system/shard-x86-at/7/src/BOOT.ASM

Raw file
Back to index

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
;*****************************************************************************
;*======= Copyright (C) 1985,86 Martin Schoenbeck, Spenge ===================*
;*                                                                           *
;*        Laden des EUMEL - Restsystems vom Archiv oder HG                   *
;*                                                                           *
;*****************************************************************************

; Versionsschluessel:
;2.2 enthaelt mehrere Partition, Floppy size = 0 bei start und fehler
;2.3 enhaelt Floppy mit Block 0 lesen immer erlaubt
;2.4 Drucker geht ueber rom, wenn adresse nicht ibmlike
;    mehrere Drucker moeglich
;    busy Abfrage kann verzoegert werden (Problem LQ1000)
;    es werden nur die vorhandenen Schnittstellen angezeigt
;    Lesezugriffe bis Block 6 auf Floppy werden immer erlaubt
;2.5 Hercules Karte wird unterstuetzt
;    Bei AT werden schlechte sectoren statt spuren behandelt
;2.6 Fehler in Plattengröße bei behoben (meldete immer al <> 0)
;2.7 Floppylogik fuer 1.7.3 restauriert, Floppy steht jetzt immer
;    auf 360k, wenn keine Floppy erkannt wird, und der Urlader die
;    HG-Version 1742 hat.
;    die Schnittstellen der Addonics-Karte sind jetzt immer mit drin,
;    wenn COM4 generiert sind.
;    Die Druckerkanäle liegen auf 15,14,16
;    Die Baudrateabfrage verneint auch 0

los_gehts:
     cli
; achtung: es und si muessen bis zum einstellen der Festplatte
; unveraendert bleiben !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     mov ax,cs
     mov ds,ax
; cs in vorlaeufige EUMEL Tabelle eintragen
     mov bx,offset systemstart+2
     mov cx,eumel_cs_init_length
self_cs_init_loop:
     mov word ptr [bx],ax
     add bx,4
     loop self_cs_init_loop
; cs in SHard - Tabelle eintragen
     mov bx,offset first_shard_cs_to_alter
     mov cx,shard_cs_alter_length
shard_cs_init_loop:
     mov word ptr [bx],cs     ;put in my code segment
     add bx,4
     loop shard_cs_init_loop 
; berechnen, wohin der EUMEL spaeter soll
     mov bx,offset lastbootbyte  ;relativen paragraph ausrechnen
     mov cl,4
     shr bx,cl
     inc bx
     add ax,bx                ;hier soll spaeter der EUMEL hin
     mov ss,ax
     mov sp,0
     push si                  ;werte fuer plattensetup merken
     push es
; warte routine fuer Platten und Floppytreiber eintragen
     call device_init           ;int 15 eintragen
; alle Kanaele initialisieren
     mov dh,33
     mov al,0
inilop:
     mov cx,-2
     push ax
     call control32
     pop ax
     cli
     inc al
     dec dh
     jnz inilop
     sti                      ;interrupts sind erlaubt
     mov bx,offset signon     ;sag ihm, wer wir sind
     call print
; alle kanaele fuer festplatte einstellen (falls vorhanden)
     pop es
     pop si                   ;zeiger auf partitiontabelle wiederholen
     call setup_fix_disk
; EUMEL 0 laden
getagain:
   ife gensys
     mov al,31      ;zuerst von kanal 31 versuchen
     mov bx,offset archtext
     call geteumel
   endif
     mov al,0
     mov bx,offset hgtext
     call geteumel
     mov bx,offset noeutext
     call print
     call waitchar
     jmp getagain

geteumel:	;EUMEL 0 laden und bei Erfolg starten
     push ax
     mov cx,5       ;size
     call cs:iocontrol
     pop ax
     push bx        ;text fuer medium merken
     mov cx,ss      ;ausrechnen, wohin der urlader muss (ss:0)
     add cx,31                ;damit wir nicht rueckwaerts gehen
     and cx,0ffe0h  ;auf 512 byte boundary
     mov ds,cx      ;segment nach ds
     mov bx,0       ;bei 0 im segment laden wir zuerst
     mov cx,0       ;auftrag
     mov dx,10      ;erster urlader block ist 10
     mov ah,1       ;nur ein versuch 
     cmp al,0
     ifz <mov ah,3> ;hintergrund muss lesbar sein
     push bx 
     push ds
     call getblock
     pop ds
     pop bx
     or cx,cx       ;fehlerfrei?
     jz firstok
     pop bx         ;text fuer medium vergessen
     ret
