Mercurial > sos > sos
annotate src/os/scall.c @ 115:4473e746fe5a
Restructured the include directory somewhat
author | Jonathan Pevarnek <pevarnj@gmail.com> |
---|---|
date | Sat, 11 Jun 2011 16:40:48 -0400 |
parents | d971d4288a5a |
children | 32560561ccea |
rev | line source |
---|---|
103
963bed9f5592
Attempted to set up the syscall handler
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
1 #include <os/scall.h> |
107
a57cb2d58b2a
Added defines for syscall numbers
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
106
diff
changeset
|
2 #include <os/svcNums.h> |
109
b3fe51f1d753
Added an ls program, fixed plenty of bugs
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
108
diff
changeset
|
3 #include <os/fs.h> |
115
4473e746fe5a
Restructured the include directory somewhat
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
113
diff
changeset
|
4 #include <os/svc.h> |
109
b3fe51f1d753
Added an ls program, fixed plenty of bugs
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
108
diff
changeset
|
5 /* |
b3fe51f1d753
Added an ls program, fixed plenty of bugs
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
108
diff
changeset
|
6 #include <stdio.h> |
b3fe51f1d753
Added an ls program, fixed plenty of bugs
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
108
diff
changeset
|
7 #include <string.h> |
b3fe51f1d753
Added an ls program, fixed plenty of bugs
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
108
diff
changeset
|
8 */ |
103
963bed9f5592
Attempted to set up the syscall handler
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
9 |
963bed9f5592
Attempted to set up the syscall handler
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
10 u64 svc_handler(u64 callCode, u64 a, u64 b, u64 c, u64 d) |
963bed9f5592
Attempted to set up the syscall handler
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
11 { |
105
fb73c5728eaf
osTest is a hello world program. It works.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
103
diff
changeset
|
12 Psw psw; |
fb73c5728eaf
osTest is a hello world program. It works.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
103
diff
changeset
|
13 u64 registers[16]; |
fb73c5728eaf
osTest is a hello world program. It works.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
103
diff
changeset
|
14 savecontext(&psw, registers); |
103
963bed9f5592
Attempted to set up the syscall handler
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
15 switch(callCode) { |
107
a57cb2d58b2a
Added defines for syscall numbers
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
106
diff
changeset
|
16 case SVC_EXIT: |
103
963bed9f5592
Attempted to set up the syscall handler
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
17 setcontext(&shellPsw, shellRegisters); |
106
6243450db431
It works! Also, fixed up many a return value.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
105
diff
changeset
|
18 break; |
107
a57cb2d58b2a
Added defines for syscall numbers
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
106
diff
changeset
|
19 case SVC_PRINT: //print |
106
6243450db431
It works! Also, fixed up many a return value.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
105
diff
changeset
|
20 registers[2] = putline((char*)a, (u32)b); |
103
963bed9f5592
Attempted to set up the syscall handler
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
21 break; |
113
d971d4288a5a
An attempt to get the standard library to work for both the system level stuff and the program level stuff
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
109
diff
changeset
|
22 case SVC_READ: |
d971d4288a5a
An attempt to get the standard library to work for both the system level stuff and the program level stuff
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
109
diff
changeset
|
23 registers[2] = getline((char*)a, (u32)b); |
d971d4288a5a
An attempt to get the standard library to work for both the system level stuff and the program level stuff
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
109
diff
changeset
|
24 break; |
109
b3fe51f1d753
Added an ls program, fixed plenty of bugs
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
108
diff
changeset
|
25 case SVC_FINFO: |
b3fe51f1d753
Added an ls program, fixed plenty of bugs
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
108
diff
changeset
|
26 registers[2] = getFInfo(a, (void*) b); |
b3fe51f1d753
Added an ls program, fixed plenty of bugs
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
108
diff
changeset
|
27 break; |
107
a57cb2d58b2a
Added defines for syscall numbers
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
106
diff
changeset
|
28 default: |
a57cb2d58b2a
Added defines for syscall numbers
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
106
diff
changeset
|
29 registers[2] = -1; //TODO HACK |
a57cb2d58b2a
Added defines for syscall numbers
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
106
diff
changeset
|
30 break; |
103
963bed9f5592
Attempted to set up the syscall handler
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
31 } |
105
fb73c5728eaf
osTest is a hello world program. It works.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
103
diff
changeset
|
32 setcontext(&psw, registers); |
106
6243450db431
It works! Also, fixed up many a return value.
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
105
diff
changeset
|
33 return -1; //the code should never get here |
103
963bed9f5592
Attempted to set up the syscall handler
Jonathan Pevarnek <pevarnj@gmail.com>
parents:
diff
changeset
|
34 } |