summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authorBenji Dial <Benji3.141@gmail.com>2019-12-23 01:33:26 -0500
committerBenji Dial <Benji3.141@gmail.com>2019-12-23 01:33:26 -0500
commite520b52cd58f70af9a17f330fe1ce98ce059762c (patch)
treea4d8ec52453b0a8f872aea1ab3c4c5867543c90c /src/kernel
parent4edc0cb2313541e74026c25b52a8f9685d953a14 (diff)
downloadportland-os-e520b52cd58f70af9a17f330fe1ce98ce059762c.tar.gz
small changes, part 1
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/link.ld11
-rw-r--r--src/kernel/main.c4
-rw-r--r--src/kernel/mem.c2
-rw-r--r--src/kernel/misc.h2
-rw-r--r--src/kernel/proc.c2
5 files changed, 17 insertions, 4 deletions
diff --git a/src/kernel/link.ld b/src/kernel/link.ld
new file mode 100644
index 0000000..64dd0be
--- /dev/null
+++ b/src/kernel/link.ld
@@ -0,0 +1,11 @@
+OUTPUT_FORMAT(binary)
+SECTIONS {
+ . = 0x01000000;
+ .text : {
+ main = .;
+ *(.text)
+ }
+ .rodata : { *(.rodata) }
+ .data : { *(.data) }
+ .bss : { *(.bss) }
+} \ No newline at end of file
diff --git a/src/kernel/main.c b/src/kernel/main.c
index 54b0a83..6a8630b 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -24,12 +24,14 @@ OF THIS SOFTWARE.
#include "misc.h"
void main(void) {
+ *(uint16_t *)0x0000200e = 0x0000;
+
*(uint32_t *)0x0000050c = (uint32_t)allocate_pages(16 * sizeof(struct file_handle_info), 2);
for (struct file_handle_info *i = FILE_HANDLES, *l = FILE_HANDLES + 65536; i < l; ++i)
i->first_sector = 0;
*(uint32_t *)0x00000510 = (uint32_t)allocate_pages(16 * sizeof(struct proc_info), 2);
- for (struct proc_info *i = FILE_HANDLES, *l = FILE_HANDLES + 65536; i < l; ++i)
+ for (struct proc_info *i = PROCS, *l = PROCS + 65536; i < l; ++i)
i->memory_start = 0;
uint16_t pages_free = 0, pages_total = 0;
diff --git a/src/kernel/mem.c b/src/kernel/mem.c
index f12fbf7..509c768 100644
--- a/src/kernel/mem.c
+++ b/src/kernel/mem.c
@@ -36,6 +36,6 @@ void *allocate_pages(uint16_t n_pages, uint16_t proc_n) {
}
void deallocate_pages(void *from, uint16_t n_pages) {
- for (uint16_t *mb = MMAP + ((uint32_t)from / 0x1000), *l = mb + n_pages; mb < l; ++mb)
+ for (uint16_t *mb = MMAP + (uint32_t)from / 0x1000, *l = mb + n_pages; mb < l; ++mb)
*mb = 0;
} \ No newline at end of file
diff --git a/src/kernel/misc.h b/src/kernel/misc.h
index c68bccc..d333f26 100644
--- a/src/kernel/misc.h
+++ b/src/kernel/misc.h
@@ -22,6 +22,6 @@ OF THIS SOFTWARE.
#ifndef MISC_H
#define MISC_H
-void print_32(uint32_t n);
+void put_16(uint16_t n);
#endif \ No newline at end of file
diff --git a/src/kernel/proc.c b/src/kernel/proc.c
index dba6b92..a0fb863 100644
--- a/src/kernel/proc.c
+++ b/src/kernel/proc.c
@@ -25,7 +25,7 @@ uint16_t new_proc(uint8_t *file) {
uint16_t handle = open_file(file);
if (handle)
for (uint16_t id = 3; id; ++id)
- if (!(PROCS[id].memory_start)) {
+ if (!PROCS[id].memory_start) {
uint32_t size = get_size(id);
void *mem = PROCS[id].memory_start = allocate_pages(PROCS[id].n_pages = (size - 1) / 4096 + 1, id);
read_file(handle, size, mem);