1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-11-20 11:16:10 -05:00

Remove modules

This commit is contained in:
Alex Kotov 2022-06-25 13:49:33 +03:00
parent 791cf9cd3d
commit 7f25b96a2b
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
12 changed files with 3 additions and 281 deletions

View file

@ -3,10 +3,8 @@ ROOTFS = rootfs
GRUBCFG = $(ROOTFS)/boot/grub/grub.cfg GRUBCFG = $(ROOTFS)/boot/grub/grub.cfg
KERNEL = $(ROOTFS)/boot/tailix.multiboot2 KERNEL = $(ROOTFS)/boot/tailix.multiboot2
PROCMAN = $(ROOTFS)/boot/procman
MEMGR = $(ROOTFS)/boot/memgr
.PHONY: kernel/tailix.multiboot2 procman/procman memgr/memgr .PHONY: kernel/tailix.multiboot2
all: run0 all: run0
@ -17,28 +15,14 @@ run1: $(IMAGE)
qemu-system-i386 -cdrom $< -serial stdio qemu-system-i386 -cdrom $< -serial stdio
clean: clean:
rm -f $(IMAGE) $(KERNEL) $(PROCMAN) $(MEMGR) rm -f $(IMAGE) $(KERNEL)
make -C kernel clean make -C kernel clean
make -C procman clean
make -C memgr clean
$(IMAGE): $(GRUBCFG) $(KERNEL) $(PROCMAN) $(MEMGR) $(IMAGE): $(GRUBCFG) $(KERNEL)
grub-mkrescue $(ROOTFS) -o $@ grub-mkrescue $(ROOTFS) -o $@
$(KERNEL): kernel/tailix.multiboot2 $(KERNEL): kernel/tailix.multiboot2
cp $< $@ cp $< $@
$(PROCMAN): procman/procman
cp $< $@
$(MEMGR): memgr/memgr
cp $< $@
kernel/tailix.multiboot2: kernel/tailix.multiboot2:
make -C kernel tailix.multiboot2 make -C kernel tailix.multiboot2
procman/procman:
make -C procman procman
memgr/memgr:
make -C memgr memgr

View file

@ -1,104 +0,0 @@
#ifndef KERNEL_INCLUDED_ELF
#define KERNEL_INCLUDED_ELF 1
#ifdef __cplusplus
extern "C" {
#endif
struct Kernel_ELF_Header {
unsigned char magic_0x7F : 8; // Must be 0x7F.
unsigned char magic_E : 8; // Must be 'E'.
unsigned char magic_L : 8; // Must be 'L'.
unsigned char magic_F : 8; // Must be 'F'.
unsigned char bitness : 8; // Must be 1 (32 bit).
unsigned char endianness : 8; // Must be 1 (little endian).
unsigned char header_version : 8; // Must be 1.
unsigned char os_abi : 8; // Must be 0 (System V).
unsigned long unused1 : 32;
unsigned long unused2 : 32;
unsigned short obj_type : 16; // Must be 2 (executable).
unsigned short isa : 16; // Must be 3 (x86).
unsigned long elf_version : 32; // Must be 1.
unsigned long entrypoint : 32;
unsigned long prog_table_pos : 32; // Must not be 0.
unsigned long sect_table_pos : 32;
unsigned long arch_flags : 32; // Must be 0.
unsigned short header_size : 16; // Must be 52.
unsigned short prog_entr_size : 16; // Must not be 0.
unsigned short prog_entr_num : 16; // Must not be 0.
unsigned short sect_entr_size : 16;
unsigned short sect_entr_num : 16;
unsigned short sect_names_idx : 16;
}
__attribute__((packed));
struct Kernel_ELF_ProgramEntry {
unsigned long type : 32;
unsigned long offset : 32;
unsigned long virt_addr : 32;
unsigned long phys_addr : 32;
unsigned long file_size : 32;
unsigned long mem_size : 32;
unsigned long flags : 32;
unsigned long align : 32;
}
__attribute__((packed));
struct Kernel_ELF_SectionEntry {
unsigned long name : 32;
unsigned long type : 32;
unsigned long flags : 32;
unsigned long vaddr : 32;
unsigned long file_offset : 32;
unsigned long file_size : 32;
unsigned long link : 32;
unsigned long info : 32;
unsigned long alignment : 32;
unsigned long ent_size : 32;
}
__attribute__((packed));
struct Kernel_ELF_RelocationEntry {
unsigned long virt_addr : 32;
unsigned long info : 32;
}
__attribute__((packed));
typedef struct Kernel_ELF_ProgramEntry Kernel_ELF_ProgramTable[];
typedef struct Kernel_ELF_SectionEntry Kernel_ELF_SectionTable[];
typedef struct Kernel_ELF_RelocationEntry Kernel_ELF_RelocationTable[];
inline static unsigned char Kernel_ELF_Header_is_valid(
const struct Kernel_ELF_Header *header
);
unsigned char Kernel_ELF_Header_is_valid(
const struct Kernel_ELF_Header *const header
) {
return (
header->magic_0x7F == 0x7F &&
header->magic_E == 'E' &&
header->magic_L == 'L' &&
header->magic_F == 'F' &&
header->bitness == 1 &&
header->endianness == 1 &&
header->header_version == 1 &&
header->os_abi == 0 &&
header->obj_type == 2 &&
header->isa == 3 &&
header->elf_version == 1 &&
header->arch_flags == 0 &&
header->header_size == 52 &&
header->prog_table_pos != 0 &&
header->prog_entr_size != 0 &&
header->prog_entr_num != 0
);
}
#ifdef __cplusplus
}
#endif
#endif

