Skip to content

Commit 1293722

Browse files
authored
Merge pull request #19 from dark-tree/fixes
Skibidi Fixes
2 parents c97edba + c906a7b commit 1293722

File tree

13 files changed

+105
-22
lines changed

13 files changed

+105
-22
lines changed

disks/files/executable/elf-pic

-636 KB
Binary file not shown.

disks/files/executable/tiny

696 Bytes
Binary file not shown.

disks/files/executable/tiny.asm

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
global _start
2+
3+
section .data:
4+
5+
hello: db `Hello World!\n`
6+
path: db `./hello.txt`, 0
7+
8+
section .text:
9+
10+
_rip:
11+
pop eax
12+
mov ecx, eax
13+
sub eax, 5
14+
sub eax, _start
15+
jmp ecx
16+
17+
_start:
18+
19+
call _rip
20+
push eax
21+
add eax, path
22+
mov ebx, eax
23+
24+
; sys_open
25+
mov eax, 0x05
26+
mov ecx, 0x442
27+
mov edx, 0x180
28+
int 0x80
29+
30+
; File Descriptor
31+
mov ebx, eax
32+
33+
; Get pointer to "Hello World"
34+
pop ecx
35+
add ecx, hello
36+
37+
; sys_write
38+
mov eax, 0x04
39+
mov edx, 13
40+
int 0x80
41+
42+
; sys_exit
43+
mov eax, 0x01
44+
mov ebx, 0
45+
int 0x80

src/kernel/entry.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void start() {
3737
cur_enable();
3838

3939
// Init memory system and make room for the kernel
40-
mem_init(0xFFFFF + 1 /* TODO: remove when fix is merged */);
40+
mem_init(0xFFFFF);
4141

4242
ginit();
4343

@@ -55,7 +55,6 @@ void start() {
5555

5656
vfs_init();
5757

58-
// for now mount /proc at /
5958
FilesystemDriver procfs;
6059
procfs_load(&procfs);
6160
vfs_mount("/proc/", &procfs);
@@ -70,7 +69,7 @@ void start() {
7069

7170
vRef root = vfs_root();
7271
vRef elf;
73-
vfs_open(&elf, &root, "/executable/elf-pic", 0);
72+
vfs_open(&elf, &root, "/executable/tiny", 0);
7473

7574
scheduler_init();
7675

src/kernel/fatfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int fatfs_open(vRef* vref, const char* basename, uint32_t flags) {
8484
// TODO: report ENOTDIR if the file is not a directory and open failed
8585
}
8686
else {
87-
const char* mode = (flags & OPEN_APPEND) ? "a" : (flags & OPEN_CREAT) ? "w" : "r";
87+
const char* mode = (flags & OPEN_APPEND) ? "a" : ((flags & OPEN_CREAT) ? "w" : "r");
8888
if (fat_fopen(&state->file, &parent_dir, basename, mode)) {
8989
state->is_dir = false;
9090
FATFS_DEBUG_LOG("fatfs: fopen success\n");

src/kernel/gdt.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "types.h"
33
#include "tables.h"
44
#include "config.h"
5+
#include "kmalloc.h"
56

67
#define EMPTY_GDT_ENTRY 0x000000000040F300
78
#define EMPTY_CODE 0x000000000040FB00
@@ -92,6 +93,6 @@ void gad(int i, uint32_t offset, uint32_t size)
9293
code = code | mask;
9394
data = data | mask;
9495

95-
gdt[i] = code;
96-
gdt[i+1] = data;
96+
gdt[i] = 0x0000FFFF00CF9B00;//code;
97+
gdt[i+1] = 0x0000FFFF00CF9300;//data;
9798
}

src/kernel/interrupt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ static void int_debug_handle(int number, int error, int* eax, int ecx, int edx,
2222
kprintf(" * EAX=%#x, EBX=%#x\n", *eax, ebx);
2323
kprintf(" * ECX=%#x, EDX=%#x\n", ecx, edx);
2424
kprintf(" * ESI=%#x, EDI=%#x\n", esi, edi);
25-
halt();
25+
26+
panic("Unregistered interrupt!");
2627
}
2728

2829
// Forward syscalls to the syscall system

src/kernel/rivendell.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static int elf_segcpy(vRef* vref, void* image, uint32_t mount, ImageSegment* seg
137137
return ELF_READ_ERROR;
138138
}
139139

140-
memset(image + address, 0, segment->mem_size);
140+
memset(image + address, 0, padding);
141141
return ELF_SUCCESS;
142142
}
143143

src/kernel/routine.asm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ isr_stub_stack:
217217

218218
; Mimic what pusha does
219219
mov edx, esp
220+
add edx, [ebp+24]
220221

221222
; First half of the 'pusha' block
222223
push dword 'SOEN' ; EAX

src/kernel/routine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern void isr_register(int interrupt, interrupt_hander handler);
3939
extern const char* isr_name(int interrupt);
4040

4141

42-
extern void* isr_stub_stack(void* stack, void* eip, uint32_t data_gdt_index, uint32_t code_gdt_index);
42+
extern void* isr_stub_stack(void* stack, void* eip, uint32_t data_gdt_index, uint32_t code_gdt_index, int virtual_offset);
4343

4444

4545
extern void isr_into_stack(void* stack);

0 commit comments

Comments
 (0)