BCOS 80x86 Stage 1 SourceProject Map
80x86 PC BIOS GRUB Boot Loader
File: 80x86/sys_src/p1/pc_bios/bootgrub/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 index file determines the layout of all other source files in memory. The final binary is used to boot the OS from GRUB (or any other multi-boot compliant boot manager).

Like all boot loaders designed for the PC BIOS, this boot loader must comply with the Common PC BIOS Module Transition State Specification.


Start Of Code


Included System Files

The following line/s include standard "include" files into the binary.

24: ;Standard include files
25: 
26: 
%include "asm.inc"
27: %include "kernel/log.inc"
28: %include "kernel/a20.inc"
29: %include "kernel/pasm.inc"
30: %include "ff/header.inc"
31: %include "ff/frl.inc"
32: 
33: 
;GRUB boot loader include files
34: 
35: 
%include "options.inc"


Assembler Setup

Here we just tell the assembler what address the code starts at, what mode the CPU is expected to be operating in and which instructions to accept.

Note: This code starts as "80386 compatible", then checks if the CPU meets the operating system's minimum requirements. After this check we tell the assembler to allow the full "80486" instruction set.

47:       ORG 0x00000010
48: 
49: 
      BITS 32
50:       CPU 386
51: 
52: 
BOOTLOADER_START:
53:       section .bss
54: BSS_START:
55:       section .text


Multiboot Header

61: MULTIBOOT_HEADER:
62:       dd 0x1BADB002                                   ;Magic number
63:       dd (1 << 16)                                    ;Flags
64:       dd -(0x1BADB002 + (1 << 16))                    ;Checksum
65: 
66: 
      dd MULTIBOOT_HEADER - 0x00000010 + 0x00100000   ;Header address
67:       dd $$ - 0x00000010 + 0x00100000                 ;Load address
68:       dd BOOTLOADER_END - 0x00000010 + 0x00100000     ;Load end address
69:       dd BSS_END - 0x00000010 + 0x00100000            ;BSS end address
70:       dd START - 0x00000010 + 0x00100000              ;Entry address


Source Code - Part 1

This code is run in protected mode, before switching back to real mode.

78: %include "part1/init.asm"
79: %include "part1/data.asm"
80: 
81: 
      BITS 16


Source Code - Part 2

This code is runs in real/unreal mode

 89: %include "part2/data.asm"
 90: %include "part2/init.asm"
 91: %include "part2/abort.asm"
 92: %include "part2/cpu.asm"
 93: 
 94: 
      cpu 486
 95: 
 96: 
%include "part2/move.asm"
 97: %include "part2/video/init.asm"
 98: %include "part2/video/print.asm"
 99: %include "part2/trusted/init.asm"
100: %include "part2/trusted/addarea.asm"
101: %include "part2/trusted/show.asm"
102: %include "part2/log/init.asm"
103: %include "part2/log/addchar.asm"
104: %include "part2/log/adddec.asm"
105: %include "part2/log/addhex.asm"
106: %include "part2/log/addstrng.asm"
107: %include "part2/pasm/init.asm"
108: %include "part2/pasm/addentry.asm"
109: %include "part2/pasm/probe.asm"
110: %include "part2/pasm/cmos.asm"
111: %include "part2/pasm/88.asm"
112: %include "part2/pasm/da88.asm"
113: %include "part2/pasm/8a.asm"
114: %include "part2/pasm/c7.asm"
115: %include "part2/pasm/e801.asm"
116: ;%include "part2/pasm/e881.asm"           ;Disabled due to buggy BIOSs (see note in "part3/pasm/init.asm")
117: %include "part2/pasm/e820.asm"
118: %include "part2/pasm/e820acpi.asm"
119: %include "part2/pasm/showpasm.asm"
120: %include "part2/pasm/findtop.asm"
121: %include "part2/pasm/foreach.asm"
122: %include "part2/nff/crc.asm"
123: %include "part2/frl/init.asm"
124: %include "part2/frl/check.asm"
125: %include "part2/frl/bitmap.asm"
126: %include "part2/frl/chcktrust.asm"
127: %include "part2/frl/clean.asm"
128: %include "part2/mem/init.asm"
129: %include "part2/mem/alloc.asm"
130: %include "part2/mem/free.asm"
131: %include "part2/mem/test.asm"
132: %include "part2/mem/show.asm"
133: %include "part2/commonpc/init.asm"
134: %include "part2/commonpc/start.asm"
135: %include "part2/bcat/init.asm"
136: %include "part2/bcat/addentry.asm"
137: %include "part2/bcat/finalize.asm"


The End

Here we define a few labels that are used later.

145:       align 4096
146: BOOTLOADER_END:
147:       section .bss
148:       alignb 4
149: 
150: 
      resb 1024
151:       alignb 4096
152: STACK_TOP:
153: BSS_END:


Generated on Sun Aug 16 02:07:23 2009