feat: première compilation de noyau composite sans l'intégration de la décompression du noyau

This commit is contained in:
Nicolas Hordé 2019-01-02 15:47:56 +01:00
parent e30592d7d4
commit 9da86c9057
9 changed files with 46 additions and 21 deletions

View File

@ -36,7 +36,7 @@
#define SEG_NORMAL 0b00010000 /* Segment normal pile/data/code (0 pour système) */
#ifndef _ASSEMBLY
#ifndef __ASSEMBLY__
#include "types.h"

View File

@ -63,7 +63,7 @@
# define setCR3(addr) \
asm volatile ("mov %[memaddr], %%eax; mov %%eax, %%cr3"::[memaddr] "m" (addr) );
#ifndef _ASSEMBLY
#ifndef __ASSEMBLY__
#include "types.h"
#include "queue.h"

View File

@ -3,6 +3,8 @@
/* */
#include "types.h"
#define E820_MAX_ENTRIES 128
typedef struct entrye820 {
u64 addr;
u64 size;

View File

@ -1,5 +1,5 @@
GCC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -Wall -w -I ../include -m32 -fno-pie -no-pie -c -o
ASM=gcc -nostdinc -ffreestanding -fno-builtin -m32 -c -fno-pie -no-pie -I ../include -c -o
ASM=gcc -nostdinc -ffreestanding -fno-builtin -m32 -c -fno-pie -no-pie -I ../include -D__ASSEMBLY__ -c -o
LINK=ld -m elf_i386 -n
CONVERT=dos2unix
INDENT=indent -nhnl -l75 -ppi3 -ts8 -bls -nbc -di8 -nbad -nbap -nsob -i8 -bl -bli0 -ncdw -nce -cli8 -cbi0 -npcs -cs -saf -sai -saw -nprs -lp -npsl
@ -11,16 +11,18 @@ OBJDEBUG=objcopy --only-keep-debug
ZOFFSET=sed -n -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|_end\|_ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p'
VOFFSET=sed -n -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(_text\|__bss_start\|_end\)$$/\#define VO_\2 _AC(0x\1,UL)/p'
COMP=gzip -9 -f
BUILD=../tools/build
MKPIGGY=../tools/mkpiggy
all: system.sys
system.sys: system.tmp
$(OBJCOPY) $^ $@
system.tmp: piggy.o voffset.h zoffset.h realmode/setup.bin
tools/build realmode/setup.bin system.bin zoffset.h system.tmp
system.sys: piggy.o voffset.h zoffset.h realmode/setup.bin
$(BUILD) realmode/setup.bin system.bin zoffset.h system.sys
sync
allpiggy.o: piggy.o decompress.o header.o
$(LINK) -T allpiggy piggy.o decompress.o header.o
voffset.h: system
$(NM) system|$(VOFFSET)>voffset.h
@ -44,7 +46,7 @@ system.bin.gz: system.bin
cat $^|$(COMP) > $@
piggy.S: system.bin.gz
../tools/mkpiggy $^ > $@
$(MKPIGGY) $^ > $@
realmode/setup.bin:
make -C realmode

View File

@ -1,5 +1,5 @@
GCC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -Wall -w -I ../../include -m16 -fomit-frame-pointer -fno-pic -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387 -c -o
ASM=gcc -nostdinc -ffreestanding -fno-builtin -m16 -fomit-frame-pointer -fno-pic -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387 -I ../ -I ../../include -c -o
GCC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -Wall -w -I ../../include -m16 -fomit-frame-pointer -fno-pie -no-pie -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387 -c
ASM=gcc -m16 -fomit-frame-pointer -fno-pie -no-pie -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387 -D__ASSEMBLY__ -I ../ -I ../../include -c -o
LINK=ld -m elf_i386 -n
CONVERT=dos2unix
INDENT=indent -nhnl -l75 -ppi3 -ts8 -bls -nbc -di8 -nbad -nbap -nsob -i8 -bl -bli0 -ncdw -nce -cli8 -cbi0 -npcs -cs -saf -sai -saw -nprs -lp -npsl
@ -8,6 +8,7 @@ CHANGEPERM=chmod 644
NM=nm
OBJCOPY=objcopy -O binary -R .note -R .comment -S
OBJDEBUG=objcopy --only-keep-debug
$(eval VERSION=$(shell git describe --tags))
all: setup.bin
sync
@ -21,7 +22,7 @@ setup.bin: setup
$(NM) setup > setup.map
setupc.o: setup.c
$(GCC) $@ $^
$(GCC) -DVERSION=$(VERSION) -o $@ $^
setup.o: setup.S
$(ASM) $@ $^

View File

@ -21,6 +21,19 @@
#include "zoffset.h"
#define __AC(X, Y) (X##Y)
#define _AC(X, Y) __AC(X,Y)
#define ROOT_RDONLY 1
#define LOADED_HIGH 1
#define SVGA_MODE 0
#define CONFIG_PHYSICAL_ALIGN 0x100000
#define MIN_KERNEL_ALIGN_LG2 4
#define COMMAND_LINE_SIZE 512
#define LOAD_PHYSICAL_ADDR 0x100000
/* loadflags */
#define LOADED_HIGH_FLAG (1<<0)
#define KASLR_FLAG (1<<1)
#define QUIET_FLAG (1<<5)
#define KEEP_SEGMENTS (1<<6)
#define CAN_USE_HEAP (1<<7)
SEGBOOT = 0x07C0
SEGSYS = 0x1000
@ -353,7 +366,7 @@ setup:
# Setup corrupt somehow...
setup_bad:
movl $setup_corrupt, %eax
calll puts
calll showstr
# Fall through...
.globl die

View File

@ -8,7 +8,7 @@
#include "memory.h"
struct params {
entrye820 *e820_table;
entrye820 e820_table[E820_MAX_ENTRIES];
u32 e820_numbers;
u8 kbflag;
} params;
@ -19,8 +19,16 @@ static struct gdtr gdtreg;
/* table de GDT */
static gdtdes gdt[GDT_SIZE];
#define STRINGIFY(x) #x
#define MACRO(x) STRINGIFY(x)
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
u8 kernel_version[] = "COS2000 Version " MACRO(VERSION) "- compiled " __DATE__ ;
#define EFLAGS_CF 0x00000001
#define CR0_PE 0x00000001
#define LOOPS_8042 100000
#define FF_8042 32
#define LOOPS_A20_ENABLE 255
@ -135,7 +143,7 @@ u8 empty8042(void)
return NULL;
}
if (status & 1) {
io_delay();
iodelay();
(void)inb(0x60);
} else if (!(status & 2)) {
return 1;
@ -252,7 +260,7 @@ void memcpy(void *src, void *dst, u32 count, u32 size)
void initselectors(u32 executingoffset)
{
asm(" movl %%cr0, %%eax \n \
orb $CR0_PE, %%eax \n \
orb $0x00000001, %%eax \n \
movl %%eax, %%cr0 \n \
ljmp %[code], $raz\n\
raz:\n \
@ -319,7 +327,7 @@ void maskinterrupts(void)
outb(0x80, 0x70); /* Disable NMI */
iodelay();
outb(0xff, 0xa1); /* Mask all interrupts on the secondary PIC */
idelay();
iodelay();
outb(0xfb, 0x21); /* Mask all but cascade on the primary PIC */
iodelay();
}
@ -336,7 +344,7 @@ void initpmode(u32 offset)
{
if (enableA20()) {
showstr("impossible d'ouvrir la ligne A20...\n");
hlt();
halt();
}
maskinterrupts();
initgdt();

View File

@ -2,8 +2,6 @@
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
/* */
#define _ASSEMBLY
#include "memory.h"
#include "gdt.h"

View File

@ -8,6 +8,7 @@ SECTIONS
{
. = 0x100000;
.text ALIGN(16): {
_text = .;
*(.text)
}
.data ALIGN(16): {