TODO and stuff

rust
E. Almqvist 3 years ago
parent 572be221b3
commit 9649d1a10d
  1. 19
      TODO.md
  2. 6
      drivers/vga.c
  3. 7
      kernel/kernel.c
  4. 1
      kernel/kernel.h
  5. 6
      kernel/memory.c
  6. 2
      kernel/memory.h
  7. 31
      lib/conv.c
  8. 3
      lib/math.c
  9. 2
      lib/math.h

@ -1,9 +1,14 @@
# TO DO # TO DO
- Multiboot (read end of memory etc) - Math lib: powf, log10, numlen
- String interpolation - Str lib: int\_to\_str
- Screen scrolling - Read and display e820 memory mapping
- (Random lib: random num from a to b?)
- Shell: input, execute
## Long term - prog/time: show time
- Get rust lang to work/switch to rust - prog/date: show date
- Shell? - prog/mem: show amount of memory
- Improve memory management - prog/bitmap: show phys bitmap
# Long term
- Rust?

@ -11,14 +11,14 @@ static uint cursor_col = 0;
void vga_init() { void vga_init() {
// Disable cursor // Disable cursor
port_outb(0x3d4, 0x0a); // port_outb(0x3d4, 0x0a);
port_outb(0x3d5, 0x20); // port_outb(0x3d5, 0x20);
// Clear screen // Clear screen
// clear_row(0); // clear_row(0);
// clear_screen(); // clear_screen();
set_cursor_pos(0, 0); //set_cursor_pos(0, 0);
} }
/* /*

@ -23,9 +23,14 @@ void kernel_init() {
// Allocate VGA memory range // Allocate VGA memory range
pm_malloc_range(VGA_ADDRESS, VGA_ADDRESS_MAX, true); // force alloc the VGA range pm_malloc_range(VGA_ADDRESS, VGA_ADDRESS_MAX, true); // force alloc the VGA range
// ENABLE PAGING // ENABLE PAGING
// TODO: make this work // TODO: make this work
// enable_paging(); // enable_paging();
set_cursor_pos(0, 8);
print("E820 loaded entries: ", DEFAULT_COLOR);
uint entries = get_phys_mem_size();
char* buf;
buf = int_to_str(entries, buf);
println(buf, DEFAULT_COLOR);
} }

@ -6,4 +6,5 @@
#define BANNER_COLOR 0x0f #define BANNER_COLOR 0x0f
void kernel_motd();
void kernel_init(); void kernel_init();

@ -23,6 +23,12 @@
static int bitmap = 0; static int bitmap = 0;
static uint last_block; static uint last_block;
uint get_phys_mem_size() {
// TODO: read actual mappings
uint entry_count = (uint) *BIOS_E820;
return entry_count;
}
void mod_bitmap(uint bit, uint bflag) { void mod_bitmap(uint bit, uint bflag) {
// create a bitmask that will be applied to the bitmap // create a bitmask that will be applied to the bitmap
int bitmask = 1 << bit; int bitmask = 1 << bit;

@ -25,3 +25,5 @@ void pm_malloc_range(ulong start, ulong end, bool force); // allocate a range of
pointer pm_malloc(uint block_count); // allocate some blocks pointer pm_malloc(uint block_count); // allocate some blocks
void pm_free(int* p); // free a var (if allocated with pm_malloc) void pm_free(int* p); // free a var (if allocated with pm_malloc)
uint get_phys_mem_size(); // physical memory size with e820 left by the bootloader

@ -1,18 +1,23 @@
#include "conv.h" #include "conv.h"
#include "../drivers/vga.h" #include "../drivers/vga.h"
char* int_to_str(int i, char* buf) { // char* int_to_str(int i, char* buf) {
ulong num = (ulong)i; // convert to ulong // ulong num = (ulong)i; // convert to ulong
uint len = ulong_len(num); // number of digits // uint len = ulong_len(num); // number of digits
//
*(buf+len) = '\0'; // add a "end-of-string" at the end // *(buf+len) = '\0'; // add a "end-of-string" at the end
//
// 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);
// }
//
// return buf;
// }
int j; char* int_to_str(int i, char* buf) {
for(j = 0; j < len; j++) { // iterate over each digit and assign it to the buffer char* sign = (i < 0) ? "-" : "+";
// super dangerous memory write return (char*) sign;
*(buf+j) = (char)(ndigit(num, len-1-j) + ASCII_OFFSET); // apply the ascii offset so that i becomes a char
println(*(buf+j), 0xc0);
}
return buf;
} }

@ -17,3 +17,6 @@ long square(uint num) {
} }
return sum + 1; return sum + 1;
} }
float powf(float n) {}

@ -2,3 +2,5 @@
long pow(int, uint); long pow(int, uint);
long square(uint); long square(uint);
float powf(float);

Loading…
Cancel
Save