chinazi-dictatorship

Ciro Santilli 5c2e547b52 bios_disk_load works 10 years ago
grub 5c2e547b52 bios_disk_load works 10 years ago
hajji 48614b45fa Document hajji working 10 years ago
multiboot 01a5e64efa Segment registers 10 years ago
nasm cba0757990 Bochs works, failed PIT and beep attempts 10 years ago
no-linker-script a8d90ac777 Make osdev example more uniform with the hello world 10 years ago
printf a8d90ac777 Make osdev example more uniform with the hello world 10 years ago
uefi 173111e0d0 rtc 10 years ago
.gitignore 7dc6e56e16 big-img, chainload self 10 years ago
Makefile 5c2e547b52 bios_disk_load works 10 years ago
README.md 5c2e547b52 bios_disk_load works 10 years ago
TODO.md 5c2e547b52 bios_disk_load works 10 years ago
apm.md a44b659299 bios keyboard 10 years ago
apm_shutdown.S 7cff2a3fc9 Factor out precefaces and postfixes, apm_shutdown2 10 years ago
apm_shutdown2.S 7cff2a3fc9 Factor out precefaces and postfixes, apm_shutdown2 10 years ago
bibliography.md 5c2e547b52 bios_disk_load works 10 years ago
bios.md 01a5e64efa Segment registers 10 years ago
bios_background.S 01a5e64efa Segment registers 10 years ago
bios_carriage_return.S 25235ad9ba Keyboard input, hex printer 10 years ago
bios_clear_screen.S 01a5e64efa Segment registers 10 years ago
bios_color.S 01a5e64efa Segment registers 10 years ago
bios_cursor_position.S 01a5e64efa Segment registers 10 years ago
bios_disk_load.S 5c2e547b52 bios_disk_load works 10 years ago
bios_hello_world.S 4fbe9f2246 Set DS to make work on hardware, more failed UEFI attempts 10 years ago
bios_keyboard.S a44b659299 bios keyboard 10 years ago
bios_keyboard_loop.S 6606a2647d reboot 10 years ago
bios_newline.S 25235ad9ba Keyboard input, hex printer 10 years ago
bios_one_char.S 7dc6e56e16 big-img, chainload self 10 years ago
bios_pixel.S 1f8c00ec8f BIOS 13h video mode draw pixels 10 years ago
bios_pixel_line.S 1f8c00ec8f BIOS 13h video mode draw pixels 10 years ago
bios_scroll.S 25235ad9ba Keyboard input, hex printer 10 years ago
common.h 5c2e547b52 bios_disk_load works 10 years ago
formats.md d217b180be Split up README 10 years ago
in.md 5c2e547b52 bios_disk_load works 10 years ago
in_beep.S 5c2e547b52 bios_disk_load works 10 years ago
in_beep_illinois.S 5c2e547b52 bios_disk_load works 10 years ago
in_keyboard.S 173111e0d0 rtc 10 years ago
in_mouse.S 5c2e547b52 bios_disk_load works 10 years ago
in_pit.S 5c2e547b52 bios_disk_load works 10 years ago
in_rtc.S cba0757990 Bochs works, failed PIT and beep attempts 10 years ago
infinite_loop.S bf4556b972 Infinite loop, rm .elf output 10 years ago
interrupt.S 5c2e547b52 bios_disk_load works 10 years ago
interrupt_keyboard.S 25235ad9ba Keyboard input, hex printer 10 years ago
interrupt_loop.S 5c2e547b52 bios_disk_load works 10 years ago
interrupt_zero_divide.S 173111e0d0 rtc 10 years ago
io.md a44b659299 bios keyboard 10 years ago
linker.ld 5c2e547b52 bios_disk_load works 10 years ago
mbr.md 25235ad9ba Keyboard input, hex printer 10 years ago
min.S 349c9bd510 Use xor ax instead of mov 0 10 years ago
modes-of-operation.md 5c2e547b52 bios_disk_load works 10 years ago
not-testable-in-userland.md 01a5e64efa Segment registers 10 years ago
protected_mode.S 5c2e547b52 bios_disk_load works 10 years ago
reboot.S 6606a2647d reboot 10 years ago
segment_registers_real_mode.S 5c2e547b52 bios_disk_load works 10 years ago
ss.S 6add24a0ee Init SS and SP by default 10 years ago
template.S 173111e0d0 rtc 10 years ago

README.md

x86 Bare Metal Examples

Hello world programs that run without an operating system.

  1. Examples
    1. printf
    2. min
    3. No ld script
    4. BIOS
      1. one char
      2. hello world
        1. NASM
      3. newline
      4. carriage return
      5. cursor position
      6. color
      7. background
      8. scroll
        1. clear screen
      9. pixel
        1. pixel line
      10. keyboard
        1. keyboard loop
      11. disk load
    5. reboot
    6. Not testable in userland
      1. Segment registers real mode
        1. SS (TODO)
      2. Interrupt
        1. Interrupt zero divide
        2. Interrupt loop
      3. in
        1. in keyboard
        2. in RTC
        3. in PIT (TODO)
        4. in beep
        5. in beep_illinois
        6. in mouse (TODO)
      4. Protected mode
    7. APM
      1. APM shutdown
      2. APM shutdown 2
    8. Multiboot
    9. GRUB
    10. TODO not working
      1. UEFI
    11. Misc
      1. hajji
  2. Theory
    1. Modes of operation
    2. Formats
      1. MBR
    3. IO
      1. BIOS
      2. APM
    4. Bibliography
  3. TODO

Getting started

sudo apt-get install bochs bochs-sdl build-essential gnu-efi qemu nasm xorriso

Emulator

Run the default program on QEMU:

make run

Run a given program:

make run RUN=min
make run RUN=bios_one_char

Use Bochs instead of QEMU:

make bochs RUN=min

Tested on Ubuntu 14.04 AMD64.

Real hardware

Insert an USB, determine its device (/dev/sdX) with:

sudo lsblk
sudo fdisk -l

Pick the .img file that you wan to run and:

sudo dd if=bios_hello_world.img of=/dev/sdX

Then:

  • insert the USB in a computer
  • during boot, hit some special hardware dependant key, usually F12, Esc
  • choose to boot from the USB

When you are done, just hit the power button to shutdown.

Tested on: ThinkPad T400.

Big image

Create a big.img that contains all examples that can be booted from GRUB:

make big-img

Now if you do:

sudo dd if=big.img of=/dev/sdX

you can test several examples with a single USB burn, which is much faster.

You will also want to change the boot order to put the USB first from the F12 BIOS menu. This way you don't have to hit F12 like a madman every time.