[4f508e6] | 1 | | ------------------------------------------------------------------------------
|
---|
| 2 | | lowram.s -- create a GEMDOS compatible basepage for the Buchla 700
|
---|
| 3 | | Version 10 -- 1988-03-28 -- D.N. Lynx Crowe
|
---|
| 4 | | ------------------------------------------------------------------------------
|
---|
| 5 | | Provides a GEMDOS compatible basepage and calls start_ to
|
---|
| 6 | | get things rolling for applications on the Buchla 700.
|
---|
| 7 |
|
---|
| 8 | | Also sets the stack pointer to the high end of RAM.
|
---|
| 9 |
|
---|
| 10 | | WARNING: This code ONLY works for programs loaded into RAM.
|
---|
| 11 | | ------------------------------------------------------------------------------
|
---|
| 12 | | We expect the following to be the relative layout of memory:
|
---|
| 13 |
|
---|
| 14 | | lowram load address (this chunk of code)
|
---|
| 15 | | ...
|
---|
| 16 | | p_lowtpa start of 'TPA' / basepage address
|
---|
| 17 | | ...
|
---|
| 18 | | start_ first module (starts 'text' area)
|
---|
| 19 | | ...
|
---|
| 20 | | ... -text-
|
---|
| 21 | | ...
|
---|
| 22 | | _etext end of 'text' area + 1
|
---|
| 23 | | basedat start of 'data' area (will usually be _etext)
|
---|
| 24 | | ...
|
---|
| 25 | | ... -data-
|
---|
| 26 | | ...
|
---|
| 27 | | _edata end of 'data' area + 1
|
---|
| 28 | | basebss start of 'bss' area (will usually be _edata)
|
---|
| 29 | | ...
|
---|
| 30 | | ... -BSS-
|
---|
| 31 | | ...
|
---|
| 32 | | _end end of actual 'bss' area + 1
|
---|
| 33 | | ...
|
---|
| 34 | | ... -heap-
|
---|
| 35 | | ...
|
---|
| 36 | | HI_RAM-0x400 end of pseudo 'bss' area (cleared by fsmain.s)
|
---|
| 37 | | ...
|
---|
| 38 | | ... -stack margin-
|
---|
| 39 | | ...
|
---|
| 40 | | HI_RAM end of RAM + 1, initial stack address
|
---|
| 41 | | ------------------------------------------------------------------------------
|
---|
| 42 | | The startup code in fsmain.s uses the bss length to know how much RAM
|
---|
| 43 | | to clear. We give it HI_RAM-0x400-basebss, and put the stack at HI_RAM.
|
---|
| 44 | | The startup code clears from p_bbase through p_bbase+p_blen-1, inclusive.
|
---|
| 45 | | This keeps fsmain.s from wiping itself out when it zaps the bss area.
|
---|
| 46 |
|
---|
| 47 | | The startup code (start_) in fsmain.s is entered with the address of
|
---|
| 48 | | the basepage passed as a long word parameter on the top of the stack.
|
---|
| 49 | | ------------------------------------------------------------------------------
|
---|
| 50 | .text
|
---|
| 51 |
|
---|
| 52 | .page
|
---|
| 53 |
|
---|
| 54 | | Globals defined here:
|
---|
| 55 |
|
---|
| 56 | .xdef LOWRAM
|
---|
| 57 | .xdef _Lo_RAM
|
---|
| 58 | .xdef _Hi_RAM
|
---|
| 59 |
|
---|
| 60 | .xdef basebss
|
---|
| 61 | .xdef basedat
|
---|
| 62 | .xdef p_lowtpa
|
---|
| 63 | .xdef p_env
|
---|
| 64 |
|
---|
| 65 | .xdef _p_tlen
|
---|
| 66 | .xdef _p_dlen
|
---|
| 67 |
|
---|
| 68 | | Globals referred to here:
|
---|
| 69 |
|
---|
| 70 | .xref start_ | entry point in fsmain.s
|
---|
| 71 | .xref _panic | entry point in fsmain.s
|
---|
| 72 |
|
---|
| 73 | .xref _edata | supplied by loader
|
---|
| 74 | .xref _etext | supplied by loader
|
---|
| 75 |
|
---|
| 76 | | ------------------------------------------------------------------------------
|
---|
| 77 | | Memory setup:
|
---|
| 78 | | ------------
|
---|
| 79 | | The equate for HI_RAM must be set to match the memory configuration used.
|
---|
| 80 |
|
---|
| 81 | | For a 512K system, _Hi_RAM = 0x080000
|
---|
| 82 | | For a 1024K system, _Hi_RAM = 0x100000
|
---|
| 83 |
|
---|
| 84 | _Hi_RAM = 0x100000 | highest RAM address + 1
|
---|
| 85 |
|
---|
| 86 | .page
|
---|
| 87 |
|
---|
| 88 | | LOWRAM -- Startup code for Buchla 700 application programs
|
---|
| 89 | | ------ ------------------------------------------------
|
---|
| 90 | _Lo_RAM:
|
---|
| 91 | LOWRAM: lea basebss,a0 | setup bss base
|
---|
| 92 | move.l a0,p_bbase | ...
|
---|
| 93 | lea _Hi_RAM-0x400,a1 | setup faked bss length
|
---|
| 94 | suba.l a0,a1 | ...
|
---|
| 95 | move.l a1,p_blen | ...
|
---|
| 96 |
|
---|
| 97 | lea basedat,a0 | setup data base
|
---|
| 98 | move.l a0,p_dbase | ...
|
---|
| 99 | lea _edata,a1 | setup data length
|
---|
| 100 | suba.l a0,a1 | ...
|
---|
| 101 | move.l a1,p_dlen | ...
|
---|
| 102 |
|
---|
| 103 | lea start_,a0 | setup text base
|
---|
| 104 | move.l a0,p_tbase | ...
|
---|
| 105 | lea _etext,a1 | setup text length
|
---|
| 106 | suba.l a0,a1 | ...
|
---|
| 107 | move.l a1,p_tlen | ...
|
---|
| 108 |
|
---|
| 109 | lea _Hi_RAM,a7 | setup stack pointer
|
---|
| 110 |
|
---|
| 111 | lea p_lowtpa,a0 | setup TPA base
|
---|
| 112 | move.l a0,p_lowtpa | ...
|
---|
| 113 | move.l a7,p_hitpa | setup high TPA
|
---|
| 114 |
|
---|
| 115 | move.l #p_lowtpa,-(a7) | Pass basepage address
|
---|
| 116 | jsr start_ | Start things going
|
---|
| 117 | addq.l #4,a7 | Clean up stack
|
---|
| 118 |
|
---|
| 119 | move.l #pmsg,-(a7) | OOPS: panic()
|
---|
| 120 | jsr _panic | ... shouldn't ever return
|
---|
| 121 | addq.l #4,a7
|
---|
| 122 |
|
---|
| 123 | hstop: stop #0x2000 | "Die, sucker!"
|
---|
| 124 | bra hstop
|
---|
| 125 |
|
---|
| 126 | .page
|
---|
| 127 |
|
---|
| 128 | | The mess below is the basepage. It defines the start of the pseudo 'TPA'.
|
---|
| 129 | | This MUST live in the 'text' segment for things to work.
|
---|
| 130 |
|
---|
| 131 | p_lowtpa: dc.l 0 | low address of TPA
|
---|
| 132 | p_hitpa: dc.l 0 | high address + 1 of TPA
|
---|
| 133 | p_tbase: dc.l 0 | low address of text segment
|
---|
| 134 | p_tlen: dc.l 0 | length of text segment
|
---|
| 135 | p_dbase: dc.l 0 | low address of data segment
|
---|
| 136 | p_dlen: dc.l 0 | length of data segment
|
---|
| 137 | p_bbase: dc.l 0 | low address of BSS segment
|
---|
| 138 | p_blen: dc.l 0 | length of BSS segment
|
---|
| 139 | p_dta: dc.l 0 | pointer to DTA
|
---|
| 140 | p_parent: dc.l 0 | pointet to parent basepage
|
---|
| 141 | dc.l 0
|
---|
| 142 | p_env: dc.l 0 | pointer to environment string
|
---|
| 143 | ds.l 20
|
---|
| 144 | p_cmdlin: dc.b 0 | command line tail image
|
---|
| 145 | ds.b 127
|
---|
| 146 |
|
---|
| 147 | current:
|
---|
| 148 | BPLEN = current-p_lowtpa | MUST be 0x0100 (or we goofed)
|
---|
| 149 |
|
---|
| 150 | _p_tlen = p_tlen | text length for MIDAS-VII
|
---|
| 151 | _p_dlen = p_dlen | data length for MIDAS-VII
|
---|
| 152 |
|
---|
| 153 | | ------------------------------------------------------------------------------
|
---|
| 154 | .data
|
---|
| 155 | | ------------------------------------------------------------------------------
|
---|
| 156 | .even
|
---|
| 157 |
|
---|
[6dc5ea7] | 158 | basedat: .ascii "||||| data |||||" | start of data
|
---|
[4f508e6] | 159 |
|
---|
[6dc5ea7] | 160 | pmsg: .asciz "returned from start_()" | panic() message
|
---|
[4f508e6] | 161 |
|
---|
| 162 | | ------------------------------------------------------------------------------
|
---|
| 163 | .bss
|
---|
| 164 | | ------------------------------------------------------------------------------
|
---|
| 165 | .even
|
---|
| 166 |
|
---|
| 167 | basebss: ds.l 1 | start of BSS
|
---|
| 168 |
|
---|
| 169 | .end
|
---|