wrote a shell but have an error will debug tomorrow
This commit is contained in:
21
user.c
21
user.c
@@ -1,13 +1,32 @@
|
||||
#include "user.h"
|
||||
#include "common.h"
|
||||
|
||||
extern char __stack_top[];
|
||||
|
||||
int syscall(int sysno, int arg0, int arg1, int arg2) {
|
||||
register int a0 __asm__("a0") = arg0;
|
||||
register int a1 __asm__("a1") = arg1;
|
||||
register int a2 __asm__("a2") = arg2;
|
||||
register int a3 __asm__("a3") = sysno;
|
||||
|
||||
__asm__ __volatile__("ecall"
|
||||
: "=r"(a0)
|
||||
: "r"(a0), "r"(a1), "r"(a2), "r"(a3)
|
||||
: "memory");
|
||||
|
||||
return a0;
|
||||
}
|
||||
|
||||
__attribute__((noreturn)) void exit(void) {
|
||||
for(;;);
|
||||
}
|
||||
|
||||
void putchar(char ch) {
|
||||
// TODO
|
||||
syscall(SYS_PUTCHAR, ch, 0, 0);
|
||||
}
|
||||
|
||||
int getchar(void) {
|
||||
return syscall(SYS_GETCHAR, 0, 0, 0);
|
||||
}
|
||||
|
||||
__attribute__((section(".text.start")))
|
||||
|
Reference in New Issue
Block a user