Merge branch 'BetterTerm' of github.com:os-k-team/GNU-GPL-OS-K into BetterTerm

This commit is contained in:
Julian Barathieu 2019-03-19 13:59:16 +01:00
commit 94eccdc3d7
13 changed files with 288 additions and 149 deletions

View File

@ -124,11 +124,11 @@ $(KOBJDIR)/prog.o: $(KERNELDIR)/extras/prog.c
@echo ${CL2}[$@] ${CL}Compiled.${CL3} @echo ${CL2}[$@] ${CL}Compiled.${CL3}
# Kernel objects # Kernel objects
kal_kern_obj= $(KOBJDIR)/kernel/cpuid.o $(KOBJDIR)/kernel/init.o \ kal_kern_obj= $(KOBJDIR)/kernel/cpuid.o $(KOBJDIR)/kernel/init.o \
$(KOBJDIR)/kernel/table.o $(KOBJDIR)/kernel/cursor.o \ $(KOBJDIR)/kernel/table.o $(KOBJDIR)/kernel/cursor.o \
$(KOBJDIR)/kernel/term.o $(KOBJDIR)/kernel/vga.o \ $(KOBJDIR)/kernel/term.o $(KOBJDIR)/kernel/vga.o \
$(KOBJDIR)/kernel/panic.o $(KOBJDIR)/kernel/heap.o \ $(KOBJDIR)/kernel/panic.o $(KOBJDIR)/kernel/map.o \
$(KOBJDIR)/kernel/malloc.o $(KOBJDIR)/kernel/heap.o $(KOBJDIR)/kernel/malloc.o
$(KOBJDIR)/kernel/cpuid.o: $(KERNELDIR)/kernel/cpu/cpuid.c $(KOBJDIR)/kernel/cpuid.o: $(KERNELDIR)/kernel/cpu/cpuid.c
@$(KCC) $< -o $@ @$(KCC) $< -o $@
@ -151,6 +151,9 @@ $(KOBJDIR)/kernel/vga.o: $(KERNELDIR)/kernel/io/vga.c
$(KOBJDIR)/kernel/panic.o: $(KERNELDIR)/kernel/ke/panic.c $(KOBJDIR)/kernel/panic.o: $(KERNELDIR)/kernel/ke/panic.c
@$(KCC) $< -o $@ @$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3} @echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/kernel/map.o: $(KERNELDIR)/kernel/mm/map.c
@$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
$(KOBJDIR)/kernel/heap.o: $(KERNELDIR)/kernel/mm/heap.c $(KOBJDIR)/kernel/heap.o: $(KERNELDIR)/kernel/mm/heap.c
@$(KCC) $< -o $@ @$(KCC) $< -o $@
@echo ${CL2}[$@] ${CL}Compiled.${CL3} @echo ${CL2}[$@] ${CL}Compiled.${CL3}
@ -187,19 +190,17 @@ debug: all
install_mbr: $(BINDIR)/disk.img $(MBRDIR)/grub.cfg install_mbr: $(BINDIR)/disk.img $(MBRDIR)/grub.cfg
@mkdir -p $(BINDIR)/disk @mkdir -p $(BINDIR)/disk
@echo ${CL2}[$@] ${NC}Installing MBR on image...${CL3} @echo ${CL2}[$@] ${NC}Installing MBR on image...${CL3}
-@$(MBRDIR)/umount.sh $(BINDIR)/disk -@$(MBRDIR)/umount.sh $(BINDIR)/disk || /bin/true
@$(MBRDIR)/grub-install.sh $(BINDIR)/disk.img $(BINDIR)/disk $(MBRDIR)/grub.cfg @$(MBRDIR)/grub-install.sh $(BINDIR)/disk.img $(BINDIR)/disk $(MBRDIR)/grub.cfg
@rmdir $(BINDIR)/disk @rmdir $(BINDIR)/disk
@echo ${CL2}[$@] ${CL}Success.${CL3} @echo ${CL2}[$@] ${CL}Success.${CL3}
.PHONY: clean .PHONY: clean
clean: clean:
-@$(MBRDIR)/umount.sh $(BINDIR)/disk -@$(MBRDIR)/umount.sh $(BINDIR)/disk || /bin/true
@rm -Rvf ./ProjectTree @rm -Rvf ./ProjectTree
@rm -Rvf $(BINDIR)/*.* @rm -Rvf $(BINDIR)/* $(OBJDIR)/*.o \
@rm -Rvf $(OBJDIR)/*.o $(OBJDIR)/*/*.o $(OBJDIR)/*/*.x86_64 $(OBJDIR)/*/*/*.o
@rm -Rvf $(OBJDIR)/*/*.o
@rm -Rvf $(OBJDIR)/*/*/*.o
@echo ${CL2}[[$@]] ${CL}Cleaned.${CL3} @echo ${CL2}[[$@]] ${CL}Cleaned.${CL3}
$(BINDIR)/kaleid: $(LOBJDIR)/kaleid.x86_64 $(BINDIR)/kaleid: $(LOBJDIR)/kaleid.x86_64
@ -216,14 +217,14 @@ $(LOBJDIR)/kaleid.x86_64: $(kal_kern_obj) $(kal_com_obj) $(LOBJDIR)/loader.o
-o $(LOBJDIR)/kaleid.x86_64 -o $(LOBJDIR)/kaleid.x86_64
@echo ${CL2}[$@] ${CL}Success.${CL3} @echo ${CL2}[$@] ${CL}Success.${CL3}
$(LOBJDIR)/loader.o: $(LOADERDIR)/loader.asm $(LOBJDIR)/loader.o: $(LOADERDIR)/loader.asm $(LOADERDIR)/*/*.inc
@echo ${CL2}[$@] ${NC}Making loader...${CL3} @echo ${CL2}[$@] ${NC}Making loader...${CL3}
@$(ASM) $(ASMFLAGS) $(LOADERDIR)/loader.asm -o $(LOBJDIR)/loader.o > /dev/null @$(ASM) $(ASMFLAGS) $(LOADERDIR)/loader.asm -o $(LOBJDIR)/loader.o > /dev/null
@echo ${CL2}[$@] ${CL}Success.${CL3} @echo ${CL2}[$@] ${CL}Success.${CL3}
$(BINDIR)/disk.img: $(MBRDIR)/create_disk.sh $(BINDIR)/disk.img: $(MBRDIR)/create_disk.sh
@echo ${CL2}[$@]${NC} Constructing disk image...${CL3} @echo ${CL2}[$@]${NC} Constructing disk image...${CL3}
-@$(MBRDIR)/umount.sh $(BINDIR)/disk -@$(MBRDIR)/umount.sh $(BINDIR)/disk || /bin/true
@$(MBRDIR)/create_disk.sh $(BINDIR)/disk.img @$(MBRDIR)/create_disk.sh $(BINDIR)/disk.img
@make install_mbr @make install_mbr
@echo ${CL2}[$@]${NC} Constructing disk image...${CL3} @echo ${CL2}[$@]${NC} Constructing disk image...${CL3}
@ -232,7 +233,7 @@ $(BINDIR)/disk.img: $(MBRDIR)/create_disk.sh
OS/K: $(BINDIR)/kaleid $(BINDIR)/disk.img ./ProjectTree OS/K: $(BINDIR)/kaleid $(BINDIR)/disk.img ./ProjectTree
@mkdir -p $(BINDIR)/disk @mkdir -p $(BINDIR)/disk
@echo ${CL2}[[$@]] ${NC}Integrating kernel...${CL3} @echo ${CL2}[[$@]] ${NC}Integrating kernel...${CL3}
-@$(MBRDIR)/umount.sh $(BINDIR)/disk -@$(MBRDIR)/umount.sh $(BINDIR)/disk || /bin/true
@$(MBRDIR)/mount.sh $(BINDIR)/disk.img $(BINDIR)/disk @$(MBRDIR)/mount.sh $(BINDIR)/disk.img $(BINDIR)/disk
@cp $(BINDIR)/kaleid $(BINDIR)/disk/boot/kaleid @cp $(BINDIR)/kaleid $(BINDIR)/disk/boot/kaleid
@$(MBRDIR)/umount.sh $(BINDIR)/disk @$(MBRDIR)/umount.sh $(BINDIR)/disk

View File

@ -62,9 +62,7 @@
│   ├── atol.o │   ├── atol.o
│   ├── atoul.o │   ├── atoul.o
│   ├── atou.o │   ├── atou.o
│   ├── crtlib
│   ├── ctype.o │   ├── ctype.o
│   ├── extras
│   ├── itoa.o │   ├── itoa.o
│   ├── kernel │   ├── kernel
│   │   ├── cpuid.o │   │   ├── cpuid.o
@ -81,6 +79,7 @@
│   │   ├── ke │   │   ├── ke
│   │   │   └── panic.o │   │   │   └── panic.o
│   │   ├── malloc.o │   │   ├── malloc.o
│   │   ├── map.o
│   │   ├── panic.o │   │   ├── panic.o
│   │   ├── table.o │   │   ├── table.o
│   │   ├── term.o │   │   ├── term.o
@ -130,18 +129,17 @@
│   │   ├── kalbase.h │   │   ├── kalbase.h
│   │   ├── kaleid.h │   │   ├── kaleid.h
│   │   ├── kalext.h │   │   ├── kalext.h
│   │   ├── kernel │   │   └── kernel
│   │   │   ├── base.h │   │   ├── base.h
│   │   │   ├── cpu.h │   │   ├── cpu.h
│   │   │   ├── heap.h │   │   ├── heap.h
│   │   │   ├── iomisc.h │   │   ├── iomisc.h
│   │   │   ├── mm.h │   │   ├── mm.h
│   │   │   ├── panic.h │   │   ├── multiboot.h
│   │   │   ├── proc.h │   │   ├── panic.h
│   │   │   ├── sched.h │   │   ├── proc.h
│   │   │   └── term.h │   │   ├── sched.h
│   │   └── multiboot │   │   └── term.h
│   │   └── multiboot.h
│   └── kernel │   └── kernel
│   ├── cpu │   ├── cpu
│   │   └── cpuid.c │   │   └── cpuid.c
@ -157,7 +155,8 @@
│   │   └── panic.c │   │   └── panic.c
│   ├── mm │   ├── mm
│   │   ├── heap.c │   │   ├── heap.c
│   │   └── malloc.c │   │   ├── malloc.c
│   │   └── map.c
│   └── proc │   └── proc
│   ├── Makefile │   ├── Makefile
│   └── sched.c │   └── sched.c
@ -168,4 +167,4 @@
├── qemu.log ├── qemu.log
└── Readme.md └── Readme.md
33 directories, 110 files 30 directories, 112 files

Binary file not shown.

View File

@ -28,7 +28,6 @@
;;VIDEO ;;VIDEO
%define TRAM 0xB8000 ; [T]ext[RAM] %define TRAM 0xB8000 ; [T]ext[RAM]
%define VRAM 0xA0000 ; [V]ideo[RAM]
%define VGA_HEIGHT 80 %define VGA_HEIGHT 80
;; GLOBAL DATA ;; GLOBAL DATA
@ -38,19 +37,6 @@ VGA_X32 dq 0
VGA_HEIGHT64 dq VGA_HEIGHT VGA_HEIGHT64 dq VGA_HEIGHT
VGA_X dq 0 VGA_X dq 0
testf:
push rsi
push rbx
mov esi, teststr
mov bl, 0xF
call write
pop rsi
pop rbx
ret
teststr: db "Salut",0
;-----------------------------------------------------------------------; ;-----------------------------------------------------------------------;
; x64/LM Clear Text Screen Function ; ; x64/LM Clear Text Screen Function ;
;-----------------------------------------------------------------------; ;-----------------------------------------------------------------------;

View File

@ -32,6 +32,7 @@
%include "boot/loader/mem/structures.inc" %include "boot/loader/mem/structures.inc"
global MB_start global MB_start
global MB_header
extern StartKern extern StartKern
[BITS 32] [BITS 32]

View File

@ -42,6 +42,7 @@ typedef struct Terminal_t Terminal_t;
typedef struct ListHead_t ListHead_t; typedef struct ListHead_t ListHead_t;
typedef struct ListNode_t ListNode_t; typedef struct ListNode_t ListNode_t;
typedef struct Processor_t Processor_t; typedef struct Processor_t Processor_t;
typedef struct BootInfo_t BootInfo_t;
typedef enum ProcState_t ProcState_t; typedef enum ProcState_t ProcState_t;
typedef enum TermColor_t TermColor_t; typedef enum TermColor_t TermColor_t;
@ -61,6 +62,8 @@ typedef enum TermColor_t TermColor_t;
// Get Process_t structure of current CPU // Get Process_t structure of current CPU
#define GetCurCPU() (cpuTable[_GetCurCPU()]) #define GetCurCPU() (cpuTable[_GetCurCPU()])
//Get the BootInfo_t structure
#define GetBootInfo(x) bootTab.x
//------------------------------------------// //------------------------------------------//
// //
@ -91,11 +94,67 @@ struct Processor_t
ListHead_t *timeCritProcs; ListHead_t *timeCritProcs;
}; };
#define FB_EGA_TEXT 2
#define FB_INDEXED 0
#define FB_RGB 1
#define BINFO_SIZE 4096
struct BootInfo_t
{
// The Bootloader infos (GRUB in our case)
struct {
uint grubFlags; //flags
uint modulesCount; //mods_count
void *modulesAddr; //mods_addr
uint grubName; //boot_loader_name
void *mbHeaderAddr;
} btldr;
// Informations about drives
struct {
uint bootDrv; //boot_device
uint bufferLength; //drives_length
void *bufferAddr; //drives_addr
} drives;
// Informations about memory
struct {
//BIOS provided low and up memory
uint lowMemory; //mem_lower
uint upMemory; //mem_upper
//GRUB provided memory map
uint mapLength; //mmap_length
void *mapAddr; //mmap_addr
} memory;
// Informations about the video drive
struct {
uint vbeControl; //vbe_control_info
uint vbeModeInfo; //vbe_mode_info
ushort vbeMode; //vbe_mode
ushort vbeInterfaceSeg; //vbe_interface_seg
ushort vbeInterfaceOff; //vbe_interface_off
ushort vbeInterfaceLen; //vbe_interface_len
void* framebufferAddr; //framebuffer_addr
uint framebufferPitch; //framebuffer_pitch
uint framebufferWidth; //framebuffer_width
uint framebufferHeight; //framebuffer_height
uchar framebufferBpp; //framebuffer_bpp
uchar framebufferType; //framebuffer_type
} video;
// Informations about the microcode firmware (BIOS/EFI)
struct {
uint apmTable; //apm_table
uint romTable; //config_table
} firmware;
};
//------------------------------------------// //------------------------------------------//
extern int cpuCount; extern int cpuCount;
extern Processor_t cpuTable[NCPUS]; extern Processor_t cpuTable[NCPUS];
extern BootInfo_t bootTab;
//------------------------------------------// //------------------------------------------//
#define DEC_PER_CPU(name, field, type) \ #define DEC_PER_CPU(name, field, type) \

View File

@ -31,13 +31,6 @@
//------------------------------------------// //------------------------------------------//
void *GetMemoryMap(void);
size_t GetMemorySize(void);
size_t GetAvailZoneSize(void *);
//------------------------------------------//
#define _HEAP_START (4 * MB) #define _HEAP_START (4 * MB)
void InitHeap(void); void InitHeap(void);

View File

@ -22,3 +22,17 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. // // along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------// //----------------------------------------------------------------------------//
#include <kernel/multiboot.h>
#include <kernel/base.h>
//
// Returns a pointer to the first entry of the memory map
//
void *GetMemoryMap(void);
//
// Initializes the memory map structure
//
error_t InitMemoryMap(void);
// -------------------------------------------------------------------------- //

View File

@ -93,74 +93,74 @@
#ifndef ASM_FILE #ifndef ASM_FILE
typedef unsigned char multiboot_uint8_t; typedef unsigned char uchar;
typedef unsigned short multiboot_uint16_t; typedef unsigned short ushort;
typedef unsigned int multiboot_uint32_t; typedef unsigned int uint;
typedef unsigned long long multiboot_uint64_t; typedef unsigned long long ullong;
struct multiboot_header struct multiboot_header
{ {
/* Must be MULTIBOOT_MAGIC - see above. */ /* Must be MULTIBOOT_MAGIC - see above. */
multiboot_uint32_t magic; uint magic;
/* Feature flags. */ /* Feature flags. */
multiboot_uint32_t flags; uint flags;
/* The above fields plus this one must equal 0 mod 2^32. */ /* The above fields plus this one must equal 0 mod 2^32. */
multiboot_uint32_t checksum; uint checksum;
/* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */ /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */
multiboot_uint32_t header_addr; uint header_addr;
multiboot_uint32_t load_addr; uint load_addr;
multiboot_uint32_t load_end_addr; uint load_end_addr;
multiboot_uint32_t bss_end_addr; uint bss_end_addr;
multiboot_uint32_t entry_addr; uint entry_addr;
/* These are only valid if MULTIBOOT_VIDEO_MODE is set. */ /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */
multiboot_uint32_t mode_type; uint mode_type;
multiboot_uint32_t width; uint width;
multiboot_uint32_t height; uint height;
multiboot_uint32_t depth; uint depth;
}; };
/* The symbol table for a.out. */ /* The symbol table for a.out. */
struct multiboot_aout_symbol_table struct multiboot_aout_symbol_table
{ {
multiboot_uint32_t tabsize; uint tabsize;
multiboot_uint32_t strsize; uint strsize;
multiboot_uint32_t addr; uint addr;
multiboot_uint32_t reserved; uint reserved;
}; };
typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t; typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
/* The section header table for ELF. */ /* The section header table for ELF. */
struct multiboot_elf_section_header_table struct multiboot_elf_section_header_table
{ {
multiboot_uint32_t num; uint num;
multiboot_uint32_t size; uint size;
multiboot_uint32_t addr; uint addr;
multiboot_uint32_t shndx; uint shndx;
}; };
typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t; typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
struct multiboot_info struct multiboot_info
{ {
/* Multiboot info version number */ /* Multiboot info version number */
multiboot_uint32_t flags; uint flags;
/* Available memory from BIOS */ /* Available memory from BIOS */
multiboot_uint32_t mem_lower; uint mem_lower;
multiboot_uint32_t mem_upper; uint mem_upper;
/* "root" partition */ /* "root" partition */
multiboot_uint32_t boot_device; uint boot_device;
/* Kernel command line */ /* Kernel command line */
multiboot_uint32_t cmdline; uint cmdline;
/* Boot-Module list */ /* Boot-Module list */
multiboot_uint32_t mods_count; uint mods_count;
multiboot_uint32_t mods_addr; uint mods_addr;
union union
{ {
@ -169,54 +169,54 @@ struct multiboot_info
} u; } u;
/* Memory Mapping buffer */ /* Memory Mapping buffer */
multiboot_uint32_t mmap_length; uint mmap_length;
multiboot_uint32_t mmap_addr; uint mmap_addr;
/* Drive Info buffer */ /* Drive Info buffer */
multiboot_uint32_t drives_length; uint drives_length;
multiboot_uint32_t drives_addr; uint drives_addr;
/* ROM configuration table */ /* ROM configuration table */
multiboot_uint32_t config_table; uint config_table;
/* Boot Loader Name */ /* Boot Loader Name */
multiboot_uint32_t boot_loader_name; uint boot_loader_name;
/* APM table */ /* APM table */
multiboot_uint32_t apm_table; uint apm_table;
/* Video */ /* Video */
multiboot_uint32_t vbe_control_info; uint vbe_control_info;
multiboot_uint32_t vbe_mode_info; uint vbe_mode_info;
multiboot_uint16_t vbe_mode; ushort vbe_mode;
multiboot_uint16_t vbe_interface_seg; ushort vbe_interface_seg;
multiboot_uint16_t vbe_interface_off; ushort vbe_interface_off;
multiboot_uint16_t vbe_interface_len; ushort vbe_interface_len;
multiboot_uint64_t framebuffer_addr; ullong framebuffer_addr;
multiboot_uint32_t framebuffer_pitch; uint framebuffer_pitch;
multiboot_uint32_t framebuffer_width; uint framebuffer_width;
multiboot_uint32_t framebuffer_height; uint framebuffer_height;
multiboot_uint8_t framebuffer_bpp; uchar framebuffer_bpp;
#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0 #define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1 #define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2 #define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
multiboot_uint8_t framebuffer_type; uchar framebuffer_type;
union union
{ {
struct struct
{ {
multiboot_uint32_t framebuffer_palette_addr; uint framebuffer_palette_addr;
multiboot_uint16_t framebuffer_palette_num_colors; ushort framebuffer_palette_num_colors;
}; };
struct struct
{ {
multiboot_uint8_t framebuffer_red_field_position; uchar framebuffer_red_field_position;
multiboot_uint8_t framebuffer_red_mask_size; uchar framebuffer_red_mask_size;
multiboot_uint8_t framebuffer_green_field_position; uchar framebuffer_green_field_position;
multiboot_uint8_t framebuffer_green_mask_size; uchar framebuffer_green_mask_size;
multiboot_uint8_t framebuffer_blue_field_position; uchar framebuffer_blue_field_position;
multiboot_uint8_t framebuffer_blue_mask_size; uchar framebuffer_blue_mask_size;
}; };
}; };
}; };
@ -224,51 +224,51 @@ typedef struct multiboot_info multiboot_info_t;
struct multiboot_color struct multiboot_color
{ {
multiboot_uint8_t red; uchar red;
multiboot_uint8_t green; uchar green;
multiboot_uint8_t blue; uchar blue;
}; };
struct multiboot_mmap_entry struct multiboot_mmap_entry
{ {
multiboot_uint32_t size; uint size;
multiboot_uint64_t addr; ullong addr;
multiboot_uint64_t len; ullong len;
#define MULTIBOOT_MEMORY_AVAILABLE 1 #define MULTIBOOT_MEMORY_AVAILABLE 1
#define MULTIBOOT_MEMORY_RESERVED 2 #define MULTIBOOT_MEMORY_RESERVED 2
#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3 #define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
#define MULTIBOOT_MEMORY_NVS 4 #define MULTIBOOT_MEMORY_NVS 4
#define MULTIBOOT_MEMORY_BADRAM 5 #define MULTIBOOT_MEMORY_BADRAM 5
multiboot_uint32_t type; uint type;
} __attribute__((packed)); } __attribute__((packed));
typedef struct multiboot_mmap_entry multiboot_memory_map_t; typedef struct multiboot_mmap_entry multiboot_memory_map_t;
struct multiboot_mod_list struct multiboot_mod_list
{ {
/* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
multiboot_uint32_t mod_start; uint mod_start;
multiboot_uint32_t mod_end; uint mod_end;
/* Module command line */ /* Module command line */
multiboot_uint32_t cmdline; uint cmdline;
/* padding to take it to 16 bytes (must be zero) */ /* padding to take it to 16 bytes (must be zero) */
multiboot_uint32_t pad; uint pad;
}; };
typedef struct multiboot_mod_list multiboot_module_t; typedef struct multiboot_mod_list multiboot_module_t;
/* APM BIOS info. */ /* APM BIOS info. */
struct multiboot_apm_info struct multiboot_apm_info
{ {
multiboot_uint16_t version; ushort version;
multiboot_uint16_t cseg; ushort cseg;
multiboot_uint32_t offset; uint offset;
multiboot_uint16_t cseg_16; ushort cseg_16;
multiboot_uint16_t dseg; ushort dseg;
multiboot_uint16_t flags; ushort flags;
multiboot_uint16_t cseg_len; ushort cseg_len;
multiboot_uint16_t cseg_16_len; ushort cseg_16_len;
multiboot_uint16_t dseg_len; ushort dseg_len;
}; };
#endif /* ! ASM_FILE */ #endif /* ! ASM_FILE */

