Skip to content

Commit

Permalink
Syscall handling actually works now. Also implemented a workaround fo…
Browse files Browse the repository at this point in the history
…r printf(), reserved word is SYSCALL_PRINTF with value 16
  • Loading branch information
sprakes committed May 3, 2015
1 parent 1d47b17 commit 50feccc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
Binary file modified kernel/fs/cmdline/buildfs
Binary file not shown.
22 changes: 20 additions & 2 deletions kernel/hw_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,20 @@ long __attribute__((interrupt("SWI"))) software_interrupt_handler(void){
// after the SVC call
// possible that syscall # passed directly in r7, not sure yet though
register int address asm("lr");

// load the SVC call and mask to get the number
callNumber = *((uint32_t *)(address-4)) & 0x00FFFFFF;





asm("MOV %0, r7":"=r"(callNumber)::);





// We have to switch VASs to the kernel's VAS if we want to do anything
struct vas *prev_vas = vm_get_current_vas();
vm_use_kernel_vas();
Expand All @@ -75,7 +85,7 @@ long __attribute__((interrupt("SWI"))) software_interrupt_handler(void){

// Print out syscall # for debug purposes
os_printf("Syscall #: ");
os_printf("%x", callNumber);
os_printf("%d", callNumber);
os_printf("\n");

// System Call Handler
Expand All @@ -95,6 +105,7 @@ long __attribute__((interrupt("SWI"))) software_interrupt_handler(void){
int numBytes;
uint32_t byte_size;
void* ptr;
char* output;

case SYSCALL_DELETE:
os_printf("Delete system call called!\n");
Expand Down Expand Up @@ -256,6 +267,13 @@ long __attribute__((interrupt("SWI"))) software_interrupt_handler(void){
return 0;
break;

case SYSCALL_PRINTF:
os_printf("Printf system call called!\n");
asm volatile("mov r0, %[output]":[output]"=r" (output)::);
os_printf(output);
return 0;
break;

default:
os_printf("That wasn't a syscall you knob!\n");
return -1;
Expand Down
1 change: 1 addition & 0 deletions kernel/include/hw_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#define SYSCALL_MALLOC 13
#define SYSCALL_CALLOC 14
#define SYSCALL_FREE 15
#define SYSCALL_PRINTF 16

void init_vector_table(void);

Expand Down
2 changes: 0 additions & 2 deletions kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ uint32_t save_process_state(uint32_t PID){
asm("MOV %0, r14":"=r"(pcb_p->R14)::);
asm("MOV %0, r15":"=r"(pcb_p->R15)::);



return 1;

}
Expand Down

0 comments on commit 50feccc

Please sign in to comment.