summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (from: 94668af)
raw | patch | inline | side by side (from: 94668af)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 19 Aug 2020 20:21:57 +0000 (23:21 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 19 Aug 2020 20:21:57 +0000 (23:21 +0300) |
12 files changed:
Boot486/boot0.S | patch | blob | history | |
Docu486/Build-Tool.odc | patch | blob | history | |
Drv/Mod486/KeyboardPS2.odc | [new file with mode: 0644] | patch | blob |
Drv/Mod486/MousePS2.odc | patch | blob | history | |
Drv/Mod486/PS2.odc | [deleted file] | patch | blob | history |
Drv/Mod486/Vesa.odc | patch | blob | history | |
Host/Mod486/Console.odc | patch | blob | history | |
Host/Mod486/Ports.odc | patch | blob | history | |
Host/Mod486/Shell.odc | patch | blob | history | |
Sys/Mod486/Input.odc | [new file with mode: 0644] | patch | blob |
System/Mod486/Init.odc | patch | blob | history | |
System/Mod486/Kernel.odc | patch | blob | history |
diff --git a/Boot486/boot0.S b/Boot486/boot0.S
index ef70f6b024d135b74de734c7cc0cfab290471872..409a28a9126c5c83480298a5e2c260922f0f8c64 100644 (file)
--- a/Boot486/boot0.S
+++ b/Boot486/boot0.S
.set MemoryMapAdr, 0x7e0A
.set ImageBase, 0x100000
+_start:
+
# =========================================================================== #
-# Stage 1
+# Setup canonical %cs:%eip, segment registers %ds, %es, %fs, %gs, %ss and
+# stack %sp
# =========================================================================== #
-_start:
-
.code16
-stage1:
-# 1. Setup canonical %cs:%eip, segment registers %ds, %es, %fs, %gs, %ss and stack %sp
+
cli
ljmp $0x0, $canonized_label; canonized_label:
xor %ax, %ax
mov $STACK1, %sp
mov %dx, BootDiskAdr
- call mapmem
- sti
-# 2. Enable A20 gate
- call enableA20
+# =========================================================================== #
+# Make memory map for kernel
+# =========================================================================== #
+
+ pusha
+ movl $0, MemoryMapAdr
+ xor %ebx, %ebx
+ mov $(MemoryMapAdr + 4), %di
+
+mapmem_loop:
+ mov $0xe820, %eax
+ mov $20, %ecx
+ mov $0x0534D4150, %edx
+ int $0x15
+ jc mapmem_method_88
+ cmp %edx, %eax
+ jne mapmem_method_88
+ cmp $0, %ebx
+ je mapmem_done
+ add $20, %di
+ incl MemoryMapAdr
+ jmp mapmem_loop
+
+mapmem_method_88:
+ #####
+ ### function:
+ ### int 0x15 + %ah = 0x88
+ ### input:
+ ### none
+ ### output:
+ ### cf clear:
+ ### %ax = available memory starting at 0x100000 in KB
+ ### cf set:
+ ### %ah = error code
+ ### note:
+ ### some bioses do not clear cf, do it manually
+ #####
+
+ movl $3, (MemoryMapAdr + 0) # num
+ xor %eax, %eax
+ mov $1, %ebx
+ # free low memory
+ movl %eax, (MemoryMapAdr + 4) # base (low)
+ movl %eax, (MemoryMapAdr + 8) # base (high)
+ movl $0x080000, (MemoryMapAdr + 12) # len (low)
+ movl %eax, (MemoryMapAdr + 16) # len (high)
+ movl %ebx, (MemoryMapAdr + 20) # type
+ # reserved harware memory
+ movl $0x080000, (MemoryMapAdr + 24) # base (low)
+ movl %eax, (MemoryMapAdr + 28) # base (high)
+ movl $0x080000, (MemoryMapAdr + 32) # len (low)
+ movl %eax, (MemoryMapAdr + 36) # len (high)
+ movl %eax, (MemoryMapAdr + 40) # type
+ # free high memory
+ movl $0x100000, (MemoryMapAdr + 44) # base (low)
+ movl %eax, (MemoryMapAdr + 48) # base (high)
+ #movl $0x700000, (MemoryMapAdr + 52) # len (low)
+ movl %eax, (MemoryMapAdr + 56) # len (high)
+ movl %ebx, (MemoryMapAdr + 60) # type
+
+ clc
+ mov $0x88, %ah
+ int $0x15
+ jc mapmem_failed
+ test %ax, %ax
+ je mapmem_failed
+ movzx %ax, %eax
+ shl $10, %eax
+ movl %eax, (MemoryMapAdr + 52) # len (low)
+ jmp mapmem_done
+
+mapmem_failed:
+ mov $msg_mapmem_failed, %si
+ call print
+ hlt
+
+mapmem_done:
+ popa
+
+# =========================================================================== #
+# Enable A20 Line
+# =========================================================================== #
+
+enableA20:
+ xor %cx, %cx
+enableA20_1:
+ inc %cx
+ jz enableA20_3
+ in $0x64, %al
+ test $0x2, %al
+ jnz enableA20_1
+ mov $0xd1, %al
+ out %al, $0x64
+enableA20_2:
+ in $0x64, %al
+ test $0x2, %al
+ jnz enableA20_2
+ mov $0xdf, %al
+ out %al, $0x60
+enableA20_3:
-# 3. Reset disk controller (%dl and %dh initialized by bios) and read Kernel into buffer
+# =========================================================================== #
+# Reset disk controller (%dl and %dh initialized by bios) and read Kernel
+# into buffer
+# =========================================================================== #
+ sti
movl $(kernel_code_end - kernel_code_start), KernelSizeAdr
- stage1__read:
- mov current_sector, %ax
- add $1, %ax
- call lba2chs
+stage1__read:
+ mov current_sector, %ax
+ add $1, %ax
+ call lba2chs
+
+ mov current_sector, %ax
+ shl $5, %ax
+ add $(BUFFER / 16), %ax
+ mov %ax, %es
+
+readsectors:
+ # %cx = Cylider+Sector; %es = 64k buf
+ xor %ah, %ah
+ int $0x13
- mov current_sector, %ax
- shl $5, %ax
- add $(BUFFER / 16), %ax
- mov %ax, %es
- call readsectors
+ xor %bx, %bx
+ mov $0x2, %ah
+ mov $READBLOCKS, %al
+ clc
+ int $0x13
- mov current_sector, %ax
- add $READBLOCKS, %ax
- mov %ax, current_sector
- cmp $((kernel_code_end - kernel_code_start + 511) / 512), %ax
- jl stage1__read
+ jnc readsectors__success
-# 4. Disable interrupts and load GDT
- mov $msg_protected_mode, %si
+ /* zero if sectors not readed */
+ or %ah, %ah
+ jnz readsectors__success
+
+ mov $msg_kernel_read_failed, %si
call print
+ #cli
+ hlt
+readsectors__success:
+
+ mov current_sector, %ax
+ add $READBLOCKS, %ax
+ mov %ax, current_sector
+ cmp $((kernel_code_end - kernel_code_start + 511) / 512), %ax
+ jl stage1__read
cli
+
+# =========================================================================== #
+# Load GDT
+# =========================================================================== #
+ mov $msg_protected_mode, %si
+ call print
lgdt gdt_info
-# 5. Switch to protected mode
+# =========================================================================== #
+# Switch to protected mode
+# =========================================================================== #
mov %cr0, %eax
or $1, %al
mov %eax, %cr0
jmp $8, $stage2
# =========================================================================== #
-# Stage 2
+# 32 bit stage begins
# =========================================================================== #
.code32
+
stage2:
-# 6. Setup data segments %ds, %es, %fs, %gs and stack %sp
+
+# =========================================================================== #
+# Setup data segments %ds, %es, %fs, %gs and stack %sp
+# =========================================================================== #
mov $16, %ax
mov %ax, %ds
mov %ax, %ss
mov %ax, %fs
mov %ax, %gs
mov $STACK2, %sp
-# 7. Copy Kernel from buffer
+
+# =========================================================================== #
+# Copy Kernel from buffer
+# =========================================================================== #
+
xor %eax, %eax
stage2_copy_loop:
mov BUFFER(%eax), %bh
inc %eax
cmp $(kernel_code_end - kernel_code_start), %eax
jne stage2_copy_loop
-# 8. Exec Kernel
+
+# =========================================================================== #
+# Jump to Kernel code (never returns)
+# =========================================================================== #
+
jmp ImageBase
+# =========================================================================== #
+# ================================ routines ================================= #
+# =========================================================================== #
# =========================================================================== #
# Print asciiz string
popa
ret
-# =========================================================================== #
-# Make memory map for kernel
-# =========================================================================== #
-
-.code16
-mapmem:
- pusha
- movl $0, MemoryMapAdr
- xor %ebx, %ebx
- mov $(MemoryMapAdr + 4), %di
- mapmem__loop:
- mov $0xe820, %eax
- mov $20, %ecx
- mov $0x0534D4150, %edx
- int $0x15
- jc mapmem__failed
- cmp %edx, %eax
- jne mapmem__failed
- cmp $0, %ebx
- je mapmem__done
- add $20, %di
- incl MemoryMapAdr
- jmp mapmem__loop
- mapmem__done:
- popa
- ret # <============
- mapmem__failed:
- mov $msg_mapmem_failed, %si
- call print
- cli
- hlt
-
# =========================================================================== #
# Convert LBA to CHS
# input: %ax = LBA %dl = disk
jnc lba2chs__success
mov $msg_chs_error, %si
call print
- cli
hlt
lba2chs__success:
mov %dx, BootDiskDxAdr
# pop %es
ret
-# =========================================================================== #
-# Read sectors to buffer
-# input: %cx = Cylider+Sector; %es = 64k buf
-# =========================================================================== #
-
-.code16
-readsectors:
- xor %ah, %ah
- int $0x13
-
- xor %bx, %bx
- mov $0x2, %ah
- mov $READBLOCKS, %al
- clc
- int $0x13
-
- jnc readsectors__success
-
- /* zero if sectors not readed */
- or %ah, %ah
- jnz readsectors__success
-
- mov $msg_kernel_read_failed, %si
- call print
- cli
- hlt
-
-readsectors__success:
- ret
-
-# =========================================================================== #
-# Enable A20 Line
-# =========================================================================== #
-
-.code16
-
-enableA20:
- cli
- xor %cx, %cx
-enableA20_1:
- inc %cx
- jz enableA20_3
- in $0x64, %al
- test $0x2, %al
- jnz enableA20_1
- mov $0xd1, %al
- out %al, $0x64
-enableA20_2:
- in $0x64, %al
- test $0x2, %al
- jnz enableA20_2
- mov $0xdf, %al
- out %al, $0x60
-enableA20_3:
- sti
- ret
-
# =========================================================================== #
# =========================================================================== #
# =========================================================================== #
diff --git a/Docu486/Build-Tool.odc b/Docu486/Build-Tool.odc
index 62c4f760b7117ba7442f9b0f188ef339c1885d4b..c0f3481e2ccfe82201bad79e136cb778a973511a 100644 (file)
Binary files a/Docu486/Build-Tool.odc and b/Docu486/Build-Tool.odc differ
Binary files a/Docu486/Build-Tool.odc and b/Docu486/Build-Tool.odc differ
diff --git a/Drv/Mod486/KeyboardPS2.odc b/Drv/Mod486/KeyboardPS2.odc
new file mode 100644 (file)
index 0000000..ec5cfb9
Binary files /dev/null and b/Drv/Mod486/KeyboardPS2.odc differ
index 0000000..ec5cfb9
Binary files /dev/null and b/Drv/Mod486/KeyboardPS2.odc differ
index fc52459e6dbf7363a4843bc323d3985783451cf0..07b5ddab9207378f8a5d032186a673196b5af5a0 100644 (file)
Binary files a/Drv/Mod486/MousePS2.odc and b/Drv/Mod486/MousePS2.odc differ
Binary files a/Drv/Mod486/MousePS2.odc and b/Drv/Mod486/MousePS2.odc differ
diff --git a/Drv/Mod486/PS2.odc b/Drv/Mod486/PS2.odc
deleted file mode 100644 (file)
index 4f329a2..0000000
Binary files a/Drv/Mod486/PS2.odc and /dev/null differ
index 4f329a2..0000000
Binary files a/Drv/Mod486/PS2.odc and /dev/null differ
diff --git a/Drv/Mod486/Vesa.odc b/Drv/Mod486/Vesa.odc
index cb64b50b5d928db9118aeea60ed78a569a5a2437..129f1e5ba74f75631b17eda7c6bd0cd1403a7afe 100644 (file)
Binary files a/Drv/Mod486/Vesa.odc and b/Drv/Mod486/Vesa.odc differ
Binary files a/Drv/Mod486/Vesa.odc and b/Drv/Mod486/Vesa.odc differ
index 56ee66d04ef955a1c1b26f980bf85510056e5968..7fc638f0054d569a3bb595257f628d80d056b4ce 100644 (file)
Binary files a/Host/Mod486/Console.odc and b/Host/Mod486/Console.odc differ
Binary files a/Host/Mod486/Console.odc and b/Host/Mod486/Console.odc differ
diff --git a/Host/Mod486/Ports.odc b/Host/Mod486/Ports.odc
index f62912dda2e70b1d4c23413a2de7dfd61d6911f9..3c49c0104f837d3d4d633352e852113d73840da1 100644 (file)
Binary files a/Host/Mod486/Ports.odc and b/Host/Mod486/Ports.odc differ
Binary files a/Host/Mod486/Ports.odc and b/Host/Mod486/Ports.odc differ
diff --git a/Host/Mod486/Shell.odc b/Host/Mod486/Shell.odc
index de8c12b743d69f8f423e8a72f07ea411285226e2..de0543b87fd65591f34fa5217be3d5619274ba60 100644 (file)
Binary files a/Host/Mod486/Shell.odc and b/Host/Mod486/Shell.odc differ
Binary files a/Host/Mod486/Shell.odc and b/Host/Mod486/Shell.odc differ
diff --git a/Sys/Mod486/Input.odc b/Sys/Mod486/Input.odc
new file mode 100644 (file)
index 0000000..9a40b37
Binary files /dev/null and b/Sys/Mod486/Input.odc differ
index 0000000..9a40b37
Binary files /dev/null and b/Sys/Mod486/Input.odc differ
diff --git a/System/Mod486/Init.odc b/System/Mod486/Init.odc
index 91bff79978301d8a0460d1acf908ca530585a9b7..7e3d07f559c593de70fdc5e415b9e3204508040f 100644 (file)
Binary files a/System/Mod486/Init.odc and b/System/Mod486/Init.odc differ
Binary files a/System/Mod486/Init.odc and b/System/Mod486/Init.odc differ
index f8e730cfef8eec6e19887c19a480cc33e4a66c2a..f98d8bb0fe005e255149fe37fda28f2cba12f492 100644 (file)
Binary files a/System/Mod486/Kernel.odc and b/System/Mod486/Kernel.odc differ
Binary files a/System/Mod486/Kernel.odc and b/System/Mod486/Kernel.odc differ