firstok:
     push ax
     mov cx,5       ;text EUMEL hat 5 buchstaben
     mov si,offset eutext     ;text EUMEL
     mov di,bx                ;puffer
textloop: 
     lods byte ptr cs:[si]
     cmp al,byte ptr ds:[di]
     jz charok
     pop ax         ;stack saeubern
     pop bx
     ret            ;nicht gleich, kein eumel urlader
charok:
     inc di
     loop textloop
     pop ax         ;kanal fuer urlader wiederholen
     pop bx         ;text fuer medium holen
     call print     ;ausgeben
     mov bx,0       ;bx ist zerstoert, aber wir wissen, wohin
     mov ah,8       ;ab hier mit acht versuchen
euloop:
     mov cx,0
     inc dx
     add bx,512     ;auf naechsten block schalten
     push bx
     push ds
     call getblock
     or cx,cx
     jnz booterr
     pop ds
     pop bx
     cmp dx,10+100  ;schon kompletten urlader gelesen
     jnz euloop
; Sprungleiste vom EUMEL abholen
     push cs
     pop es                   ;ziel ist codesegment
     mov si,0
     mov di,offset eumel0id
     mov cx,eumel_leisten_laenge 
     cli
     cld
     rep movsb
     mov ax,ds                ;eumel codesegment nach ax
     push cs                  ;datensegment wieder auf shard
     pop ds
; und passendes cs eintragen
     mov bx,offset systemstart+2
     mov cx,eumel_cs_init_length
eumel_cs_init_loop:
     mov word ptr [bx],ax
     add bx,4
     loop eumel_cs_init_loop 
     call paragraphs
     sub dx,ax                ;rest fuer eumel ausrechnen
    if ramsys
     urram equ 1000h

     sub dx,urram             ;64k fuer urlader und paging
     mov M3SIZE,dx
     mov M0SIZE,urram
     mov M0START,ax
     add ax,urram
     mov M3START,ax
    else
     mov M0SIZE,dx
     mov M0START,ax           ;eumel codesegment eintragen
    endif
     mov ax,31           ;allen floppies die chance geben
i173lop:                 ;sich auf 173 einzustellen
     mov cx,-173
     push ax
     call control32
     pop ax
     dec al
     jnz i173lop
     mov bx,offset SHard_leiste
     jmp systemstart
 

booterr:
     push ds
     push bx
     mov bx,offset booterrtext
     call print
     pop bx
     pop ds
     call dsprint
     jmp $
 
getblock:
     push ax        ;original ax merken
getloop:
     push bx
     push ds 
     push ax        ;ax mit retry zaehler
     mov cx,0
     call cs:blockin
     pop ax
     or cx,cx
     jnz geterr
     pop ds
     pop bx
     pop ax
     ret
geterr:
     dec ah         ;genuegend retries
     jnz getcontinue
     pop ax         ;kill ds
     pop ax         ;kill bx
     pop ax         ;altes ax holen
     ret
getcontinue:
     pop ds
     pop bx
     jmp getloop

waitchar:
     sti
     mov byte ptr cs:waschar,0
waitcloop:
     cmp byte ptr cs:waschar,0
     jz waitcloop
     ret

iint proc far
     cmp al,1                 ;nur kanal 1 ist interessant
     ifnz <ret>
     mov byte ptr cs:waschar,1
     ret
iint endp

waschar db 0

print:
     push ds
     push cs
     pop ds
     call dsprint
     pop ds
     ret

dsprint:
     push cx
     push ax
     mov cl,byte ptr [bx]     ;laenge holen
     inc bx                   ;auf text schalten
     mov ch,0
     mov al,1                 ;auf terminal 1
     call cs:output
     pop ax
     pop cx
     ret

setup_fix_disk:
  if hdsystem
     mov di,si                ;si retten
     mov dl,4
eumel_partition_search_loop:
     test byte ptr es:[si],80h  ;aktivierte Partition
     jnz eu_found
     add si,10h
     dec dl
     jnz eumel_partition_search_loop
; keine EUMEL Partition, Sauerei
no_eu_part:
     mov bx,offset no_eumel_partition_text
     call print
     sti
     jmp $