View File

@ -22,9 +22,58 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. // // along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------// //----------------------------------------------------------------------------//
#include <multiboot/multiboot.h> #include <kernel/multiboot.h>
#include <kernel/term.h> #include <kernel/term.h>
#include <kernel/panic.h> #include <kernel/panic.h>
#include <kernel/mm.h>
//
// BootInfo_t initialization. It is necessary because grub will potentially be
// wiped since it is below 1MB....
//
void InitBootInfo(multiboot_info_t *mbi)
{
KalAssert(mbi);
extern uint MB_header;
//Retrieves the bootloader informations
GetBootInfo(btldr).grubFlags = mbi->flags;
GetBootInfo(btldr).grubName = (mbi->boot_loader_name);
GetBootInfo(btldr).modulesCount = mbi->mods_count;
GetBootInfo(btldr).modulesAddr = (void*)(ullong)mbi->mods_addr;
GetBootInfo(btldr).mbHeaderAddr = (void*)(ullong)&MB_header;
DebugLog("\n[InitBootInfo] %s\n", GetBootInfo(btldr).grubName);
DebugLog("[InitBootInfo] Header address : %p, modules address : %p\n",
GetBootInfo(btldr).mbHeaderAddr, GetBootInfo(btldr).modulesAddr);
DebugLog("[InitBootInfo] GRUB flags : %x\n", GetBootInfo(btldr).grubFlags);
//Retrieves the drives informations
GetBootInfo(drives).bootDrv = mbi->boot_device;
GetBootInfo(drives).bufferLength = mbi->drives_length;
GetBootInfo(drives).bufferAddr = (void*)(ullong)mbi->drives_addr;
DebugLog("[InitBootInfo] Root drive : %x\n",
GetBootInfo(drives).bootDrv);
//Retrieves the memory informations
GetBootInfo(memory).lowMemory = mbi->mem_lower;
GetBootInfo(memory).upMemory = mbi->mem_upper;
GetBootInfo(memory).mapAddr = (void*)(ullong)mbi->mmap_addr;
GetBootInfo(memory).mapLength = mbi->mmap_length;
DebugLog("[InitBootInfo] Low memory : %d Kio, Up memory : %d Mio\n",
GetBootInfo(memory).lowMemory, GetBootInfo(memory).upMemory / (MB/KB));
DebugLog("[InitBootInfo] Memory map address : %p, length : %d\n",
GetBootInfo(memory).mapAddr, GetBootInfo(memory).mapLength);
// XXX assign video infos, but unused at this time
// Retrieves the firmware infos
GetBootInfo(firmware).apmTable = mbi->apm_table;
GetBootInfo(firmware).romTable = mbi->config_table;
DebugLog("[InitBootInfo] APM Table : %p, ROM Table : %p\n",
GetBootInfo(firmware).apmTable, GetBootInfo(firmware).romTable);
}
// //
// Entry point of the Kaleid kernel // Entry point of the Kaleid kernel
@ -37,23 +86,19 @@ noreturn void StartKern(multiboot_info_t *mbInfo, int mbMagic)
// Kernel terminals // Kernel terminals
InitTerms(); InitTerms();
KernLog( "We were loaded by : %s\n\n" //Hello world because why not
"We get\n" KernLog("%c%c%c OS/K\n\n", 219, 219, 219);
" *mbInfo : %p\n"
" mbMagic : %x\n"
" mbBootdrv : %x\n"
" *mbMmap : %p\n"
" `-length : %d\n"
"\nGoodbye World :(",
mbInfo->boot_loader_name, KalAlwaysAssert(mbMagic == MULTIBOOT_BOOTLOADER_MAGIC);
mbInfo, KernLog("[Init] We have magic : %x\n", mbMagic);
mbMagic,
mbInfo->boot_device,
mbInfo->mmap_addr,
mbInfo->mmap_length
);
// Get out //Initialize the BootInfo_t structure
CrashSystem(); InitBootInfo(mbInfo);
}
//Memory mapping
InitMemoryMap();
// We're out
KernLog("\n[Init] Evil never dies !");
CrashSystem(); //yay
}

View File

@ -27,6 +27,8 @@
int cpuCount = 1; int cpuCount = 1;
Processor_t cpuTable[NCPUS] = {0}; Processor_t cpuTable[NCPUS] = {0};
BootInfo_t bootTab = {0}
Terminal_t *StdOut = 0, *StdDbg = 0; Terminal_t *StdOut = 0, *StdDbg = 0;
volatile char *PanicStr = 0; volatile char *PanicStr = 0;
Terminal_t *stdOut = 0, *stdDbg = 0;

View File

@ -66,5 +66,6 @@ error_t KalAllocMemory(void **ptr, size_t req, int flags, size_t align)
error_t KalFreeMemory(void *ptr) error_t KalFreeMemory(void *ptr)
{ {
(void)ptr; (void)ptr;
return 0;
} }

38
kaleid/kernel/mm/map.c Normal file
View File

@ -0,0 +1,38 @@
//----------------------------------------------------------------------------//
// GNU GPL OS/K //
// //
// Desc: //
// //
// //
// Copyright © 2018-2019 The OS/K Team //
// //
// This file is part of OS/K. //
// //
// OS/K is free software: you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation, either version 3 of the License, or //
// any later version. //
// //
// OS/K is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY//without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <kernel/mm.h>
#include <kernel/term.h>
error_t InitMemoryMap(void)
{
///uint MapIsValid = (GetBootInfo(btldr).grubFlags & MULTIBOOT_INFO_MEM_MAP = MULTIBOOT_INFO_MEM_MAP ? 1 : 0);
KalAlwaysAssert(MapIsValid);
return EOK;
}
void *GetMemoryMap(void)
{
return (void*)0;
}