Skip to content

Commit

Permalink
Multitasking and Ring 3 groundwork
Browse files Browse the repository at this point in the history
Added scheduler into irq0 #10 along with two example tasks to
demonstrate the task switching. Added a security level switch function
into syscalls #12. Added a kernel and user tss. Changed line endings to
Linux.
  • Loading branch information
triforce committed Feb 3, 2016
1 parent 333e912 commit 2e9ca11
Show file tree
Hide file tree
Showing 12 changed files with 1,118 additions and 650 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
minOS
=====

A simple hobby operating system based on a monolithic kernel design written purely in assembly language.
A minimal bare bones operating system based on a monolithic kernel design written purely in Assembly language.

Legacy boots from a pre-built disk image with planned support for GRUB multiboot.

Kernel size: 8 KiB

System Requirements:

* RAM: 2MB - (3MB for User Mode)
* RAM: 3 MiB
* CPU: x86-64

Microprocessors tested on:
Expand Down
Binary file modified imgs/minOS.img
Binary file not shown.
8 changes: 4 additions & 4 deletions src/boot.ASM
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jmp start
nop

; File System Info, legacy BIOS parameter block (bpb)
OEM: db "MIN OS"
OEM: db "MIN OS"
bpbBytesPerSector: dw 512
bpbSectorsPerTrack: dw 18
bpbHeadsPerCylinder: dw 2
bpbHeadsPerCylinder: dw 2
bsDriveNumber: db 0
bsVolumeLabel: db "minOS "

Expand All @@ -30,8 +30,8 @@ start:
; Set up stack and segment registers
; Stop interrupts
cli
xor ax, ax
mov ds, ax
xor ax, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
Expand Down
3 changes: 1 addition & 2 deletions src/build.ASM
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
format binary as 'img'
file 'boot.BIN'
file 'k_main/k_main.BIN'
file 'boot.BIN'
250 changes: 125 additions & 125 deletions src/inc/e820.inc
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,125 +1,125 @@
; =========================================================
; minos -- a hobby operating system written for x86-64
; Copyright (C) 2010-2016
;
; Detect memory
; =========================================================

e820_buffer: times 32 db 0
e820_bufferLength equ $ - e820_buffer
line db crlf, 0
ram_e820h_msg db 'Memory Available Below 1MB (bytes): ', 0
ram_88h_msg db 'Memory Available Above 1MB (kb): ', 0

detect_memory:

do_e820:
pusha

mov [total_mem], dword 0

mov di, e820_buffer
xor ebx, ebx
mov edx, 0534D4150h
mov ecx, e820_bufferLength
mov eax, 0E820h
int 15h
jc .nsupported

.e820_check_1:
cmp eax, 0534D4150h
stc
jne .e820_check_4

push ebx
push ecx

mov eax, dword [di + 16]
cmp eax, 1
jg .not_os
mov eax, [di + 8]
add eax, [total_mem]
mov [total_mem], eax ; Save total mem
jmp .print_values

.not_os:
cmp eax,2
jg .not_reserved
jmp .print_values

.not_reserved:
cmp eax, 3
jg .not_reclaimed
jmp .print_values

.not_reclaimed:
cmp eax, 4
jg .handle_acpinvs
jmp .print_values

.handle_acpinvs:
cmp eax, 5
jg .print_values

.print_values:
; TODO

.e820_check_2:
pop ecx
cmp ecx, 24
jne .end_record
test dword [di + 20], 1
je .ignore
jmp .non_volatile

.ignore:
; TODO

.non_volatile:
test dword [di + 20], 1 shl 1
jne .end_record

.end_record:
pop ebx
or ebx, ebx
je .e820_check_3

mov edx, 0534D4150h
mov ecx, e820_bufferLength
mov eax, 0E820h
int 15h

jnc .e820_check_1

.e820_check_3:
clc

.e820_check_4:
jmp .finish_e820

.nsupported:
mov [mem_check], 0
mov al, 'n'
mov ah, 0eh
int 10h

.finish_e820:
popa
call do_e88h
ret

do_e88h:
push ax
mov ah, 88h
int 15h
jc .nsupported_88
mov [user_mem], ax
pop ax
ret

.nsupported_88:
mov [mem_check], 0
mov al, 'n'
mov ah, 0eh
int 10h
ret
; =========================================================
; minos -- a hobby operating system written for x86-64
; Copyright (C) 2010-2016
;
; Detect memory
; =========================================================

e820_buffer: times 32 db 0
e820_bufferLength equ $ - e820_buffer
line db crlf, 0
ram_e820h_msg db 'Memory Available Below 1MB (bytes): ', 0
ram_88h_msg db 'Memory Available Above 1MB (kb): ', 0

detect_memory:

do_e820:
pusha

mov [total_mem], dword 0

mov di, e820_buffer
xor ebx, ebx
mov edx, 0534D4150h
mov ecx, e820_bufferLength
mov eax, 0E820h
int 15h
jc .nsupported

.e820_check_1:
cmp eax, 0534D4150h
stc
jne .e820_check_4

push ebx
push ecx

mov eax, dword [di + 16]
cmp eax, 1
jg .not_os
mov eax, [di + 8]
add eax, [total_mem]
mov [total_mem], eax ; Save total mem
jmp .print_values

.not_os:
cmp eax,2
jg .not_reserved
jmp .print_values

.not_reserved:
cmp eax, 3
jg .not_reclaimed
jmp .print_values

.not_reclaimed:
cmp eax, 4
jg .handle_acpinvs
jmp .print_values

.handle_acpinvs:
cmp eax, 5
jg .print_values

.print_values:
; TODO

.e820_check_2:
pop ecx
cmp ecx, 24
jne .end_record
test dword [di + 20], 1
je .ignore
jmp .non_volatile

.ignore:
; TODO

.non_volatile:
test dword [di + 20], 1 shl 1
jne .end_record

.end_record:
pop ebx
or ebx, ebx
je .e820_check_3

mov edx, 0534D4150h
mov ecx, e820_bufferLength
mov eax, 0E820h
int 15h

jnc .e820_check_1

.e820_check_3:
clc

.e820_check_4:
jmp .finish_e820

.nsupported:
mov [mem_check], 0
mov al, 'n'
mov ah, 0eh
int 10h

.finish_e820:
popa
call do_e88h
ret

do_e88h:
push ax
mov ah, 88h
int 15h
jc .nsupported_88
mov [user_mem], ax
pop ax
ret

.nsupported_88:
mov [mem_check], 0
mov al, 'n'
mov ah, 0eh
int 10h
ret
Loading

0 comments on commit 2e9ca11

Please sign in to comment.