docs: documente ISA/AT buses I/O Port map
This commit is contained in:
parent
a9fec6e18c
commit
08a7d5c975
|
@ -41,48 +41,58 @@ Timestamp: Updated yyyy/mm/dd
|
||||||
File: Introduction (docs/intro.txt)
|
File: Introduction (docs/intro.txt)
|
||||||
Link: Source Code (https://github.com/d0p1s4m4/StupidOS)
|
Link: Source Code (https://github.com/d0p1s4m4/StupidOS)
|
||||||
File: Coding Style (docs/coding-style.txt)
|
File: Coding Style (docs/coding-style.txt)
|
||||||
|
File: Building (building.txt)
|
||||||
File: FAQ (docs/faq.txt)
|
File: FAQ (docs/faq.txt)
|
||||||
|
|
||||||
Group: Kernel {
|
Group: Kernel {
|
||||||
|
|
||||||
Group: Boot {
|
File: Introduction (kernel/intro.txt)
|
||||||
|
|
||||||
|
Group: boot {
|
||||||
|
|
||||||
File: feat.s (kernel/boot/feat.s)
|
|
||||||
File: head.s (kernel/boot/head.s)
|
File: head.s (kernel/boot/head.s)
|
||||||
} # Group: Boot
|
} # Group: boot
|
||||||
|
|
||||||
|
File: kernel.s (kernel/kernel.s)
|
||||||
File: gdt.s (kernel/gdt.s)
|
File: gdt.s (kernel/gdt.s)
|
||||||
File: idt.s (kernel/idt.s)
|
File: idt.s (kernel/idt.s)
|
||||||
File: pic.s (kernel/pic.s)
|
File: pic.s (kernel/pic.s)
|
||||||
|
|
||||||
Group: Driver {
|
Group: dev {
|
||||||
|
|
||||||
File: serial.s (no auto-title, kernel/drivers/serial.s)
|
Group: AT {
|
||||||
} # Group: Driver
|
|
||||||
|
File: IBM PC/AT (kernel/dev/at/intro.txt)
|
||||||
|
File: cmos.s (kernel/dev/at/cmos.s)
|
||||||
|
File: pit.s (kernel/dev/at/pit.s)
|
||||||
|
File: serial.s (kernel/dev/at/serial.s)
|
||||||
|
} # Group: AT
|
||||||
|
|
||||||
|
} # Group: dev
|
||||||
|
|
||||||
Group: i18n {
|
Group: i18n {
|
||||||
|
|
||||||
File: msg_en.s (kernel/i18n/msg_en.s)
|
File: msg_en.s (kernel/i18n/msg_en.s)
|
||||||
} # Group: i18n
|
} # Group: i18n
|
||||||
|
|
||||||
File: kernel.s (kernel/kernel.s)
|
|
||||||
File: pmm.s (kernel/pmm.s)
|
File: pmm.s (kernel/pmm.s)
|
||||||
|
|
||||||
Group: Sys {
|
Group: sys {
|
||||||
|
|
||||||
File: multiboot.inc (kernel/sys/multiboot.inc)
|
File: multiboot.inc (kernel/sys/multiboot.inc)
|
||||||
|
|
||||||
Group: I386 {
|
Group: i386 {
|
||||||
|
|
||||||
File: cpuid.inc (kernel/sys/i386/cpuid.inc)
|
File: cpuid.inc (kernel/sys/i386/cpuid.inc)
|
||||||
File: mmu.inc (kernel/sys/i386/mmu.inc)
|
File: mmu.inc (kernel/sys/i386/mmu.inc)
|
||||||
File: registers.inc (kernel/sys/i386/registers.inc)
|
File: registers.inc (kernel/sys/i386/registers.inc)
|
||||||
} # Group: I386
|
} # Group: i386
|
||||||
|
|
||||||
} # Group: Sys
|
} # Group: sys
|
||||||
|
|
||||||
File: vm.inc (kernel/vm/vm.inc)
|
File: vm.inc (kernel/vm/vm.inc)
|
||||||
File: pmap.s (kernel/vm/pmap.s)
|
File: pmap.s (kernel/vm/pmap.s)
|
||||||
|
File: cpu.inc (kernel/cpu.inc)
|
||||||
} # Group: Kernel
|
} # Group: Kernel
|
||||||
|
|
||||||
Group: Lib {
|
Group: Lib {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
KERNEL = vmstupid
|
KERNEL = vmstupid
|
||||||
SRCS = boot/head.s \
|
SRCS = boot/head.s \
|
||||||
kernel.s gdt.s pic.s isr.s idt.s \
|
kernel.s gdt.s pic.s isr.s idt.s \
|
||||||
lib/log.s drivers/serial.s
|
lib/log.s dev/at/serial.s \
|
||||||
|
i18n/msg_en.s \
|
||||||
|
base/console.s
|
||||||
INCS = sys/multiboot.inc \
|
INCS = sys/multiboot.inc \
|
||||||
sys/i386/cpuid.inc \
|
sys/i386/cpuid.inc \
|
||||||
sys/i386/mmu.inc \
|
sys/i386/mmu.inc \
|
||||||
|
|
|
@ -30,7 +30,8 @@ align 4
|
||||||
section .multiboot.text
|
section .multiboot.text
|
||||||
|
|
||||||
;; Function: entry
|
;; Function: entry
|
||||||
;;
|
;; Setup boot page table, map kernel to higher half
|
||||||
|
;; then jump to <entry_high>
|
||||||
;;
|
;;
|
||||||
;; in:
|
;; in:
|
||||||
;; EAX - Multiboot magic
|
;; EAX - Multiboot magic
|
||||||
|
@ -83,16 +84,20 @@ entry:
|
||||||
|
|
||||||
section .text
|
section .text
|
||||||
|
|
||||||
|
;; Function: entry_high
|
||||||
|
;; Invalidate page[0], setup stack then call <kmain>
|
||||||
entry_high:
|
entry_high:
|
||||||
|
;; unmap first 4MiB, since it's not needed anymore
|
||||||
mov dword [boot_page_dir], 0
|
mov dword [boot_page_dir], 0
|
||||||
invlpg [0]
|
invlpg [0]
|
||||||
|
|
||||||
|
;; Setup stack
|
||||||
extern stack_top
|
extern stack_top
|
||||||
mov esp, stack_top
|
mov esp, stack_top
|
||||||
xor ebp, ebp
|
xor ebp, ebp
|
||||||
|
|
||||||
push edi
|
push esi ; multiboot struct
|
||||||
push esi
|
push edi ; multiboot magic
|
||||||
extern kmain
|
extern kmain
|
||||||
call kmain
|
call kmain
|
||||||
|
|
||||||
|
|
25
kernel/boot/memory.s
Normal file
25
kernel/boot/memory.s
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
extern kernel_start
|
||||||
|
extern kernel_end
|
||||||
|
extern kernel_size
|
||||||
|
|
||||||
|
pmm_check_page_free:
|
||||||
|
push ebp
|
||||||
|
mov ebp, esp
|
||||||
|
|
||||||
|
|
||||||
|
leave
|
||||||
|
ret
|
||||||
|
|
||||||
|
pmm_setup_from_multiboot_mmap:
|
||||||
|
push ebp
|
||||||
|
mov ebp, esp
|
||||||
|
push edi
|
||||||
|
push esi
|
||||||
|
push ebx
|
||||||
|
|
||||||
|
mov eax, [esi + mb_info.mmap_addr]
|
||||||
|
pop ebx
|
||||||
|
pop esi
|
||||||
|
pop edi
|
||||||
|
leave
|
||||||
|
ret
|
|
@ -1,3 +1,62 @@
|
||||||
|
;; File: cpu.inc
|
||||||
|
|
||||||
|
|
||||||
|
;; Structure: tss
|
||||||
|
;;
|
||||||
|
;; > 31 23 15 7 0
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x64 | I/O map base | 00000000 0000000T |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x60 | 00000000 00000000 | LDT |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x5c | 00000000 00000000 | GS |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x58 | 00000000 00000000 | FS |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x54 | 00000000 00000000 | DS |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x50 | 00000000 00000000 | SS |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x4C | 00000000 00000000 | CS |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x48 | 00000000 00000000 | ES |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x44 | EDI |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x40 | ESI |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x3C | EBP |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x38 | ESP |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x34 | EBX |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x30 | EDX |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x2C | ECX |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x28 | EAX |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x24 | EFLAGS |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x20 | EIP |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x1C | CR3 |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x18 | 00000000 00000000 | SS2 |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x14 | ESP2 |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x10 | 00000000 00000000 | SS1 |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x0C | ESP1 |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x08 | 00000000 00000000 | SS0 |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x04 | ESP0 |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
|
;; > 0x00 | 00000000 00000000 | old TSS selector |
|
||||||
|
;; > +----------|----------+----------|----------+
|
||||||
struc tss
|
struc tss
|
||||||
.link: resw 1
|
.link: resw 1
|
||||||
resw 1
|
resw 1
|
||||||
|
|
72
kernel/dev/at/cmos.s
Normal file
72
kernel/dev/at/cmos.s
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
;; File: cmos.s
|
||||||
|
;; Real/Time Clock/CMOS RAM
|
||||||
|
;;
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x00 - 0x0D | *Real-time clock information |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x0E | *Diagnostic status byte |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x0F | *Shutdown status byte |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x10 | Diskette drive type byte |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x12 | Fixed disk type byte |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x14 | Equipment byte |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x15 | Low base memory byte |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x16 | High base memory byte |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x17 | Low expansion memory byte |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x18 | High expansion memory byte |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x19 | Disk C extended byte |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x1A | Disk D extended byte |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x2E - 0x2F | CMOS checksum |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x30 | *Low expansion memory byte |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x31 | *High expansion memory byte |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x32 | *Date century byte |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
;; > | 0x33 | *Flags |
|
||||||
|
;; > +-------------+------------------------------+
|
||||||
|
|
||||||
|
CMOS_RTC equ 0x00
|
||||||
|
|
||||||
|
RTC_SECONDS equ 0x00
|
||||||
|
RTC_SECOND_ALRM equ 0x01
|
||||||
|
RTC_MINUTES equ 0x02
|
||||||
|
RTC_MINUTE_ALRM equ 0x03
|
||||||
|
RTC_HOURS equ 0x04
|
||||||
|
RTC_HOUR_ALRM equ 0x05
|
||||||
|
RTC_WEEKDAY equ 0x06
|
||||||
|
RTC_DATE_OF_MONTH equ 0x07
|
||||||
|
RTC_MONTH equ 0x08
|
||||||
|
RTC_YEAR equ 0x09
|
||||||
|
RTC_STATUS_REGA equ 0x0A
|
||||||
|
RTC_STATUS_REGB equ 0x0B
|
||||||
|
RTC_STATUS_REGC equ 0x0C
|
||||||
|
RTC_STATUS_REGD equ 0x0D
|
||||||
|
|
||||||
|
STATUS_REGA_UIP equ (1 << 7)
|
||||||
|
|
||||||
|
STATUS_REGB_PIE equ (1 << 6)
|
||||||
|
STATUS_REGB_AIE equ (1 << 5)
|
||||||
|
STATUS_REGB_UIE equ (1 << 4)
|
||||||
|
STATUS_REGB_SQWE equ (1 << 3)
|
||||||
|
STATUS_REGB_DM equ (1 << 2)
|
||||||
|
STATUS_REGB_24H equ (1 << 1)
|
||||||
|
STATUS_REGB_DSE equ (1 << 0)
|
||||||
|
|
||||||
|
CMOS_CENTURY equ 0x32
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
54
kernel/dev/at/intro.txt
Normal file
54
kernel/dev/at/intro.txt
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
File: IBM PC/AT
|
||||||
|
|
||||||
|
About: I/O Address Map
|
||||||
|
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x000 - 0x01F | DMA controller 1 |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x020 - 0x03F | 8259A, Primary |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x040 - 0x05F | Timer |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x060 - 0x06F | Keyboard |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x070 - 0x07F | CMOS |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x080 - 0x09F | DMA page register |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x0A0 - 0x0BF | 8259A, Secondary |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x0C0 - 0x0DF | DMA controller 2 |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x0F0 | Clear Math Coprocessor |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x0F1 | Reset Math Coprocessor |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x0F8 - 0x0FF | Math Coprocessor |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x1F0 - 0x1F8 | Fixed Disk |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x200 - 0x207 | Game I/O |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x278 - 0x27F | Parallel printer port 2 |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x2F8 - 0x2FF | Serial port 2 |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x300 - 0x31F | Prototype card |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x360 - 0x363 | PC Network (low) |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x368 - 0x36B | PC Network (high) |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x378 - 0x37F | Parallel printer port 1 |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x380 - 0x38F | SDLC, bisynchronous 2 |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x3B0 - 0x3BF | Monochrome Display |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x3D0 - 0x3DF | Color Monitor Adapter |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x3F0 - 0x3F7 | Diskette controller |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
> | 0x3F8 - 0x3FF | Serial port 1 |
|
||||||
|
> +---------------+-------------------------+
|
||||||
|
|
0
kernel/dev/at/kbd.S
Normal file
0
kernel/dev/at/kbd.S
Normal file
15
kernel/dev/at/pit.s
Normal file
15
kernel/dev/at/pit.s
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
;; File: pit.s
|
||||||
|
;; Programmable Interval Timer (8253/8254)
|
||||||
|
|
||||||
|
PIT_CHAN_0 equ 0x40
|
||||||
|
PIT_CHAN_1 equ 0x41
|
||||||
|
PIT_CHAN_2 equ 0x42
|
||||||
|
PIT_CMD equ 0x43
|
||||||
|
|
||||||
|
CMD_CHANNEL_1 equ (0x1 << 6)
|
||||||
|
CMD_CHANNEL_2 equ (0x2 << 6)
|
||||||
|
CMD_READ_BACK equ (0x3 << 6)
|
||||||
|
CMD_ACCESS_LO equ (0x1 << 4)
|
||||||
|
CMD_ACCESS_HI equ (0x2 << 4)
|
||||||
|
CMD_ACCESS_LO_HI equ (0x3 << 4)
|
||||||
|
|
|
@ -1,10 +1,3 @@
|
||||||
struc lang_entry
|
%include "i18n/lang.inc"
|
||||||
.code: resb 2
|
|
||||||
.data: resd 1
|
|
||||||
.next: resd 1
|
|
||||||
endstruc
|
|
||||||
|
|
||||||
struc msg_table
|
extern msg_en
|
||||||
.hello_world: resd 1
|
|
||||||
.cpu_exceptions: resd 32
|
|
||||||
endstruc
|
|
||||||
|
|
10
kernel/i18n/lang.inc
Normal file
10
kernel/i18n/lang.inc
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
struc lang_entry
|
||||||
|
.code: resb 2
|
||||||
|
.data: resd 1
|
||||||
|
.next: resd 1
|
||||||
|
endstruc
|
||||||
|
|
||||||
|
struc msg_table
|
||||||
|
.hello_world: resd 1
|
||||||
|
.cpu_exceptions: resd 32
|
||||||
|
endstruc
|
|
@ -1,22 +1,22 @@
|
||||||
; file: msg_en.s
|
; file: msg_en.s
|
||||||
; English strings
|
; English strings
|
||||||
|
|
||||||
%include "i18n.inc"
|
%include "i18n/lang.inc"
|
||||||
|
|
||||||
.section rodata
|
section .rodata
|
||||||
global lang_en
|
global lang_en
|
||||||
lang_en:
|
lang_en:
|
||||||
istruc lang_entry
|
istruc lang_entry
|
||||||
at lang_entry.code: db "en"
|
at lang_entry.code, db "en"
|
||||||
at lang_entry.data: dd msg_en
|
at lang_entry.data, dd msg_en
|
||||||
at lang_entry.next: dd 0
|
at lang_entry.next, dd 0
|
||||||
iend
|
iend
|
||||||
|
|
||||||
|
global msg_en
|
||||||
msg_en:
|
msg_en:
|
||||||
istruc msg_table
|
istruc msg_table
|
||||||
at msg_table.hello_world: dd msg_hello_world
|
at msg_table.hello_world, dd msg_hello_world
|
||||||
|
at msg_table.cpu_exceptions,
|
||||||
at msg_table.cpu_exceptions:
|
|
||||||
dd msg_int_division_zero
|
dd msg_int_division_zero
|
||||||
dd msg_int_debug
|
dd msg_int_debug
|
||||||
dd msg_int_nmi
|
dd msg_int_nmi
|
||||||
|
|
BIN
kernel/intro.txt
Normal file
BIN
kernel/intro.txt
Normal file
Binary file not shown.
Loading…
Reference in a new issue