Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/boot_common.asm @ 1902:d141618d38df
Can now be compiled to cobble CoCo or Dragon disks.
author | afra |
---|---|
date | Thu, 03 Nov 2005 01:36:10 +0000 |
parents | 6d5bd8549d28 |
children | 0902ccedce07 |
rev | line source |
---|---|
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
1 ******************************************************************** |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
2 * Boot Common - Common code for NitrOS-9 booters |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
3 * |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
4 * $Id$ |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
5 * |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
6 * This common file is not a stand-alone module, but is 'used' by boot module |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
7 * source files to bring in support for booting from RBF file systems that have |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
8 * either standard or new-style fragmented bootfiles. |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
9 * |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
10 * This code uses several static variables which are expected to be defined in |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
11 * the main boot source code. See a booter like boot_1773.asm for an example on |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
12 * how to write a booter which uses this code. |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
13 * |
1894 | 14 * Important Notes: |
15 * For certain devices, only the lower 16 bits of DD.BT are used. This special | |
16 * case allows us to save some code by ignoring the loading LSN bits 23-16 in | |
17 * DD.BT and FDSL.A. Booters for such devices (floppy, RAMPak) should have the | |
18 * following line in their code to take advantage of this optimization: | |
19 * | |
20 * LSN24BIT equ 0 | |
21 * | |
22 * Floppy booters require the acquistion of DD.TKS and DD.FMT from LSN0 to make | |
23 * certain decisions about the boot process. In most cases, non-floppy booters | |
24 * do not need these values. Hence, floppy booters should have this line in their | |
25 * source code file: | |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
26 * |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
27 * FLOPPY equ 1 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
28 * |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
29 * Edt/Rev YYYY/MM/DD Modified by |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
30 * Comment |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
31 * ------------------------------------------------------------------ |
1894 | 32 * 2005/10/14 Boisy G. Pitre |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
33 * Created as a stand-alone file. |
1894 | 34 * |
35 * 2005/10/16 Boisy G. Pitre | |
36 * Further optimizations made | |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
37 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
38 start orcc #IntMasks ensure IRQs are off (necessary?) |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
39 leas -size,s |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
40 tfr s,u get pointer to data area |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
41 pshs u save pointer to data area |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
42 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
43 * Request memory for LSN0 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
44 ldd #256 get sector/fd buffer |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
45 os9 F$SRqMem get it! |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
46 bcs error2 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
47 bsr getpntr restore U to point to our statics |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
48 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
49 * Initialize Hardware |
1894 | 50 ldy Address,pcr get hardware address |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
51 lbsr HWInit |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
52 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
53 * Read LSN0 |
1894 | 54 IFNE LSN24BIT |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
55 clrb MSB sector |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
56 ENDC |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
57 ldx #0 LSW sector |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
58 lbsr HWRead read LSN 0 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
59 bcs error branch if error |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
60 |
1894 | 61 IFGT Level-1 |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
62 lda #'0 --- loaded in LSN0' |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
63 jsr <D.BtBug --- |
1894 | 64 ENDC |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
65 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
66 * Pull relevant values from LSN0 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
67 IFNE FLOPPY |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
68 lda DD.TKS,x number of tracks on this disk |
1894 | 69 ldb DD.FMT,x disk format byte |
70 std ddtks,u TAKE NOTE! ASSUMES ADJACENT VARS! | |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
71 ENDC |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
72 ldd DD.BSZ,x os9boot size in bytes |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
73 beq FragBoot if zero, do frag boot |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
74 std bootsize,u |
1894 | 75 * Old style boot -- make a fake FD segment right from LSN0! |
76 leax DD.BT,x | |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
77 addd #$00FF round up to next page |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
78 * Important note: We are making an assumption that the upper 8 bits of the |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
79 * FDSL.B field will always be zero. That is a safe assumption, since an |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
80 * FDSL.B value of $00FF would mean the file is 65280 bytes. A bootfile |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
81 * under NitrOS-9 cannot be this large, and therefore this assumption |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
82 * is safe. |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
83 sta FDSL.B+1,x save file size |
1894 | 84 IFNE LSN24BIT |
85 clr FDSL.S,x make next segment entry 0 | |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
86 ENDC |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
87 clr FDSL.S+1,x |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
88 clr FDSL.S+2,x |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
89 bra GrabBootMem |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
90 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
91 Back2Krn lbsr HWTerm call HW termination routine |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
92 ldx blockimg,u pointer to start of os9boot in memory |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
93 clrb clear carry |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
94 ldd bootsize,u |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
95 error2 leas 2+size,s reset the stack same as PULS U |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
96 rts return to kernel |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
97 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
98 * Error point - return allocated memory and then return to kernel |
1894 | 99 error |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
100 * Return memory allocated for sector buffers |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
101 ldd #256 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
102 ldu blockloc,u |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
103 os9 F$SRtMem |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
104 bra error2 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
105 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
106 * Routine to save off alloced mem from F$SRqMem into blockloc,u and restore |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
107 * the statics pointer in U |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
108 getpntr tfr u,d save pointer to requested memory |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
109 ldu 2,s recover pointer to data stack |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
110 std blockloc,u |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
111 rts |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
112 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
113 * NEW! Fragmented boot support! |
1894 | 114 *FragBoot ldb bootloc,u MSB fd sector location |
115 * ldx bootloc+1,u LSW fd sector location | |
116 FragBoot ldb DD.BT,x MSB fd sector location | |
117 ldx DD.BT+1,x LSW fd sector location | |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
118 lbsr HWRead get fd sector |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
119 ldd FD.SIZ+2,x get file size (we skip first two bytes) |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
120 std bootsize,u |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
121 leax FD.SEG,x point to segment table |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
122 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
123 GrabBootMem |
1894 | 124 IFGT Level-1 |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
125 os9 F$BtMem |
1894 | 126 ELSE |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
127 os9 F$SRqMem |
1894 | 128 ENDC |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
129 bcs error |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
130 bsr getpntr |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
131 std blockimg,u |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
132 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
133 * Get os9boot into memory |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
134 BootLoop stx seglist,u update segment list |
1894 | 135 IFNE LSN24BIT |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
136 ldb FDSL.A,x MSB sector location |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
137 ENDC |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
138 BL2 ldx FDSL.A+1,x LSW sector location |
1894 | 139 IFNE LSN24BIT |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
140 bne BL3 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
141 tstb |
1894 | 142 ENDC |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
143 beq Back2Krn |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
144 BL3 lbsr HWRead |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
145 inc blockloc,u point to next input sector in mem |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
146 |
1894 | 147 IFGT Level-1 |
148 lda #'. show .' | |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
149 jsr <D.BtBug |
1894 | 150 ENDC |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
151 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
152 ldx seglist,u get pointer to segment list |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
153 dec FDSL.B+1,x get segment size |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
154 beq NextSeg if <=0, get next segment |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
155 |
1894 | 156 ldd FDSL.A+1,x update sector location by one |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
157 addd #1 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
158 std FDSL.A+1,x |
1894 | 159 IFNE LSN24BIT |
1893
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
160 ldb FDSL.A,x |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
161 adcb #0 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
162 stb FDSL.A,x |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
163 ENDC |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
164 bra BL2 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
165 |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
166 NextSeg leax FDSL.S,x advance to next segment entry |
1827bb446188
Modified booters to use new boot strategy with boot_common.asm
boisy
parents:
diff
changeset
|
167 bra BootLoop |