1 / 18

Administrative Overview

Administrative Overview. 6 Projects Design Review: Monday before 6:30pm Lab Friend Center 010 (“Fishbowl”). COS 318 Project 1 Bootloader. Problem. We will write an Operating System Manages programs, resources, users, etc. How are programs loaded? The OS takes care of this

lynda
Download Presentation

Administrative Overview

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Administrative Overview • 6 Projects • Design Review: Monday before 6:30pm • Lab Friend Center 010 (“Fishbowl”)

  2. COS 318 Project 1Bootloader

  3. Problem • 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? …

  4. 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 sector

  5. Bootup Details • Start at 0xFFFF0 • Self test & initialization • Search for a boot device • Hard disk • Floppy • Flash • …

  6. Bootup Details • 1st sector loaded to 0x7c00 • Jump to 0x7c00 • 512 bytes to load the kernel

  7. Bootloader Kernel Bootloader Memory Disk

  8. Entering 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 unset

  9. The kernel might be big Kernel

  10. Solution • Move the bootloader Kernel

  11. Loading the kernel • Load to address 0x0000:1000 • Set up the stack • %ss = 0x9000, %sp=0xfffe • %ds = 0 • Long Jump to 0x0000:1000

  12. Design Reviewprint_char, print_string Example: _start: jmp past_data welcome_msg: .asciz “OS Project 1\n\rLoading…” past_data: push welcome_msg call print_string jmp somewhere_else

  13. Design 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?

  14. 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 structs Debugging will take the most time.

  15. 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…

  16. Registers General Registers

  17. AT&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, .asciz

  18. Assembly Pitfalls .equ BOOT_SEGMENT, 0x07c0 movw BOOT_SEGMENT, %ds

More Related