Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Krishna Vinnakota
CSEP551
Commits
f3d29022
Commit
f3d29022
authored
18 years ago
by
rsc
Browse files
Options
Downloads
Patches
Plain Diff
add cons_puts for atomic (readable) output
parent
9b37d1bf
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
syscall.c
+40
-5
40 additions, 5 deletions
syscall.c
syscall.h
+1
-0
1 addition, 0 deletions
syscall.h
with
41 additions
and
5 deletions
syscall.c
+
40
−
5
View file @
f3d29022
...
...
@@ -30,7 +30,18 @@ fetchint(struct proc *p, unsigned addr, int *ip)
if
(
addr
>
p
->
sz
-
4
)
return
-
1
;
memmove
(
ip
,
p
->
mem
+
addr
,
4
);
*
ip
=
*
(
int
*
)(
p
->
mem
+
addr
);
return
0
;
}
// Fetch byte from a user-supplied pointer.
// Returns 0 on success, -1 if pointer is illegal.
int
fetchbyte
(
struct
proc
*
p
,
unsigned
addr
,
char
*
c
)
{
if
(
addr
>=
p
->
sz
)
return
-
1
;
*
c
=
*
(
p
->
mem
+
addr
);
return
0
;
}
...
...
@@ -174,7 +185,8 @@ sys_kill(void)
{
int
pid
;
fetcharg
(
0
,
&
pid
);
if
(
fetcharg
(
0
,
&
pid
)
<
0
)
return
-
1
;
return
proc_kill
(
pid
);
}
...
...
@@ -182,9 +194,31 @@ int
sys_cons_putc
(
void
)
{
int
c
;
char
buf
[
2
];
if
(
fetcharg
(
0
,
&
c
)
<
0
)
return
-
1
;
buf
[
0
]
=
c
;
buf
[
1
]
=
0
;
cprintf
(
"%s"
,
buf
);
return
0
;
}
fetcharg
(
0
,
&
c
);
cons_putc
(
c
&
0xff
);
int
sys_cons_puts
(
void
)
{
char
buf
[
256
];
int
i
;
unsigned
addr
;
struct
proc
*
cp
=
curproc
[
cpu
()];
if
(
fetcharg
(
0
,
&
addr
)
<
0
)
return
-
1
;
for
(
i
=
0
;
i
<
sizeof
buf
-
1
&&
fetchbyte
(
cp
,
addr
+
i
,
&
buf
[
i
])
>=
0
;
i
++
)
if
(
buf
[
i
]
==
0
)
break
;
buf
[
i
]
=
0
;
cprintf
(
"%s"
,
buf
);
return
0
;
}
...
...
@@ -219,7 +253,8 @@ sys_panic(void)
struct
proc
*
p
=
curproc
[
cpu
()];
unsigned
int
addr
;
fetcharg
(
0
,
&
addr
);
if
(
fetcharg
(
0
,
&
addr
)
<
0
)
return
-
1
;
panic
(
p
->
mem
+
addr
);
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
syscall.h
+
1
−
0
View file @
f3d29022
...
...
@@ -9,3 +9,4 @@
#define SYS_block 9
#define SYS_kill 10
#define SYS_panic 11
#define SYS_cons_puts 12
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