Last change
on this file since 582 was
444,
checked in by satin@…, 7 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.6 KB
|
Rev | Line | |
---|
[444] | 1 | extern int main(int argc, char **argv, char **envp); |
---|
| 2 | extern int brk (void *value); |
---|
| 3 | |
---|
| 4 | extern char bss_start; |
---|
| 5 | extern char end; |
---|
| 6 | |
---|
| 7 | char *__env[1] = {0}; |
---|
| 8 | char **environ = __env; |
---|
| 9 | |
---|
| 10 | #define ENABLE_TRACE_MASK 1 |
---|
| 11 | |
---|
| 12 | __inline static void |
---|
| 13 | enable_tracing (void) |
---|
| 14 | { |
---|
| 15 | register int mask = ENABLE_TRACE_MASK; |
---|
| 16 | __asm__ volatile ("modpc %0,%0,%0" |
---|
| 17 | : |
---|
| 18 | : "d" (mask)); |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | #define STACK_ALIGN 64 |
---|
| 22 | |
---|
| 23 | __inline static void |
---|
| 24 | set_stack (void* ptr) |
---|
| 25 | { |
---|
| 26 | ptr = (void *)(((int)ptr + STACK_ALIGN - 1) & ~(STACK_ALIGN - 1)); |
---|
| 27 | /* SP must be 64 bytes larger than FP at start. */ |
---|
| 28 | __asm__ volatile ("mov %0,sp" |
---|
| 29 | : |
---|
| 30 | : "d" (ptr+STACK_ALIGN)); |
---|
| 31 | __asm__ volatile ("mov %0,fp" |
---|
| 32 | : |
---|
| 33 | : "d" (ptr)); |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | __inline static void |
---|
| 37 | init_Cregs (void) |
---|
| 38 | { |
---|
| 39 | /* set register values gcc like */ |
---|
| 40 | register unsigned int mask0=0x3b001000; |
---|
| 41 | register unsigned int mask1=0x00009107; |
---|
| 42 | __asm__ volatile ("mov %0,g14" |
---|
| 43 | : /* no output */ |
---|
| 44 | : "I" (0)); /* gnu structure pointer */ |
---|
| 45 | __asm__ volatile ("modac %1,%0,%0" |
---|
| 46 | : /* no output */ |
---|
| 47 | : "d" (mask0), |
---|
| 48 | "d" (mask1)); /* fpu control kb */ |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | void |
---|
| 52 | _start(void) |
---|
| 53 | { |
---|
| 54 | char *p; |
---|
| 55 | |
---|
| 56 | enable_tracing (); |
---|
| 57 | set_stack (&end); |
---|
| 58 | init_Cregs (); |
---|
| 59 | /* The stack grows upwards, so this makes the heap start after a 256K |
---|
| 60 | stack area. PlumHall known to fail with less than 73K of stack. */ |
---|
| 61 | brk (&end+0x40000); |
---|
| 62 | /* clear bss */ |
---|
| 63 | memset (&bss_start, 0, &end - &bss_start); |
---|
| 64 | main(0, 0, 0); |
---|
| 65 | exit(0); |
---|
| 66 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.