This commit is contained in:
Ciro Santilli
2015-09-21 09:43:03 +02:00
parent 6add24a0ee
commit 6606a2647d
6 changed files with 75 additions and 2 deletions

View File

@@ -20,6 +20,8 @@ Hello world programs that run without an operating system.
1. [pixel](bios_pixel.S)
1. [pixel line](bios_pixel_line.S)
1. [keyboard](bios_keyboard.S)
1. [keyboard loop](bios_keyboard_loop.S)
1. [reboot](reboot.S)
1. [Not testable in userland](not-testable-in-userland.md)
1. [Segment registers real mode](segment_registers_real_mode.S)
1 [SS (TODO)](ss.S)

View File

@@ -9,8 +9,12 @@
- wbinvd
- outb inb
- lgdtl, paging http://stackoverflow.com/questions/21128311/the-physical-address-of-global-descriptor-table
- lidtl, interrupts
- lgdtl, paging http://stackoverflow.com/questions/21128311/the-physical-address-of-global-descriptor-table http://stackoverflow.com/questions/7415515/problem-accessing-control-registers-cr0-cr2-cr3
- lidtl, interrupts, IDTR
- https://en.wikipedia.org/wiki/Double_fault
- https://en.wikipedia.org/wiki/Triple_fault
- http://stackoverflow.com/questions/1817577/what-does-int-0x80-mean-in-assembly-code
- http://stackoverflow.com/questions/12464329/is-it-possible-to-make-a-custom-interrupt-in-assembly
- WRMSR https://en.wikipedia.org/wiki/Model-specific_register http://x86.renejeschke.de/html/file_module_x86_id_326.html
- Segment registers on protected mode. Then try to answer all of:
@@ -60,6 +64,7 @@
- play with hardware
- keyboard through interrupt (high level int 16 bios done)
- keyboard protected mode: http://stackoverflow.com/questions/219120/x86-assembly-protected-mode-keyboard-access
- set a pixel on screen in protected mode http://stackoverflow.com/questions/14419088/assembly-draw-a-pixel-on-the-screen-in-protected-mode
- USB
- networking

14
bios_keyboard_loop.S Normal file
View File

@@ -0,0 +1,14 @@
/*
This just begs for a non-minimal for-fun infinite loop version.
Do try Ctrl-key combinations.
*/
#include "common.h"
BEGIN
start:
mov $0x00, %ah
int $0x16
PUTC(%al)
jmp start
END

24
interrupt.S Normal file
View File

@@ -0,0 +1,24 @@
/*
Minimal interrupt example.
Upon division by zero, the interrupt handler is run,
and it prints the character 'A' to screen.
TODO: is STI not needed because this interrupt is not maskable?
TODO: use IDTR. Is initial value guaranteed?
*/
#include "common.h"
BEGIN
CLEAR
movw $handler, 0x00
movw $0x00, 0x02
mov $0x00, %ax
div %ax
jmp fail
handler:
PUTC($0x61)
fail:
hlt
END

16
interrupt_keyboard.S Normal file
View File

@@ -0,0 +1,16 @@
/*
TODO get working
*/
#include "common.h"
BEGIN
CLEAR
movw $handler, 0x04
movw $0x00, 0x06
sti
loop:
jmp loop
handler:
PUTC($0x61)
jmp loop
END

12
reboot.S Normal file
View File

@@ -0,0 +1,12 @@
/*
http://stackoverflow.com/questions/32682152/how-to-reboot-in-x86-assembly-from-16-bit-real-mode
Infinite reboot loop on emulator!
TODO why does it work?
*/
#include "common.h"
BEGIN
ljmpw $0xF000, $0XFFF0
END