mirror of https://github.com/E-Almqvist/eOS
commit
54337e72e9
@ -1,9 +1,19 @@ |
||||
# TO DO |
||||
- Multiboot (read end of memory etc) |
||||
- String interpolation |
||||
# TO DO |
||||
- FIX E820 |
||||
- actual gdt |
||||
- CPU freq detection |
||||
- proc? |
||||
- Screen scrolling |
||||
- Malloc all kernel code |
||||
- (Random lib: random num from a to b?) |
||||
|
||||
## Long term |
||||
- Get rust lang to work/switch to rust |
||||
- Shell? |
||||
- Improve memory management |
||||
## Userland????????? |
||||
- Shell: input, execute |
||||
|
||||
- prog/time: show time |
||||
- prog/date: show date |
||||
- prog/mem: show amount of memory |
||||
- prog/bitmap: show phys bitmap |
||||
|
||||
# Long term |
||||
- Rust? |
||||
|
@ -1,49 +1,89 @@ |
||||
; SRs to find memory size and leave it as a "note" for the kernel |
||||
|
||||
mmap_probe: ; literally just test the memory boundaries |
||||
push eax |
||||
push ebx |
||||
push edx |
||||
push ebp |
||||
; mmap_probe: ; literally just test the memory boundaries |
||||
; push eax |
||||
; push ebx |
||||
; push edx |
||||
; push ebp |
||||
; |
||||
; mov ebp, esi |
||||
; add esi, 0x00000ff |
||||
; and esi, ~0x00000ff |
||||
; mmap_probe_addr: |
||||
; |
||||
; mmap_probe_done: |
||||
|
||||
mov ebp, esi |
||||
add esi, 0x00000ff |
||||
and esi, ~0x00000ff |
||||
mmap_probe_addr: |
||||
e820_stats_addr equ 0x9820 |
||||
|
||||
mmap_probe_done: |
||||
|
||||
mmap_e820: |
||||
mov di, 0x8004 |
||||
e820: |
||||
mov di, e820_stats_addr + 4 |
||||
mov ebx, 0 ; Must be 0 |
||||
mov bp, 0 ; entry count |
||||
|
||||
mov eax, 0xe820 ; function reg |
||||
mov edx, 'SMAP' ; function sig |
||||
|
||||
; TODO: update es:di to e820_dt |
||||
mov [es:di + 20], dword 1 ; fill |
||||
mov ecx, 24 ; ask for 24 bytes |
||||
int 0x15 ; Do the interupt |
||||
|
||||
; carry flag = (un)supported function |
||||
jc mmap_e820_fail ; Try probing instead |
||||
jc e820_fail_unsup ; TODO: Try probing instead |
||||
|
||||
cmp eax, edx ; eax should be = 'SMAP' |
||||
jne mmap_e820_fail ; if not then fail |
||||
jne e820_fail_smap ; if not then fail |
||||
|
||||
test ebx, ebx |
||||
je mmap_e820_fail |
||||
test ebx, ebx ; no entries |
||||
je e820_fail_noent |
||||
|
||||
mmap_e820_fail: |
||||
stc |
||||
e820_lp: |
||||
mov eax, 0xe820 |
||||
mov [es:di + 20], dword 1 |
||||
mov ecx, 24 |
||||
int 0x15 |
||||
jc e820_finish ; carry => finished -> save entry count |
||||
|
||||
e820_iter: |
||||
; skip 0 entries |
||||
jcxz e820_skip |
||||
|
||||
; check resp |
||||
cmp cl, 20 |
||||
jbe e820_ntxt |
||||
|
||||
; check the ignore bit |
||||
test byte [es:di + 20], 1 |
||||
je e820_skip |
||||
|
||||
e820_ntxt: |
||||
mov ecx, [es:di + 8] ; lower mem length |
||||
; test for 0 |
||||
or ecx, [es:di + 12] |
||||
jz e820_skip |
||||
|
||||
; next entry |
||||
inc bp |
||||
add di, 24 |
||||
|
||||
e820_skip: |
||||
test ebx, ebx ; of ebx = 0 then complete |
||||
jne e820_lp |
||||
|
||||
e820_finish: |
||||
mov [e820_stats_addr], bp ; save entry count at e820_ent |
||||
clc |
||||
ret |
||||
|
||||
e820_dt_start: |
||||
e820_low: dd 0 |
||||
e820_high: dd 0 |
||||
e820_len_low: dd 0 |
||||
e820_len_high: dd 0 |
||||
e820_type: dd 0 |
||||
e820_dt_end: |
||||
e820_fail_unsup: |
||||
mov [e820_stats_addr], byte -1 |
||||
jmp e820_fail |
||||
e820_fail_smap: |
||||
mov [e820_stats_addr], byte -2 |
||||
jmp e820_fail |
||||
e820_fail_noent: |
||||
mov [e820_stats_addr], byte -3 |
||||
jmp e820_fail |
||||
|
||||
e820_fail: |
||||
stc |
||||
ret |
||||
|
@ -1,23 +1,76 @@ |
||||
#include "kernel.h" |
||||
|
||||
void print_kernel_motd() { |
||||
printalign(" ___ ____ ", BANNER_COLOR, MIDDLE); |
||||
printalign(" ___ / _ \\/ ___| ", BANNER_COLOR, MIDDLE); |
||||
printalign(" / _ \\ | | \\___ \\ ", BANNER_COLOR, MIDDLE); |
||||
printalign("| __/ |_| |___) | A x86 operating system,", BANNER_COLOR, MIDDLE); |
||||
printalign(" \\___|\\___/|____/ licenced under GPL-2.0", BANNER_COLOR, MIDDLE); |
||||
|
||||
println(""); |
||||
printalign("Fun fact: e = lim[h->0] (1+h)^(1/h)", DEFAULT_COLOR, MIDDLE); |
||||
printalign("Created by E. Almqvist", DEFAULT_COLOR, MIDDLE); |
||||
println(""); |
||||
} |
||||
|
||||
void print_kernel_stats() { |
||||
char* buf; |
||||
// Memory stats
|
||||
print("MEMORY BITMAP: ", 0x0f); |
||||
buf = itoa(get_bitmap(), buf, 2); |
||||
println(buf, DEFAULT_COLOR); |
||||
|
||||
println(""); |
||||
|
||||
println("BIOS E820", 0x0f); |
||||
print("Loaded Entries: ", DEFAULT_COLOR); |
||||
uint entries = get_phys_mem_size(); |
||||
buf = itoa(entries, buf, 10); |
||||
println(buf, DEFAULT_COLOR); |
||||
|
||||
print("Physical Memory Size: "); |
||||
println("?", DEFAULT_COLOR); |
||||
|
||||
println(""); |
||||
|
||||
// VGA stats
|
||||
println("Display (VGA)", 0x0f); |
||||
print("Memory Range: ", DEFAULT_COLOR); |
||||
buf = itoa(VGA_ADDRESS, buf, 16); |
||||
print(buf, DEFAULT_COLOR); |
||||
print(" - "); |
||||
buf = itoa(VGA_ADDRESS_MAX, buf, 16); |
||||
println(buf, DEFAULT_COLOR); |
||||
|
||||
print("Screen Dimensions: ", DEFAULT_COLOR); |
||||
buf = itoa(MAX_COLS, buf, 10); |
||||
print(buf, DEFAULT_COLOR); |
||||
print("x"); |
||||
buf = itoa(MAX_ROWS, buf, 10); |
||||
println(buf, DEFAULT_COLOR); |
||||
|
||||
uint ticks = 0; |
||||
while (true) { |
||||
set_cursor_pos(0, 20); |
||||
buf = itoa(ticks, buf, 10); |
||||
printalign(buf, 0x0f, MIDDLE); |
||||
++ticks; |
||||
} |
||||
|
||||
} |
||||
|
||||
void kernel_init() { |
||||
vga_init(); // Initialize the screen first
|
||||
// i.e. clear the screen et cetera.
|
||||
|
||||
println("Kernel loaded", SUCCESS_COLOR); |
||||
// i.e. clear the screen et cetera.
|
||||
|
||||
// Allocate VGA memory range
|
||||
pm_malloc_range(VGA_ADDRESS, VGA_ADDRESS_MAX, true); // force alloc the VGA range
|
||||
|
||||
// ENABLE PAGING
|
||||
// TODO: make this work
|
||||
// enable_paging();
|
||||
|
||||
println(""); |
||||
char* title = "eOS - lim[h->0] (1+h)^(1/h) OS"; |
||||
println(title, DEFAULT_COLOR); |
||||
|
||||
char* subtitle = "A x86 operating system, licenced under GPL-2.0"; |
||||
println(subtitle, DEFAULT_COLOR); |
||||
clear_screen(); |
||||
print_kernel_motd(); |
||||
print_kernel_stats(); |
||||
|
||||
} |
||||
|
@ -1,11 +1,11 @@ |
||||
|
||||
#include "memory.h" |
||||
#include "paging.h" |
||||
#include "../drivers/vga.h" |
||||
#include "../lib/str.h" |
||||
#include "../lib/conv.h" |
||||
|
||||
#define STATUS_TEXT_COLOR 0x0f |
||||
#define BANNER_COLOR 0x0c |
||||
|
||||
void init(); |
||||
void display_status(char*, unsigned int);
|
||||
void print_kernel_motd(); |
||||
void print_kernel_stats(); |
||||
void kernel_init(); |
||||
|
@ -1,18 +1,48 @@ |
||||
#include "conv.h" |
||||
#include "../drivers/vga.h" |
||||
|
||||
char* int_to_str(int i, char* buf) { |
||||
ulong num = (ulong)i; // convert to ulong
|
||||
uint len = ulong_len(num); // number of digits
|
||||
char* itoa( int value, char * str, int base ) { |
||||
char* rc; |
||||
char* ptr; |
||||
char* low; |
||||
|
||||
*(buf+len) = '\0'; // add a "end-of-string" at the end
|
||||
// Check for supported base.
|
||||
if( base < 2 || base > 36 ) { |
||||
*str = '\0'; |
||||
return str; |
||||
} |
||||
rc = ptr = str; |
||||
|
||||
switch(base) { |
||||
case 16: |
||||
*ptr++ = '0'; |
||||
*ptr++ = 'x'; |
||||
case 10: |
||||
if(value < 0) |
||||
*ptr++ = '-'; |
||||
} |
||||
|
||||
// if(value < 0 && base == 10 ) // sign
|
||||
// *ptr++ = '-';
|
||||
|
||||
// Remember where the numbers start.
|
||||
low = ptr; |
||||
|
||||
// The actual conversion.
|
||||
do { |
||||
// Modulo is negative for negative value. This trick makes abs() unnecessary.
|
||||
*ptr++ = "zyxwvutsrqponmlkjihgfedcba9876543210123456789abcdefghijklmnopqrstuvwxyz"[35 + value % base]; |
||||
value /= base; |
||||
} while(value); |
||||
|
||||
// Terminating the string.
|
||||
*ptr-- = '\0'; |
||||
|
||||
int j; |
||||
for(j = 0; j < len; j++) { // iterate over each digit and assign it to the buffer
|
||||
// super dangerous memory write
|
||||
*(buf+j) = (char)(ndigit(num, len-1-j) + ASCII_OFFSET); // apply the ascii offset so that i becomes a char
|
||||
println(*(buf+j), 0xc0); |
||||
// Invert the numbers.
|
||||
while ( low < ptr ) { |
||||
char tmp = *low; |
||||
*low++ = *ptr; |
||||
*ptr-- = tmp; |
||||
} |
||||
|
||||
return buf; |
||||
return rc; |
||||
} |
||||
|
@ -1,6 +1,4 @@ |
||||
#include "types.h" |
||||
#include "util.h" |
||||
|
||||
#define ASCII_OFFSET 0x30 |
||||
|
||||
char* int_to_str(int i, char* buf); |
||||
char* itoa(int, char*, int); |
||||
|
Before Width: | Height: | Size: 3.3 KiB |
Loading…
Reference in new issue