|
|
1.1 ! root 1: .data ! 2: .asciz "@(#)srt0.s 1.1 86/02/03 Copyr 1985 Sun Micro"; ! 3: .even ! 4: | This variable is used in the DELAY macro. 5 is the right value for ! 5: | 68010's running 10MHz. 3 is the right value for 68020's running 16MHz ! 6: | with cache on. (4x as fast at doing the delay loop.) Other values ! 7: | should be empirically determined as needed. Srt0.s sets this value ! 8: | based on the actual runtime environment encountered. ! 9: | ! 10: | It's critical that the value be no SMALLER than required, e.g. the ! 11: | DELAY macro guarantees a MINIMUM delay, not a maximum. ! 12: .globl _cpudelay ! 13: _cpudelay: ! 14: .long 5 | Multiplier for DELAY macro. ! 15: ! 16: .text ! 17: ! 18: | Copyright (c) 1985 by Sun Microsystems, Inc. ! 19: ! 20: | ! 21: | Startup code for standalone system ! 22: | ! 23: ! 24: .globl _end ! 25: .globl _edata ! 26: .globl _main ! 27: .globl __exit ! 28: .globl __exitto ! 29: ! 30: HIGH = 0x2700 ! 31: ! 32: | FIXME!!! These should come from statreg.h or assym.h ! 33: CACR_CLEAR = 0x8 ! 34: CACR_ENABLE = 0x1 ! 35: ! 36: .globl entry ! 37: entry: ! 38: movw #HIGH,sr | just in case ! 39: leax: lea pc@(entry-(leax+2)),a0 | True current location of "entry" ! 40: lea entry:l,a1 | Desired location of "entry" ! 41: cmpl a0,a1 ! 42: jeq gobegin | If the same, just go do it. ! 43: movl #_end,d0 | Desired end of program ! 44: subl a1,d0 | Calculate length, round up. ! 45: lsrl #2,d0 ! 46: movc: movl a0@+,a1@+ | Move it where it belongs. ! 47: dbra d0,movc ! 48: ! 49: | Test if 68020: Use the 68020 scaled indexing mode, which is ignored by ! 50: | 68000/68010. ! 51: gobegin: ! 52: moveq #is020-is010,d0 | Set up jump offset ! 53: | jmp pc@((is010-.)-(is020-is010),d0:w*2) | Jump if 68010 ! 54: .word 0x4EFB ! 55: J: .word 0x0200+(is010-J)-(is020-is010) ! 56: is020: ! 57: | Turn on the cache... ! 58: moveq #CACR_CLEAR+CACR_ENABLE,d0 ! 59: .long 0x4e7b0002 | movc d0,cacr ! 60: moveq #3,d0 | Set the delay factor for 68020 ! 61: movl d0,_cpudelay ! 62: is010: ! 63: jmp begin:l | Force non-PCrel jump ! 64: ! 65: begin: ! 66: movl sp,entry-4:l | Save old stack pointer value ! 67: lea entry-4:l,sp | Set up new stack below load point ! 68: movl #_edata,a0 ! 69: clr: ! 70: clrl a0@+ ! 71: cmpl #_end,a0 ! 72: ble clr ! 73: #ifdef SUN2 ! 74: jsr _setkcontext ! 75: #endif ! 76: clrl sp@- | argv = 0 for now. ! 77: clrl sp@- | argc = 0 for now. ! 78: jsr _main ! 79: addqw #8,sp ! 80: jsr _exit | after main() returns, call exit(). ! 81: | Just fall thru into __exit if exit() ever returns. ! 82: ! 83: __exit: ! 84: movl entry-4:l,sp | Restore caller's stack pointer ! 85: rts | Return to caller (PROM probably) ! 86: ! 87: | Transfer control to a new program, passing on the same arguments that ! 88: | we (srt0.s) received when we were started. Note that this does NOT call ! 89: | exit() -- you'd better close your files yourself. ! 90: __exitto: ! 91: movl sp@(4),a0 | Address to call ! 92: movl entry-4:l,sp | Restore caller's stack pointer ! 93: jra a0@ | Jump to callee using caller's stk
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.