BCOS 80x86 SourceProject Map
80x86 OS Installation Boot CD Image
File: 80x86/bootcd/0index.asm
 

Copyright © Brendan Trotter 2008

This material is provided by Brendan Trotter as a service to interested parties on an "as-is" basis, for informational purposes only. Brendan Trotter assumes no responsibility for any errors or omissions. Brendan Trotter does not make, and expressly disclaims any, representations or warranties, express or implied, regarding this web page and the host web site, including, without limitation, any implied warranties of merchantability or fitness for a particular purpose.

Under no circumstances shall Brendan Trotter, or any associated contributors, volunteers or representatives be liable for any damages, whether direct, indirect, special or consequential damages for lost revenues, lost profits, or otherwise, arising from or in connection with this web page, the host web site, or the materials contained herein.

All materials contained in these files are protected by copyright laws, and may not be reproduced, republished, distributed, transmitted, displayed, broadcast or otherwise exploited in any manner without the express prior written permission of Brendan Trotter. You may make one copy of this web page for your personal and non-commercial use only, without altering or removing this copyright notice or any other notice.




Overview

This source code creates a default boot CD image (mainly intended for installing the operating system).


Notes

"d-characters" are ASCII characters with values 0x30 to 0x39 (numerical digits 0 to 9), 0x41 to 0x5A (upper case letters from A to Z), and 0x5F (underscore). This means no space characters(?).

