Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
abinade2
kernel
Commits
9f59fe2b
Commit
9f59fe2b
authored
7 years ago
by
abinade2
Browse files
Options
Downloads
Patches
Plain Diff
grep now works
parent
c9ffa12a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
student-distrib/rtc.c
+9
-0
9 additions, 0 deletions
student-distrib/rtc.c
student-distrib/syscall.c
+21
-21
21 additions, 21 deletions
student-distrib/syscall.c
with
30 additions
and
21 deletions
student-distrib/rtc.c
+
9
−
0
View file @
9f59fe2b
...
...
@@ -86,8 +86,10 @@ int32_t rtc_read(int32_t fd, void* buf, int32_t nbytes)
//interrupt_flag = 1;
sti
();
/* Wait until interrupt handler clears flag */
while
(
rtc_flag
[
running_terminal
]);
cli
();
return
0
;
...
...
@@ -176,8 +178,15 @@ int32_t rtc_write(int32_t fd, const void* buf, int32_t nbytes)
*/
int32_t
rtc_open
(
const
uint8_t
*
filename
)
{
int32_t
freq
=
2
;
/* Set RTC to active for the running terminal */
rtc_active
[
running_terminal
]
=
1
;
rtc_counter
[
running_terminal
]
=
INIT_FREQ
/
freq
;
rtc_init_counter
[
running_terminal
]
=
rtc_counter
[
running_terminal
];
return
0
;
...
...
This diff is collapsed.
Click to expand it.
student-distrib/syscall.c
+
21
−
21
View file @
9f59fe2b
...
...
@@ -206,9 +206,9 @@ int32_t execute(const uint8_t* command){
terminal
[
running_terminal
].
pcb
=
pcb_ptr
;
//printf("[EXE] using pcb = %x\n", terminal[
visible
_terminal].pcb);
//printf("[EXE] using pcb = %x\n", terminal[
running
_terminal].pcb);
//printf("[EXE] set pcb ebp to %x , esp to %x\n", terminal[
visible
_terminal].pcb->current_ebp, terminal[
visible
_terminal].pcb->current_esp);
//printf("[EXE] set pcb ebp to %x , esp to %x\n", terminal[
running
_terminal].pcb->current_ebp, terminal[
running
_terminal].pcb->current_esp);
//printf("[EXE] should be ebp %x , esp %x\n", temp_ebp, temp_esp);
//--------------------- 6: scheduling initilization -----------------------
...
...
@@ -271,7 +271,7 @@ int32_t read (int32_t fd_n, void* buf, int32_t nbytes){
if
(
nbytes
<
0
)
return
-
1
;
// invalid nbytes
//terminal[
visible
_terminal].pcb = current_pcb();
//terminal[
running
_terminal].pcb = current_pcb();
/* Enable for keyboard interrupts */
//sti();
...
...
@@ -338,7 +338,7 @@ int32_t open (const uint8_t* filename){
int
type
;
dentry_t
dentry
;
terminal
[
visible
_terminal
].
pcb
=
current_pcb
();
//
terminal[
running
_terminal].pcb = current_pcb();
/* Valid file name check */
if
(
strlen
(
(
char
*
)
filename
)
==
0
)
return
-
1
;
...
...
@@ -354,7 +354,7 @@ int32_t open (const uint8_t* filename){
for
(
i
=
USER_FILE_START
;
i
<
MAX_FILE_NUM
;
i
++
){
/* Check if FD table entry is unused */
if
(
terminal
[
visible
_terminal
].
pcb
->
fd
[
i
].
flags
==
0
)
if
(
terminal
[
running
_terminal
].
pcb
->
fd
[
i
].
flags
==
0
)
{
fd
=
i
;
break
;
...
...
@@ -365,25 +365,25 @@ int32_t open (const uint8_t* filename){
}
terminal
[
visible
_terminal
].
pcb
->
fd
[
fd
].
inode_index
=
(
type
==
2
)
?
dentry
.
inode_index
:
0
;
terminal
[
visible
_terminal
].
pcb
->
fd
[
fd
].
file_pos
=
0
;
terminal
[
visible
_terminal
].
pcb
->
fd
[
fd
].
flags
=
1
;
terminal
[
running
_terminal
].
pcb
->
fd
[
fd
].
inode_index
=
(
type
==
2
)
?
dentry
.
inode_index
:
0
;
terminal
[
running
_terminal
].
pcb
->
fd
[
fd
].
file_pos
=
0
;
terminal
[
running
_terminal
].
pcb
->
fd
[
fd
].
flags
=
1
;
switch
(
type
)
{
case
0
:
terminal
[
visible
_terminal
].
pcb
->
fd
[
fd
].
fileop_ptr
=
rtc_jumptable
;
terminal
[
running
_terminal
].
pcb
->
fd
[
fd
].
fileop_ptr
=
rtc_jumptable
;
break
;
case
1
:
terminal
[
visible
_terminal
].
pcb
->
fd
[
fd
].
fileop_ptr
=
dir_jumptable
;
terminal
[
running
_terminal
].
pcb
->
fd
[
fd
].
fileop_ptr
=
dir_jumptable
;
break
;
case
2
:
terminal
[
visible
_terminal
].
pcb
->
fd
[
fd
].
fileop_ptr
=
file_jumptable
;
terminal
[
running
_terminal
].
pcb
->
fd
[
fd
].
fileop_ptr
=
file_jumptable
;
break
;
}
sti
();
//
sti();
terminal
[
visible
_terminal
].
pcb
->
fd
[
fd
].
fileop_ptr
.
open
(
filename
);
terminal
[
running
_terminal
].
pcb
->
fd
[
fd
].
fileop_ptr
.
open
(
filename
);
return
fd
;
}
...
...
@@ -402,11 +402,11 @@ int32_t close (int32_t fd){
if
(
fd_check
(
fd
)
<
0
||
fd
<
USER_FILE_START
)
return
-
1
;
// invalid fd
terminal
[
visible
_terminal
].
pcb
=
current_pcb
();
//
terminal[
running
_terminal].pcb = current_pcb();
sti
();
//
sti();
terminal
[
visible
_terminal
].
pcb
->
fd
[
fd
].
fileop_ptr
.
close
(
fd
);
terminal
[
running
_terminal
].
pcb
->
fd
[
fd
].
fileop_ptr
.
close
(
fd
);
fd_clear
(
fd
);
...
...
@@ -433,10 +433,10 @@ int32_t getargs (uint8_t* buf, int32_t nbytes){
uint8_t
*
argument
;
terminal
[
visible
_terminal
].
pcb
=
current_pcb
();
argument
=
(
uint8_t
*
)
(
terminal
[
visible
_terminal
].
pcb
->
argv
);
//
terminal[
running
_terminal].pcb = current_pcb();
argument
=
(
uint8_t
*
)
(
terminal
[
running
_terminal
].
pcb
->
argv
);
if
(
terminal
[
visible
_terminal
].
pcb
->
arg_num
==
0
||
nbytes
<=
0
)
if
(
terminal
[
running
_terminal
].
pcb
->
arg_num
==
0
||
nbytes
<=
0
)
{
//printf("[getargs] return -1\n");
return
-
1
;
//If there are no arguments
...
...
@@ -448,8 +448,8 @@ int32_t getargs (uint8_t* buf, int32_t nbytes){
memcpy
(
buf
,
argument
,
nbytes
);
// uint32_t i;
// //printf("[getargs] argument number = %d\n", terminal[
visible
_terminal].pcb->arg_num);
// for(i = 0; i < terminal[
visible
_terminal].pcb->arg_num; i++)
// //printf("[getargs] argument number = %d\n", terminal[
running
_terminal].pcb->arg_num);
// for(i = 0; i < terminal[
running
_terminal].pcb->arg_num; i++)
// //printf("[getargs] buf[%d] = %s\n", i, buf+i*MAX_ARGUMENT_SIZE);
//printf("[getargs] return 0\n");
return
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment