1 /* (CC-BY-NC-SA) ROBIN KRENS - ROBIN @ ROBINKRENS.NL
4 * 2019/9/20 - ROBIN KRENS
9 * |----------------------------|
11 * |--------------------|-------|
21 * |----------------------------|
23 * TODO: include in header enum
31 #include <sys/robsys.h>
34 #include <lib/stdio.h>
35 #include <lib/string.h>
36 #include <lib/regfunc.h>
37 #include <lib/tinyprintf.h>
41 * This is a so-called first interrupt handler
42 * The naked attribute makes sure the compiler doesn't
43 * places registers on the stack. */
45 __attribute__ ((naked))
46 void * _svc_handler(void) {
48 uint32_t * current_sp;
50 /* Test whether system call was invoked from supervisor (use MSP) or
51 * user (use PSP) mode */
55 "mrseq %0, msp" "\n\t"
56 "mrsne %0, psp" : "=r" (current_sp));
58 /* An exception (or interrupt) before entering this handler
59 * places the following on the stack
67 * PC <- placed at current_sp[6]
70 * PC contains the return address that will continue after this SVC handler
71 * is finised. The previous address (the svc # call) is at PC - 2, the
72 * first byte contains the svc number.
75 uint8_t svc_nr = ((char *) current_sp[6])[-2];
77 printf("SYSTEM CALL NR: %d", svc_nr);
83 void syscall(unsigned int * args) {
85 uint32_t svc_number = 99;
86 printf("SYSCALL NR: %x", svc_number);
89 /* switch(SYSCALL_NO) {
101 /* SVC is located at position 11 in the interrupt vector table */
102 ivt_set_gate(11, _svc_handler, 0);
106 static void kernel_cputs(char * s, size_t l) {
112 void kernel_omnigod() {