"a-characters" are ASCII characters with values 0x20 to 0x22 (space, exclamation mark, double quote), 0x25 to 0x3F (characters "%&'()*+,-./0123456789:;<=>?", 0x41 to 0x5A (upper case letters from A to Z), and 0x5F (underscore).


Macros

 27: ;Misc. macros
 28: 
 29: 
%ifdef __UTC_DATE_NUM__
 30:  %ifdef __UTC_TIME_NUM__
 31:   %define USE_UTC
 32:  %endif
 33:  %endif
 34: 
 35: 
 36: 
%ifdef USE_UTC
 37:  %defstr CURRENT_DATE_STRING __UTC_DATE_NUM__
 38:  %defstr CURRENT_TIME_STRING __UTC_TIME_NUM__
 39: %else
 40:  %defstr CURRENT_DATE_STRING __DATE_NUM__
 41:  %defstr CURRENT_TIME_STRING __TIME_NUM__
 42: %endif
 43: 
 44: 
 45: 
%macro NULL_TIME 0
 46:       times 16 db '0'
 47:       db 0
 48: %endmacro
 49: 
 50: 
 51: 
%macro CURRENT_TIME 0
 52:       db CURRENT_DATE_STRING
 53:       db CURRENT_TIME_STRING
 54:       db '00'                 ;Hundreths of a second
 55:       db 3                    ;Offset from "Greenwich Mean Time"
 56: %endmacro
 57: 
 58: 
 59: 
%macro BIG_ENDIAN_WORD 1
 60:       db (%1) >> 8                                                ;Big endian word (first byte/high byte)
 61:       db (%1) & 0xFF                                              ;Big endian word (second byte/low byte)
 62: %endmacro
 63: 
 64: 
 65: 
%macro BIG_ENDIAN_DWORD 1
 66:       db ((%1) >> 24) & 0xFF                                      ;Big endian dword (first byte/high byte)
 67:       db ((%1) >> 16) & 0xFF                                      ;Big endian dword (second byte)
 68:       db ((%1) >> 8) & 0xFF                                       ;Big endian dword (third byte)
 69:       db (%1) & 0xFF                                              ;Big endian dword (fourth byte/low byte)
 70: %endmacro
 71: 
 72: 
 73: 
%macro MIXED_ENDIAN_WORD 1
 74:       dw %1                                                       ;Little endian word
 75:       db (%1) >> 8                                                ;Big endian word (first byte/high byte)
 76:       db (%1) & 0xFF                                              ;Big endian word (second byte/low byte)
 77: %endmacro
 78: 
 79: 
 80: 
%macro MIXED_ENDIAN_DWORD 1
 81:       dd %1                                                       ;Little endian dword
 82:       db ((%1) >> 24) & 0xFF                                      ;Big endian dword (first byte/high byte)
 83:       db ((%1) >> 16) & 0xFF                                      ;Big endian dword (second byte)
 84:       db ((%1) >> 8) & 0xFF                                       ;Big endian dword (third byte)
 85:       db (%1) & 0xFF                                              ;Big endian dword (fourth byte/low byte)
 86: %endmacro
 87: 
 88: 
 89: 
 90: 
;Path table macros
 91: 
 92: 
%macro PATH_TABLE 1
 93:  %ifidni %1, L
 94:   %push PATH_L
 95:  %else
 96:   %push PATH_M
 97:  %endif
 98: %endmacro
 99: 
100: 
101: 
%macro PATH_ENTRY 3+
102:       db %%l2 - %%l1                                              ;Length of directory identifier
103:       db 0                                                        ;Length of extended data
104:  %ifctx PATH_L
105:       dd (%1 - IMAGE_START) / 2048                                ;Starting sector
106:       dw %2                                                       ;Parent directory number
107:  %else
108:       BIG_ENDIAN_DWORD (%1 - IMAGE_START) / 2048                  ;Starting sector
109:       BIG_ENDIAN_WORD %2                                          ;Parent directory number
110:  %endif
111: %%l1:
112:       db %3                                                       ;Directory identifier
113: %%l2:
114:       times (%%l2 - %%l1) & 1 db 0                                ;Padding byte (only if directory identifer length is odd)
115: %endmacro
116: 
117: 
118: 
%macro PATH_TABLE_END 0
119:  %ifctx PATH_L
120:   %pop
121:  %endif
122:  %ifctx PATH_M
123:   %pop
124:  %endif
125: .end:
126:       align 2048, db 0
127: %endmacro
128: 
129: 
130: 
;Directory entry macros
131: 
132: 
%macro DIR_ENTRY 3+
133: %%l1:
134:       db %%l4 - %%l1                                              ;Length of directory entry
135:       db 0                                                        ;Length of extended data
136:       MIXED_ENDIAN_DWORD (%1 - IMAGE_START) / 2048                ;Starting sector
137:       MIXED_ENDIAN_DWORD %{1}.end - %1                            ;Number of bytes of data
138:  %ifdef USE_UTC
139:       db (__UTC_DATE_NUM__ / 10000) - 1900                        ;Years since 1900
140:       db (__UTC_DATE_NUM__ / 100) % 100                           ;Month
141:       db __UTC_DATE_NUM__  % 100                                  ;Day of month
142:       db (__UTC_TIME_NUM__ / 10000) - 1900                        ;Hour
143:       db (__UTC_TIME_NUM__ / 100) % 100                           ;Minute
144:       db __UTC_TIME_NUM__  % 100                                  ;Second
145:  %else
146:       db (__DATE_NUM__ / 10000) - 1900                            ;Years since 1900
147:       db (__DATE_NUM__ / 100) % 100                               ;Month
148:       db __DATE_NUM__  % 100                                      ;Day of month
149:       db (__DATE_NUM__ / 10000) - 1900                            ;Hour
150:       db (__DATE_NUM__ / 100) % 100                               ;Minute
151:       db __DATE_NUM__  % 100                                      ;Second
152:  %endif
153:       db 3                                                        ;Offset from "Greenwich Mean Time"
154:       db %2                                                       ;File flags
155:       db 0                                                        ;File unit size (zero if file doesn't used interleaved mode)
156:       db 0                                                        ;Interleave gap size (zero if file doesn't used interleaved mode)
157:       MIXED_ENDIAN_WORD 1                                         ;Volume sequence number
158:       db %%l3 - %%l2                                              ;File identifier length
159: %%l2:
160:       db %3                                                       ;File identifier
161: %%l3:
162:       times ~(%%l3 - %%l2) & 1 db 0                               ;Padding byte (only if file identifer length is even)
163: %%l4:
164: %endmacro
165: 
166: 
%define F_HIDDEN        0x01
167: %define F_DIRECTORY     0x02
168: %define SELF            0x00
169: %define PARENT          0x01
170: 
171: 
172: 
%macro DIR_START 2
173:       DIR_ENTRY %1F_DIRECTORYSELF
174:       DIR_ENTRY %2F_DIRECTORYPARENT
175: %endmacro
176: 
177: 
%macro DIR_END 0
178:       align 2048, db 0
179: .end:
180: %endmacro
181: 
182: 
183: 
;File macros
184: 
185: 
%macro ADD_FILE_END 0
186: .end:
187:       align 2048, db 0
188: %endmacro


Assembler Setup

194:       ORG 0
195: IMAGE_START:


Data


(Sectors 0 to 15) System Area

204: ;This is 16 sectors (sector 0 to sector 15) that are reserved for system use.
205: 
206: 
      times 2048*16 db 0


(Sector 16) Primary Volume Descriptor

212:       db 1                                                        ;Volume descriptor type
213:       db "CD001"                                                  ;Standard identifier
214:       db 1                                                        ;Volume descriptor version
215:       db 0                                                        ;unused
216:       db "BCOS                            "                       ;System identifier ("a-characters")
217:       db "VOLUME_IDENTIFIER_0000000000001A"                       ;Volume identifier ("d-characters")
218:       db 0,0,0,0,0,0,0,0                                          ;unused
219:       MIXED_ENDIAN_DWORD (IMAGE_END - IMAGE_START + 2047)/2048    ;Volume space size (in logical blocks)
220:       times 32 db 0                                               ;unused
221:       MIXED_ENDIAN_WORD 1                                         ;Volume set size
222:       MIXED_ENDIAN_WORD 1                                         ;Volume sequence number (first volume of a one volume set)
223:       MIXED_ENDIAN_WORD 2048                                      ;Logical block size in bytes
224:       MIXED_ENDIAN_DWORD PATH_TABLE_L.end - PATH_TABLE_L          ;Path table size
225:       dd (PATH_TABLE_L - IMAGE_START) / 2048                      ;Location of Type L Path Table
226:       dd 0                                                        ;Location of optional Type L Path Table
227:       BIG_ENDIAN_DWORD (PATH_TABLE_M - IMAGE_START) / 2048        ;Location of Type M Path Table
228:       dd 0                                                        ;Location of optional Type M Path Table
229:       DIR_ENTRY ROOT_DIRF_DIRECTORYSELF                       ;Directory record for root directory
230:       db "________________________________"                       ;Volume set identifier, part 1 ("d-characters")
231:       db "________________________________"                       ;Volume set identifier, part 2 ("d-characters")
232:       db "________________________________"                       ;Volume set identifier, part 3 ("d-characters")
233:       db "________________________________"                       ;Volume set identifier, part 4 ("d-characters")
234:       db "BRENDAN TROTTER                 "                       ;Publisher identifier, part 1 ("a-characters")
235:       db "                                "                       ;Publisher identifier, part 2 ("a-characters")
236:       db "                                "                       ;Publisher identifier, part 3 ("a-characters")
237:       db "                                "                       ;Publisher identifier, part 4 ("a-characters")
238:       db "BRENDAN TROTTER                 "                       ;Data preparer identifier, part 1 ("a-characters")
239:       db "                                "                       ;Data preparer identifier, part 2 ("a-characters")
240:       db "                                "                       ;Data preparer identifier, part 3 ("a-characters")
241:       db "                                "                       ;Data preparer identifier, part 4 ("a-characters")
242:       db "CUSTOM ASSEMBLY LANGUAGE        "                       ;Application identifier, part 1 ("a-characters")
243:       db "                                "                       ;Application identifier, part 2 ("a-characters")
244:       db "                                "                       ;Application identifier, part 3 ("a-characters")
245:       db "                                "                       ;Application identifier, part 4 ("a-characters")
246:       times 37 db ' '                                             ;Copyright file identifier (none)
247:       times 37 db ' '                                             ;Abstract file identifier (none)
248:       times 37 db ' '                                             ;Bibliographic file identifier (none)
249:       CURRENT_TIME                                                ;Volume creation date and time
250:       CURRENT_TIME                                                ;Volume modification date and time
251:       NULL_TIME                                                   ;Volume expiration date and time
252:       NULL_TIME                                                   ;Volume effective date and time
253:       db 1                                                        ;File structure version
254:       db 0                                                        ;Reserved/unused
255:       times 512 db 0                                              ;Application use
256:       times 653 db 0                                              ;Reserved/unused


(Sector 17) Boot Record Volume Descriptor

262: ;WARNING: The El Torito specification directly contradicts the ECMA-119 Standard
263: ;         for the format of the "a-character" fields. This data reluctantly
264: ;         follows the El Torito specification's use of zeros in "a-character"
265: ;         fields.
266: 
267: 
      db 0                                                        ;Volume descriptor type
268:       db "CD001"                                                  ;Standard identifier
269:       db 1                                                        ;Volume descriptor version
270:       db "EL TORITO SPECIFICATION",0,0,0,0,0,0,0,0,0              ;Boot system identifier ("a-characters", sort of)
271:       db "                                "                       ;Boot identifier ("a-characters")
272:       dd (BOOT_CATALOGUE - IMAGE_START) / 2048                    ;Absolute pointer to first sector of boot catalogue (this is a sector number)
273:       times 1973 db 0                                             ;Unused


(Sector 18) Set Terminator Volume Descriptor

279:       db 255                                                      ;Volume descriptor type
280:       db "CD001"                                                  ;Standard identifier
281:       db 1                                                        ;Volume descriptor version
282:       times 2041 db 0                                             ;Reserved/unused


(Sector 19) Boot Catalogue

288: ;WARNING: The El Torito specification doesn't say which characters are allowed
289: ;         in character strings, and the only thing it does say is "All character
290: ;         strings are padded to their full length with hex zeros.". I've assumed
291: ;         that all characters are "a-characters". I'm still trying to figure out the
292: ;         difference between "hex zeros" and other types of zeros, and have assumed
293: ;         they won't mind if I use "decimal zeros" instead... :-)
294: 
295: 
BOOT_CATALOGUE:
296: 
297: 
;Validation entry
298: 
299: 
      db 1                                                        ;Header ID
300:       db 0                                                        ;Platform ID (80x86)
301:       dw 0                                                        ;Reserved/unused
302:       db "BRENDAN TROTTER",0,0,0,0,0,0,0,0,0                      ;ID string
303:       dw -(0x0001 + "BR" + "EN" + "DA" + "N " + "TR" + "OT" + "TE" + "R" + 0xAA55)              ;Checksum
304:       dw 0xAA55                                                   ;Key bytes
305: 
306: 
;Initial/Default Entry
307: 
308: 
      db 0x88                                                     ;Boot indicator
309:       db 0x00                                                     ;Media type (0x00 = "no emulation")
310:       dw 0x07C0                                                   ;Load segment
311:       db 0                                                        ;Partition type (assumed to be unused for "no emulation")
312:       db 0                                                        ;Unused, must be 0
313:       dw (BOOT_LOADER.end - BOOT_LOADER + 511) / 512              ;Sector count (virtual 512-byte sectors)
314:       dd (BOOT_LOADER - IMAGE_START) / 2048                       ;First sector number for boot loader
315:       times 20 db 0                                               ;Unused, must be zero
316: 
317: 
;Padding
318: 
319: 
      times 62*32 db 0                                            ;62 unused entries


(Sector 20 to Sector ?) Boot Loader

325: BOOT_LOADER:
326:       incbin "../sys_src/bin/bootcd.bin"
327:       ADD_FILE_END


Type L Path Table

333: PATH_TABLE_L:
334:       PATH_TABLE L
335:       PATH_ENTRY ROOT_DIR10
336:       PATH_ENTRY BOOT_DIR1"BOOT"
337:       PATH_ENTRY FLOPPY_DIR1"FLOPPY"
338:       PATH_TABLE_END


Type M Path Table

344: PATH_TABLE_M:
345:       PATH_TABLE M
346:       PATH_ENTRY ROOT_DIR10
347:       PATH_ENTRY BOOT_DIR1"BOOT"
348:       PATH_ENTRY FLOPPY_DIR1"FLOPPY"
349:       PATH_TABLE_END


Root Directory

355: ROOT_DIR:
356:       DIR_START ROOT_DIRROOT_DIR
357:       DIR_ENTRY BOOT_DIRF_DIRECTORY"BOOT"
358:       DIR_ENTRY FLOPPY_DIRF_DIRECTORY"FLOPPY"
359:       DIR_END


"BOOT" Directory

366: BOOT_DIR:
367:       DIR_START BOOT_DIRROOT_DIR
368:       DIR_ENTRY BOOT_IMAGE_FILE0"BOOT.BIM;1"
369:       DIR_ENTRY BOOT_SCRIPT_FILE0"BOOT.BSC;1"
370:       DIR_ENTRY BOOT_FRL_FILE0"BOOT.FRL;1"
371:       DIR_ENTRY COMMONPC_FILE0"COMMONPC.BIN;1"
372:       DIR_END
373: 
374: 
BOOT_IMAGE_FILE:
375:       incbin "../bin/install.sbi"
376:       ADD_FILE_END
377: 
378: 
BOOT_SCRIPT_FILE:
379:       incbin "../bin/default.bsc"
380:       ADD_FILE_END
381: 
382: 
BOOT_FRL_FILE:
383:       incbin "../bin/default.frl"
384:       ADD_FILE_END
385: 
386: 
COMMONPC_FILE:
387:       incbin "../sys_src/bin/commonpc.bin"
388:       ADD_FILE_END


"FLOPPY" Directory

394: FLOPPY_DIR:
395:       DIR_START FLOPPY_DIRROOT_DIR
396:       DIR_ENTRY FLOPPY1200_FILE0"FLOP1200.IMG;1"
397:       DIR_ENTRY FLOPPY1440_FILE0"FLOP1440.IMG;1"
398:       DIR_ENTRY FLOPPY2880_FILE0"FLOP2880.IMG;1"
399:       DIR_END
400: 
401: 
FLOPPY1200_FILE:
402:       incbin "../../www/ftp/flop1200.img"
403:       ADD_FILE_END
404: 
405: 
FLOPPY1440_FILE:
406:       incbin "../../www/ftp/flop1440.img"
407:       ADD_FILE_END
408: 
409: 
FLOPPY2880_FILE:
410:       incbin "../../www/ftp/flop2880.img"
411:       ADD_FILE_END


The End

417:       align 32 * 1024, db 0
418: IMAGE_END:


Generated on Thu Sep 17 04:38:58 2009