DOC PREVIEW
Princeton COS 318 - Bootloader

This preview shows page 1-2-3-4-5-6 out of 18 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Administrative OverviewCOS 318 Project 1 BootloaderProblemBooting a Computer On Startup…Bootup DetailsSlide 6BootloaderEntering the BootloaderThe kernel might be bigSolutionLoading the kernelDesign Review print_char, print_stringDesign ReviewHow long will this take?AddressingRegistersAT&T SyntaxAssembly PitfallsAdministrative Overview6 ProjectsDesign Review: Monday before 6:30pmLab Friend Center 010 (“Fishbowl”)COS 318 Project 1BootloaderProblemWe will write an Operating SystemManages programs, resources, users, etc.How are programs loaded?The OS takes care of thisHow is the OS loaded?…Booting a ComputerOn Startup…The BIOS is loadedTypically doesn’t know anything about the OSMinimal functionalityThe BIOS loads & runs the first sector of a boot device.An OS cannot fit in just one sectorBootup DetailsStart at 0xFFFF0Self test & initializationSearch for a boot deviceHard diskFloppyFlash…Bootup Details1st sector loaded to 0x7c00Jump to 0x7c00512 bytes to load the kernelBootloaderBootloaderKernelDiskMemoryEntering the Bootloader%dl = Boot device numberLoad the kernel from this device%cs = Code segmentNO STACK! (%ss, %sp unset)%ds unset (set it to 0x07c0 before fetching from memory!)Other registers unsetThe kernel might be bigKernelSolutionMove the bootloaderKernelLoading the kernelLoad to address 0x0000:1000Set up the stack%ss = 0x9000, %sp=0xfffe%ds = 0Long Jump to 0x0000:1000Design Reviewprint_char, print_stringExample:_start:jmp past_datawelcome_msg: .asciz “OS Project 1\n\rLoading…”past_data: push welcome_msg call print_string jmp somewhere_elseDesign ReviewBootloaderHow to find the kernel on disk?Where to copy the kernel?How to copy the kernel?CreateimageHow do you find the code segments in ELF using header information?Give a formula for the disk/image address of segment i in the program header. Where do you use padding?How long will this take?BootloaderAbout 80 lines assemblySimple instructions (int, mov, cld)CreateimageAbout 200 lines of CHardest part: navigating ELF structsDebugging will take the most time.AddressingReal Mode1 MBFormat: 0x0000:0000Physical address = (segment << 4)+offsetEx: 0x07c0:0000 = 0x0000:7c00Protected Mode4 GB (32-bit)Format: 0x0000:00000000 (32-bit)Virtual Addressing (user mode)Physical address = a bit more complicated…Registers31 16 8 0E_X EAX, EBX, ECX, EDX_X AX, BX, CX, DX_H _L AH, AL, BH, BL, …Segment Registers16CS, DS, SS, ES, FS, GSIndex Registers32BP, SI, DI, SPStatus & Control32EFLAGS, EIPGeneral RegistersAT&T SyntaxRegisters: %ax, %ah, %eax ,…Definitions.equ BOOT_SEGMENT, 0x07c0Constants: $0x0100, $4Labels_start:print_string:Memory accessmovw %ax, (0x40)movb %dl, (a_label)movw %es:(%ax), %dxComments/* multiline */# to the end of the lineDirectives.equ, .byte, .word, .ascii, .ascizAssembly Pitfalls.equ BOOT_SEGMENT, 0x07c0movw BOOT_SEGMENT,


View Full Document

Princeton COS 318 - Bootloader

Documents in this Course
Overview

Overview

25 pages

Deadlocks

Deadlocks

25 pages

lectute 2

lectute 2

28 pages

Lecturel

Lecturel

24 pages

Real mode

Real mode

49 pages

Lecture 2

Lecture 2

54 pages

lecture 5

lecture 5

27 pages

Load more
Download Bootloader
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Bootloader and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Bootloader 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?