mirror of
https://github.com/tailix/kernel.git
synced 2025-10-09 23:14:08 -04:00
Rewrite modules with C
This commit is contained in:
parent
a734782062
commit
878250df98
6 changed files with 52 additions and 44 deletions
|
@ -6,13 +6,15 @@ CC = $(CCPREFIX)gcc
|
||||||
|
|
||||||
MEMGR = memgr
|
MEMGR = memgr
|
||||||
|
|
||||||
|
CFLAGS = -std=gnu99 -ffreestanding -nostdinc -fno-builtin -fno-stack-protector -Wall -Wextra
|
||||||
|
|
||||||
all: $(MEMGR)
|
all: $(MEMGR)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(MEMGR) main.o
|
rm -f $(MEMGR) start.o
|
||||||
|
|
||||||
$(MEMGR): main.o
|
$(MEMGR): start.o
|
||||||
$(CC) -T linker.ld -o $@ -ffreestanding -nostdlib -lgcc $^
|
$(CC) -T linker.ld -o $@ -ffreestanding -nostdlib -lgcc $^
|
||||||
|
|
||||||
main.o: main.asm
|
start.o: start.c
|
||||||
nasm -f elf32 $< -o $@
|
$(CC) -c $< -o $@ $(CFLAGS)
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[GLOBAL _start]
|
|
||||||
|
|
||||||
_start:
|
|
||||||
xor eax, eax
|
|
||||||
xor ebx, ebx
|
|
||||||
int 0x80
|
|
8
memgr/start.c
Normal file
8
memgr/start.c
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
void _start()
|
||||||
|
{
|
||||||
|
asm(
|
||||||
|
"mov $0, %eax \n\t"
|
||||||
|
"mov $0, %ebx \n\t"
|
||||||
|
"int $0x80 \n\t"
|
||||||
|
);
|
||||||
|
}
|
|
@ -6,13 +6,15 @@ CC = $(CCPREFIX)gcc
|
||||||
|
|
||||||
PROCMAN = procman
|
PROCMAN = procman
|
||||||
|
|
||||||
|
CFLAGS = -std=gnu99 -ffreestanding -nostdinc -fno-builtin -fno-stack-protector -Wall -Wextra
|
||||||
|
|
||||||
all: $(PROCMAN)
|
all: $(PROCMAN)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(PROCMAN) main.o
|
rm -f $(PROCMAN) start.o
|
||||||
|
|
||||||
$(PROCMAN): main.o
|
$(PROCMAN): start.o
|
||||||
$(CC) -T linker.ld -o $@ -ffreestanding -nostdlib -lgcc $^
|
$(CC) -T linker.ld -o $@ -ffreestanding -nostdlib -lgcc $^
|
||||||
|
|
||||||
main.o: main.asm
|
start.o: start.c
|
||||||
nasm -f elf32 $< -o $@
|
$(CC) -c $< -o $@ $(CFLAGS)
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
[GLOBAL _start]
|
|
||||||
|
|
||||||
_start:
|
|
||||||
xor eax, eax
|
|
||||||
xor ebx, ebx
|
|
||||||
int 0x80
|
|
||||||
|
|
||||||
xor eax, eax
|
|
||||||
mov ebx, 1
|
|
||||||
int 0x80
|
|
||||||
|
|
||||||
mov eax, 1
|
|
||||||
xor ebx, ebx
|
|
||||||
int 0x80
|
|
||||||
|
|
||||||
mov eax, 2
|
|
||||||
xor ebx, ebx
|
|
||||||
int 0x80
|
|
||||||
|
|
||||||
mov eax, 256
|
|
||||||
xor ebx, ebx
|
|
||||||
int 0x80
|
|
||||||
|
|
||||||
mov eax, 257
|
|
||||||
xor ebx, ebx
|
|
||||||
int 0x80
|
|
||||||
|
|
||||||
mov eax, 258
|
|
||||||
xor ebx, ebx
|
|
||||||
int 0x80
|
|
32
procman/start.c
Normal file
32
procman/start.c
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
void _start()
|
||||||
|
{
|
||||||
|
asm(
|
||||||
|
"mov $0, %eax \n\t"
|
||||||
|
"mov $0, %ebx \n\t"
|
||||||
|
"int $0x80 \n\t"
|
||||||
|
|
||||||
|
"mov $0, %eax \n\t"
|
||||||
|
"mov $1, %ebx \n\t"
|
||||||
|
"int $0x80 \n\t"
|
||||||
|
|
||||||
|
"mov $1, %eax \n\t"
|
||||||
|
"mov $0, %ebx \n\t"
|
||||||
|
"int $0x80 \n\t"
|
||||||
|
|
||||||
|
"mov $2, %eax \n\t"
|
||||||
|
"mov $0, %ebx \n\t"
|
||||||
|
"int $0x80 \n\t"
|
||||||
|
|
||||||
|
"mov $256, %eax \n\t"
|
||||||
|
"mov $0, %ebx \n\t"
|
||||||
|
"int $0x80 \n\t"
|
||||||
|
|
||||||
|
"mov $257, %eax \n\t"
|
||||||
|
"mov $0, %ebx \n\t"
|
||||||
|
"int $0x80 \n\t"
|
||||||
|
|
||||||
|
"mov $258, %eax \n\t"
|
||||||
|
"mov $0, %ebx \n\t"
|
||||||
|
"int $0x80 \n\t"
|
||||||
|
);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue