From 980bf8921aaa568ea6bf73631eff7506d68fd2b9 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 29 Jun 2015 00:01:25 +0200 Subject: [PATCH] Fix syscall interface and file header to actually work. --- Library/libs/crt0_msp430x.s | 10 +++++----- Library/libs/fuzixmsp430x/syscall.s | 6 +++--- Library/tools/syscall_msp430x.c | 8 ++++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Library/libs/crt0_msp430x.s b/Library/libs/crt0_msp430x.s index 4d3bfa37..d90e03d8 100644 --- a/Library/libs/crt0_msp430x.s +++ b/Library/libs/crt0_msp430x.s @@ -2,16 +2,16 @@ .globl _start _start: jmp 1f ; two bytes - .byte 0 ; one byte of padding + .byte 0 ; two bytes of padding .byte 'F', 'Z', 'X', '1' ; magic starts at 0x8003 - .word 0 ; chmem + .byte 0x80 ; page to start at + .word 0 ; chmem (0 means 'all') .word __data_start - .word __data_end - .word __bss_end + .word __data_len + .word __bss_len .word 0 ; spare - .align 2 1: ; Wipe BSS. mov #__bss_start, r12 diff --git a/Library/libs/fuzixmsp430x/syscall.s b/Library/libs/fuzixmsp430x/syscall.s index 2f2b7894..6fbb0fd2 100644 --- a/Library/libs/fuzixmsp430x/syscall.s +++ b/Library/libs/fuzixmsp430x/syscall.s @@ -5,11 +5,11 @@ _syscall: ; On entry, the syscall number is in r11 and the four parameters in ; r12-r15 (luckily, these are all caller saved). calla &(_start-4) - ; On exit from the kernel, the result in r12 is either 0 or an errno. - tst r12 + ; On exit from the kernel, the result is in r12 and r13 is an errno. + tst r13 jz 1f ; Error path. - mov r12, &errno + mov r13, &errno mov #-1, r12 1: ret diff --git a/Library/tools/syscall_msp430x.c b/Library/tools/syscall_msp430x.c index 9d7289c2..b229f71b 100644 --- a/Library/tools/syscall_msp430x.c +++ b/Library/tools/syscall_msp430x.c @@ -22,6 +22,14 @@ static void write_call(int n) "\t.globl _syscall\n" "\t.globl %1$s\n\n" "%1$s:\n", syscall_name[n]); + if (syscall_args[n] == VARARGS) + { + /* Varargs syscalls have the first argument in r12 and the others on + * the stack. We support up to four parameters. */ + fprintf(fp, "\tmov 2(sp), r13\n" + "\tmov 4(sp), r14\n" + "\tmov 6(sp), r15\n"); + } fprintf(fp, "\tmov #%d, r11\n" "\tbr #_syscall\n", n); -- 2.34.1