View file

@ -6,7 +6,6 @@
#include "protected.h" #include "protected.h"
#include "tasks.h" #include "tasks.h"
#include "elf.h"
#include <kernaux/drivers/console.h> #include <kernaux/drivers/console.h>
#include <kernaux/multiboot2.h> #include <kernaux/multiboot2.h>
@ -72,19 +71,4 @@ void main(
protected_initialize(&kinfo); protected_initialize(&kinfo);
kernaux_drivers_console_print("[INFO] main: Finished.\n"); kernaux_drivers_console_print("[INFO] main: Finished.\n");
if (kinfo.modules_count > 0) {
const struct Kernel_ELF_Header *const elf_header =
(void*)kinfo.modules[0].base;
if (Kernel_ELF_Header_is_valid(elf_header)) {
const unsigned long real_entrypoint =
kinfo.modules[0].base + elf_header->entrypoint;
tasks_switch_to_user(real_entrypoint);
}
else {
kernaux_drivers_console_print("[WARN] main: Invalid ELF header.\n");
}
}
} }

1
memgr/.gitignore vendored
View file

@ -1 +0,0 @@
/memgr

View file

@ -1,20 +0,0 @@
CCPREFIX = /home/kotovalexarian/repos/global/tailix/cross/root/bin/i386-elf-
AS = $(CCPREFIX)as
CC = $(CCPREFIX)gcc
LD = $(CCPREFIX)ld
MEMGR = memgr
CFLAGS = -std=gnu99 -ffreestanding -nostdinc -fno-builtin -fno-stack-protector -Wall -Wextra
all: $(MEMGR)
clean:
rm -f $(MEMGR) start.o
$(MEMGR): start.o
$(LD) -o $@ -T linker.ld $^
start.o: start.c
$(CC) -c $< -o $@ $(CFLAGS)

View file

@ -1,29 +0,0 @@
OUTPUT_ARCH("i386")
OUTPUT_FORMAT("elf32-i386")
ENTRY(_start)
SECTIONS
{
. = 0x0;
.text BLOCK(4K) : ALIGN(4K)
{
*(.text)
}
.rodata BLOCK(4K) : ALIGN(4K)
{
*(.rodata)
}
.data BLOCK(4K) : ALIGN(4K)
{
*(.data)
}
.bss BLOCK(4K) : ALIGN(4K)
{
*(COMMON)
*(.bss)
}
}

View file

@ -1,8 +0,0 @@
void _start()
{
asm(
"mov $0, %eax \n\t"
"mov $0, %ebx \n\t"
"int $0x80 \n\t"
);
}

1
procman/.gitignore vendored
View file

@ -1 +0,0 @@
/procman

View file

@ -1,20 +0,0 @@
CCPREFIX = /home/kotovalexarian/repos/global/tailix/cross/root/bin/i386-elf-
AS = $(CCPREFIX)as
CC = $(CCPREFIX)gcc
LD = $(CCPREFIX)ld
PROCMAN = procman
CFLAGS = -std=gnu99 -ffreestanding -nostdinc -fno-builtin -fno-stack-protector -Wall -Wextra
all: $(PROCMAN)
clean:
rm -f $(PROCMAN) start.o
$(PROCMAN): start.o
$(LD) -o $@ -T linker.ld $^
start.o: start.c
$(CC) -c $< -o $@ $(CFLAGS)

View file

@ -1,29 +0,0 @@
OUTPUT_ARCH("i386")
OUTPUT_FORMAT("elf32-i386")
ENTRY(_start)
SECTIONS
{
. = 0x0;
.text BLOCK(4K) : ALIGN(4K)
{
*(.text)
}
.rodata BLOCK(4K) : ALIGN(4K)
{
*(.rodata)
}
.data BLOCK(4K) : ALIGN(4K)
{
*(.data)
}
.bss BLOCK(4K) : ALIGN(4K)
{
*(COMMON)
*(.bss)
}
}

View file

@ -1,32 +0,0 @@
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"
);
}

View file

@ -2,6 +2,4 @@ set timeout=0
menuentry "Tailix" { menuentry "Tailix" {
multiboot2 /boot/tailix.multiboot2 hello kernel multiboot2 /boot/tailix.multiboot2 hello kernel
module2 /boot/procman hello module
module2 /boot/memgr
} }