2351
|
1 ********************************************************************
|
|
2 * NitrOS9 - Sets up NitrOS-9 Level 3
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Edt/Rev YYYY/MM/DD Modified by
|
|
7 * Comment
|
|
8 * ------------------------------------------------------------------
|
|
9 * ????/??/?? Alan DeKok
|
|
10 * Created.
|
|
11
|
|
12 nam NitrOS9
|
|
13 ttl Sets up NitrOS-9 Level 3
|
|
14
|
|
15 ifp1
|
|
16 use defsfile
|
|
17 endc
|
|
18
|
|
19 tylg set Systm+Obj6309
|
|
20 atrv set ReEnt+rev
|
|
21 rev set $04
|
|
22 mod eom,name,tylg,atrv,Start,size
|
|
23 u0000 rmb 0
|
|
24 size equ .
|
|
25 name equ *
|
|
26 fcs /NitrOS9/
|
|
27 fcb $01
|
|
28
|
|
29 Start ldd #$10ff illegal instruction, /0 trap
|
|
30 std >0
|
|
31 ldd #$0008
|
|
32 std >2
|
|
33 ldd #$20FE
|
|
34 std >4
|
|
35
|
|
36 * allocate a block of RAM for SCF drivers
|
|
37 ldu #eom get the size of this module
|
|
38 leax eom,pc point to the next module
|
|
39 ldy #L3.SCF
|
|
40
|
|
41 all.ram bsr f.modul move some modules over
|
|
42 tstb did we, in fact, move any?
|
|
43 beq all.done if not, we're done
|
|
44 stb ,y+ save the starting RAM block number
|
|
45 bra all.ram and go get another block of RAM
|
|
46
|
|
47 * Verify the rest of the boot: start of old OS9p1 code
|
|
48 all.done ldd <D.BtSz get the size of the boot
|
|
49 subr u,d take out the size of the modules we're skipping
|
|
50 * F$VBlock has NO exit conditions, and doesn't change any registers
|
|
51 OS9 F$VBlock go verify the rest of the OS9Boot file
|
|
52 * do NOT use U after this!
|
|
53
|
|
54 * set the DAT image of the allocate blocks to be RAMInUse, rather than
|
|
55 * Module In block
|
|
56 ldx <D.SysDAT point to the system DAT image
|
|
57 ldb $0D,x grab the block# of the last allocated block
|
|
58 incb account for block 0: leave SCF & RBF as ModInBlk
|
|
59 lda #RAMInUse set the RAM to be in use...
|
|
60 ldx <D.BlkMap point to system block allocation map
|
|
61
|
|
62 set.lp sta ,x+ allocate the RAM
|
|
63 decb count down
|
|
64 bne set.lp continue until done
|
|
65
|
|
66 ldx <D.BlkMap grab the block map again
|
|
67 sta <$3F,x mark the boot track block as used, too.
|
|
68
|
|
69 * mark block 1 ($2000-$3FFF) in the system memory map as allocated
|
|
70 ldx <D.SysMem ptr to low system memory
|
|
71 ldd #$0100+L3.Size RAMInUse, N times
|
|
72 leax $20,x to the start of block 1 in the block map
|
|
73 blk.lp sta ,x+ set it to be in use
|
|
74 decb
|
|
75 bne blk.lp
|
|
76
|
|
77 * U = total size of the crap we've removed
|
|
78 ldd <D.BtSz size of the bootfile
|
|
79 subr u,d take out size of code we've removed
|
|
80 std <D.BtSz
|
|
81 ldd <D.BtPtr
|
|
82 addr u,d point to new start of the OS9Booto file
|
|
83 pshs d and save for later
|
|
84 tfr u,d size of code we've taken out
|
|
85 subd #$00FF round _down_ a page
|
|
86
|
|
87 ldx <D.SysMem pt to system memory map
|
|
88 ldb <D.BtPtr point to start of OS9Boot in memory
|
|
89 abx go to it
|
|
90
|
|
91 * remove the memory from the system memory map
|
|
92 m.lp clr ,x+ set the RAM to be not in use
|
|
93 deca count down the number of pages we've moved
|
|
94 bne m.lp continue
|
|
95 bra x.done
|
|
96
|
|
97 leax -1,x point to last unused byte
|
|
98 tfr x,d move into an address register
|
|
99 lsra
|
|
100 lsra
|
|
101 lsra
|
|
102 lsra
|
|
103 lsra now A=block number of highest block
|
|
104 ldb <D.BtPtr
|
|
105 lsrb
|
|
106 lsrb
|
|
107 lsrb
|
|
108 lsrb
|
|
109 lsrb
|
|
110 subr b,a same block? (now A=number of blocks to delete)
|
|
111 beq x.done yes, don't do anything
|
|
112
|
|
113 ldu <D.BlkMap point to system-wide block map
|
|
114 ldx <D.SysDAT pointer to system DAT image
|
|
115 lslb convert to DAT image offset
|
|
116 incb point to block number, not flag
|
|
117 abx point to the offset
|
|
118
|
|
119 x.loop ldb ,x++ grab a block number
|
|
120 clr b,u mark the block as unused
|
|
121 deca
|
|
122 bne x.loop continue until done
|
|
123
|
|
124 x.done puls d restore ptr to new start of the OS9Boot file
|
|
125 std <D.BtPtr and save it again
|
|
126 clrb
|
|
127 rts
|
|
128
|
|
129 *============================================================================
|
|
130 *
|
|
131 * Copy the modules into local memory.
|
|
132 * Copied from [X] to a module called _end
|
|
133 * Entry: X = ptr to start at
|
|
134 * U = size of stuff deleted so far
|
|
135 * Exit : X = ptr to module after _end module
|
|
136 * U = total size of stuff deleted
|
|
137
|
|
138 f.modul pshs b,x,y,u save start of area to move, size moved before
|
|
139 * grab the name: is it _end?
|
|
140 is.end ldd ,x
|
|
141 cmpd #$87Cd is it a module?
|
|
142 bne f.exit no, exit
|
|
143 ldd M$Name,x get the name pointer
|
|
144 ldd d,x get 2 bytes of the name
|
|
145 cmpd #$5F65 '_e'?
|
|
146 beq fnd.end yes, found it
|
|
147
|
|
148 * skip this module if not at the end yet
|
|
149 ldd M$Size,x grab the module size
|
|
150 leax d,x go to the next module
|
|
151 leau d,u add in the size of it
|
|
152 bra is.end and continue looking for end
|
|
153
|
|
154 f.exit clrb we're done everything
|
|
155 puls a,x,y,u,pc
|
|
156
|
|
157 * copy modules over, and verify
|
|
158 fnd.end ldy 1,s restore ptr to start of area to move
|
|
159 tfr u,w new size
|
|
160 subw 5,s take out old size: W = total size
|
|
161 cmpw #L3.Size*$FF greater than the room available?
|
|
162 bhs f.exit yes, exit without allocating RAM
|
|
163
|
|
164 * skip _end module
|
|
165 ldd M$Size,x get size of the _end module
|
|
166 leax d,x skip it
|
|
167 leau d,u
|
|
168 stx 1,s save new start ptr
|
|
169 stu 5,s and new size
|
|
170
|
|
171 * we've found blocks to move, so let's allocate some RAM
|
|
172 ldb #L3.Blks 1 block to allocate
|
|
173 OS9 F$AllRAM allocate some RAM
|
|
174
|
|
175 std >$0642 map it into system DAT image
|
|
176 stb >$FFA1 map into physical RAM
|
|
177 stb ,s save starting block number
|
|
178
|
|
179 ifeq L3.Blks-2 more than 1 block?
|
|
180 incb yes, go up by a block
|
|
181 std >$0644 map it into the system DAT image
|
|
182 stb >$FFA2 and into the hardware
|
|
183 endc
|
|
184
|
|
185 * move the modules to local RAM
|
|
186 pshsw save size of the block to move
|
|
187 ldx #L3.Start+L3.Size where to move the stuff to
|
|
188 tfm y+,x+ move it from the OS9Boot file to IOMan local memory
|
|
189
|
|
190 * verify the modules
|
|
191 puls d grab the size of the block
|
|
192 ldx #L3.Start+L3.Size start ptr again
|
|
193 OS9 F$VBlock verify the block
|
|
194
|
|
195 * get A = total size (in pages) of stuff moved over
|
|
196 addd #L3.Size+$FF round up to the nearest block, adding in $20
|
|
197
|
|
198 * start with all local RAM deallocated
|
|
199 ldx #L3.Start to the start of the block
|
|
200 ldb #L3.Size-1 number of pages to mark as free
|
|
201 clr.lp clr b,x set them to be all clear.
|
|
202 decb
|
|
203 bpl clr.lp count down until B=-1
|
|
204
|
|
205 * allocate local RAM to the size of the modules we've moved over
|
|
206 ldb #RAMInUse RAM in use
|
|
207 all.lp stb ,x+ make the page allocated
|
|
208 deca count down a page
|
|
209 bne all.lp and continue
|
|
210
|
|
211 lda #'- a hyphen
|
|
212 jsr <D.BtBug print it out
|
|
213
|
|
214 * restore start, size pointers and exit
|
|
215 puls b,x,y,u,pc
|
|
216
|
|
217 emod
|
|
218 eom equ *
|
|
219 end
|