eu_found:
     cmp byte ptr es:[si+4],'E' ;EUMEL partition
     jc no_eu_part
     mov dx,es:[si+8]    ;low word partition start holen
     mov bx,es:[si+10]   ;high word partition start holen
     add dx,68           ;50k fuer shard etc. frei lassen
     adc bl,0
     mov cx,-101         ;partition start einstellen
     mov al,0            ;fuer HG
     call control32
     mov cx,-100         ;dasselbe als groesse fuer Setup Kanal
     mov al,setup_channel
     call control32
     mov dx,es:[si+12]   ;low word partition size holen
     mov bx,es:[si+14]   ;high word partition size holen
     
    if at
     sub dx,68           ;platz fuer SHard
     sbb bl,0
     sub dx,[bb_anz]     ;platz fuer schlechte sectoren lassen
     sbb bl,0
    else
     sub dx,68+(2*68)    ;das, was wir fuers SHard lassen, abziehen
                         ;und das, was fuer schlechte spuren bleiben muss
     sbb bl,0
    endif

     mov cx,-100         ;size einstellen
     mov al,0            ;fuer hg
     call control32
; DOS partition suchen
     mov si,di           ;si wieder holen
     mov dl,4
dos_partition_search_loop:
     cmp byte ptr es:[si+4],1 ;DOS partition
     jz dos_found
     add si,10h
     dec dl
     jnz dos_partition_search_loop
     xor dx,dx
     mov bx,dx           ;DOS Partition existiert nicht
     jmp short dos_size
dos_found:
     mov dx,es:[si+8]    ;low word partition start holen
     mov bx,es:[si+10]   ;high word partition start holen
     mov cx,-101         ;partition start einstellen
     mov al,dos_channel  ;fuer DOS
     call control32
     mov dx,es:[si+12]   ;low word partition size holen
     mov bx,es:[si+14]   ;high word partition size holen
dos_size:
     mov cx,-100         ;size einstellen
     mov al,dos_channel  ;fuer DOS
     call control32
  endif
     ret

 if 0
     mov ax,0
     mov cx,5
     call cs:iocontrol           ;get size of harddisk
  if mit_msdos
     mov bx,17068
  else
     mov bx,100               ;50k freilassen
  endif
     sub cx,bx                ;von size abziehen
     cmp cx,0fd00h shr 1      ;bei mehr legt sich eumel auf den bauch
     ifnc <mov cx,0fcfeh shr 1> ;dann nur soviel, wie er kann
     mov dx,cx                ;in dx melden
     mov cx,-100              ;set size
     call control32
     ret
 endif

eutext:
     db 'EUMEL'

signon:
     db booterrtext-$-1
  if pcd
     db 1bh,5bh,'H',1bh,5bh,'2J'
     db 13,10,10 
     db 'Demo - SHard f',129,'r EUMEL auf Siemens PC-D, V 2.1'
     db 13,10
     db 'Copyright (C) 1985,86 Martin Sch',148,'nbeck, Spenge'
     db 13,10
   else
     if gensys
        db 13,10,10
        db 'Setup - SHard f',129,'r EUMEL'
        db ' auf IBM PC,AT,XT und Kompatiblen V 2.7'
        db 13,10
        db 'Copyright (C) 1985,86 Martin Sch',148,'nbeck, Spenge'
        db 13,10
     else
       if at
          db 13,10,10
          db 'SHard f',129,'r EUMEL auf IBM PC/AT, V 2.7'
          db 13,10
          db 'Copyright (C) 1985,86 Martin Sch',148,'nbeck, Spenge'
          db 13,10
       else
          db 13,10,10
          db 'ModSoft - SHard f',129,'r EUMEL'
          db ' auf IBM-PC und Kompatiblen, Version 2.7'
          db 13,10
          db 'Copyright (C) 1985,86 ModSoft, Martin Sch',148,'nbeck'
          db 13,10
       endif
     endif
  endif

booterrtext:
     db archtext-$-1
     db 'Fehler beim Laden des Systems: '
     db 7
archtext:
     db hgtext-$-1
     db 'EUMEL wird vom Archiv geladen'
     db 13,10
hgtext:
     db noeutext-$-1
     db 'EUMEL wird vom Hintergrund geladen'
     db 13,10
noeutext:
     db no_eumel_partition_text-$-1
     db 'Kein EUMEL - System gefunden'
     db 13,10
     db 'Bitte einlegen und Taste dr',129,'cken! '
no_eumel_partition_text:
     db endtext-$-1
     db 'Keine EUMEL Partition auf der Platte'
     db 13,10
     db 'Bitte benutzen Sie Ihre Setup-Floppy zum Anlegen'
endtext:

lastbootbyte: