Renaming & restructuration
This commit is contained in:
parent
dc1cfa6151
commit
feee90c3d0
87
Makefile
87
Makefile
|
@ -33,7 +33,7 @@ ASMFLAGS=-f elf64
|
|||
LDFLAGS=-melf_x86_64
|
||||
COPTIM=-O2
|
||||
CWARNS=-Wall -Wextra -Werror=implicit-function-declaration
|
||||
CINCLUDES=-Ikaleid/include
|
||||
CINCLUDES=-Iinclude
|
||||
CFLAGS1=-nostdlib -ffreestanding -mcmodel=large -std=gnu11
|
||||
CFLAGS2= -c -g -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -fno-strict-aliasing
|
||||
CFLAGS=$(CFLAGS1) $(CFLAGS2)
|
||||
|
@ -42,7 +42,8 @@ KCC=$(CCNAME) $(COPTIM) $(CWARNS) $(CFLAGS) $(CINCLUDES) -D_OSK_SOURCE -D_KALEID
|
|||
#Folders
|
||||
MBRDIR=boot/grub
|
||||
LOADERDIR=boot/loader
|
||||
KERNELDIR=kaleid
|
||||
KALEIDDIR=kaleid
|
||||
INCLUDEDIR=include
|
||||
OBJDIR=build/obj
|
||||
KOBJDIR=build/obj/kaleid
|
||||
LOBJDIR=build/obj/boot
|
||||
|
@ -55,7 +56,6 @@ CL2='\033[1;36m'
|
|||
CL3='\033[0m'
|
||||
NC='\033[1;37m'
|
||||
|
||||
|
||||
.PHONY: all
|
||||
all : OS/K
|
||||
|
||||
|
@ -72,55 +72,66 @@ kal_com_obj= $(KOBJDIR)/atoi.o $(KOBJDIR)/ctype.o \
|
|||
$(KOBJDIR)/utoa.o $(KOBJDIR)/ltoa.o \
|
||||
$(KOBJDIR)/ultoa.o
|
||||
|
||||
$(KOBJDIR)/atoi.o: $(KERNELDIR)/crtlib/atoi.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/atoi.o: $(KALEIDDIR)/libc/atoi.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) -D_NEED_ATOI $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/atol.o: $(KERNELDIR)/crtlib/atoi.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/atol.o: $(KALEIDDIR)/libc/atoi.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) -D_NEED_ATOL $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/atou.o: $(KERNELDIR)/crtlib/atoi.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/atou.o: $(KALEIDDIR)/libc/atoi.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) -D_NEED_ATOU $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/atoul.o: $(KERNELDIR)/crtlib/atoi.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/atoul.o: $(KALEIDDIR)/libc/atoi.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) -D_NEED_ATOUL $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/ctype.o: $(KERNELDIR)/crtlib/ctype.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/ctype.o: $(KALEIDDIR)/libc/ctype.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/itoa.o: $(KERNELDIR)/crtlib/itoa.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/itoa.o: $(KALEIDDIR)/libc/itoa.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) -D_NEED_ITOA $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/ltoa.o: $(KERNELDIR)/crtlib/itoa.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/ltoa.o: $(KALEIDDIR)/libc/itoa.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) -D_NEED_LTOA $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/utoa.o: $(KERNELDIR)/crtlib/itoa.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/utoa.o: $(KALEIDDIR)/libc/itoa.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) -D_NEED_UTOA $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/ultoa.o: $(KERNELDIR)/crtlib/itoa.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/ultoa.o: $(KALEIDDIR)/libc/itoa.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) -D_NEED_ULTOA $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/mem.o: $(KERNELDIR)/crtlib/mem.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/mem.o: $(KALEIDDIR)/libc/mem.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) -fno-strict-aliasing $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/rand.o: $(KERNELDIR)/crtlib/rand.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/rand.o: $(KALEIDDIR)/libc/rand.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/sprintf.o: $(KERNELDIR)/crtlib/sprintf.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/sprintf.o: $(KALEIDDIR)/libc/sprintf.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/status.o: $(KERNELDIR)/crtlib/status.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/status.o: $(KALEIDDIR)/libc/status.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/string.o: $(KERNELDIR)/crtlib/string.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/string.o: $(KALEIDDIR)/libc/string.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/strtol.o: $(KERNELDIR)/crtlib/strtol.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/strtol.o: $(KALEIDDIR)/libc/strtol.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/argv.o: $(KERNELDIR)/extras/argv.c $(KERNELDIR)/include/*/*.h
|
||||
|
||||
$(KOBJDIR)/argv.o: $(KALEIDDIR)/extras/argv.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/prog.o: $(KERNELDIR)/extras/prog.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/prog.o: $(KALEIDDIR)/extras/prog.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
|
||||
$(KOBJDIR)/kernel/buf.o: $(KALEIDDIR)/libbuf/buf.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/kernel/bput.o: $(KALEIDDIR)/libbuf/bput.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/kernel/bprint.o: $(KALEIDDIR)/libbuf/bprint.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
|
||||
|
@ -134,51 +145,42 @@ kal_kern_obj= $(KOBJDIR)/kernel/cpuid.o $(KOBJDIR)/kernel/init.o \
|
|||
$(KOBJDIR)/kernel/bput.o $(KOBJDIR)/kernel/bprint.o \
|
||||
$(KOBJDIR)/kernel/gdt.o
|
||||
|
||||
$(KOBJDIR)/kernel/cpuid.o: $(KERNELDIR)/kernel/cpu/cpuid.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/kernel/cpuid.o: $(KALEIDDIR)/kernel/cpu/cpuid.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/kernel/idt.o: $(KERNELDIR)/kernel/cpu/idt.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/kernel/idt.o: $(KALEIDDIR)/kernel/cpu/idt.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/kernel/init.o: $(KERNELDIR)/kernel/init/init.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/kernel/init.o: $(KALEIDDIR)/kernel/init/init.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/kernel/table.o: $(KERNELDIR)/kernel/init/table.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/kernel/table.o: $(KALEIDDIR)/kernel/init/table.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/kernel/cursor.o: $(KERNELDIR)/kernel/io/cursor.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/kernel/cursor.o: $(KALEIDDIR)/kernel/io/cursor.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/kernel/log.o: $(KERNELDIR)/kernel/ke/log.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/kernel/log.o: $(KALEIDDIR)/kernel/ke/log.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/kernel/vga.o: $(KERNELDIR)/kernel/io/vga.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/kernel/vga.o: $(KALEIDDIR)/kernel/io/vga.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/kernel/panic.o: $(KERNELDIR)/kernel/ke/panic.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/kernel/panic.o: $(KALEIDDIR)/kernel/ke/panic.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/kernel/map.o: $(KERNELDIR)/kernel/mm/map.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/kernel/map.o: $(KALEIDDIR)/kernel/mm/map.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/kernel/heap.o: $(KERNELDIR)/kernel/mm/heap.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/kernel/heap.o: $(KALEIDDIR)/kernel/mm/heap.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/kernel/malloc.o: $(KERNELDIR)/kernel/mm/malloc.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/kernel/malloc.o: $(KALEIDDIR)/kernel/mm/malloc.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
$(KOBJDIR)/kernel/gdt.o: $(KERNELDIR)/kernel/mm/gdt.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/kernel/gdt.o: $(KALEIDDIR)/kernel/mm/gdt.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/kernel/buf.o: $(KERNELDIR)/kernel/buf/buf.c $(KERNELDIR)/include/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/kernel/bput.o: $(KERNELDIR)/kernel/buf/bput.c $(KERNELDIR)/include/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/kernel/bprint.o: $(KERNELDIR)/kernel/buf/bprint.c $(KERNELDIR)/include/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
$(KOBJDIR)/kernel/sched.o: $(KERNELDIR)/kernel/ps/sched.c $(KERNELDIR)/include/*/*.h
|
||||
$(KOBJDIR)/kernel/sched.o: $(KALEIDDIR)/kernel/ps/sched.c $(INCLUDEDIR)/*/*.h
|
||||
@$(KCC) $< -o $@
|
||||
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
|
||||
|
||||
|
@ -189,6 +191,7 @@ $(KOBJDIR)/kernel/sched.o: $(KERNELDIR)/kernel/ps/sched.c $(KERNELDIR)/include/*
|
|||
@echo "\n" >> ./ProjectTree
|
||||
@tree --dirsfirst >> ./ProjectTree
|
||||
@echo ${CL2}[$@] ${CL}Generated.${CL3}
|
||||
|
||||
## MAIN MAKEFILE ------------------------------------------------------------- #
|
||||
|
||||
.PHONY: test
|
||||
|
|
130
ProjectTree
130
ProjectTree
|
@ -89,82 +89,82 @@
|
|||
│ │ ├── ultoa.o
|
||||
│ │ └── utoa.o
|
||||
│ ├── grub.log
|
||||
│ └── kernel.ld
|
||||
│ ├── kernel.ld
|
||||
│ └── qemu.log
|
||||
├── include
|
||||
│ ├── base
|
||||
│ │ ├── assert.h
|
||||
│ │ ├── bdefs.h
|
||||
│ │ ├── crtlib.h
|
||||
│ │ ├── errno.h
|
||||
│ │ ├── limits.h
|
||||
│ │ ├── masks.h
|
||||
│ │ └── types.h
|
||||
│ ├── extras
|
||||
│ │ ├── argv.h
|
||||
│ │ ├── buf.h
|
||||
│ │ ├── list.h
|
||||
│ │ ├── locks.h
|
||||
│ │ ├── malloc.h
|
||||
│ │ └── prog.h
|
||||
│ ├── kernel
|
||||
│ │ ├── base.h
|
||||
│ │ ├── boot.h
|
||||
│ │ ├── cpu.h
|
||||
│ │ ├── heap.h
|
||||
│ │ ├── iomisc.h
|
||||
│ │ ├── mboot.h
|
||||
│ │ ├── mm.h
|
||||
│ │ ├── panic.h
|
||||
│ │ ├── proc.h
|
||||
│ │ └── sched.h
|
||||
│ ├── kalbase.h
|
||||
│ ├── kaleid.h
|
||||
│ └── kalext.h
|
||||
├── kaleid
|
||||
│ ├── crtlib
|
||||
│ │ ├── atoi.c
|
||||
│ │ ├── ctype.c
|
||||
│ │ ├── itoa.c
|
||||
│ │ ├── mem.c
|
||||
│ │ ├── rand.c
|
||||
│ │ ├── sprintf.c
|
||||
│ │ ├── status.c
|
||||
│ │ ├── string.c
|
||||
│ │ └── strtol.c
|
||||
│ ├── extras
|
||||
│ │ ├── argv.c
|
||||
│ │ └── prog.c
|
||||
│ ├── include
|
||||
│ │ ├── base
|
||||
│ │ │ ├── assert.h
|
||||
│ │ │ ├── bdefs.h
|
||||
│ │ │ ├── crtlib.h
|
||||
│ │ │ ├── errno.h
|
||||
│ │ │ ├── limits.h
|
||||
│ │ │ ├── masks.h
|
||||
│ │ │ └── types.h
|
||||
│ │ ├── extras
|
||||
│ │ │ ├── argv.h
|
||||
│ │ │ ├── list.h
|
||||
│ │ │ ├── locks.h
|
||||
│ │ │ ├── malloc.h
|
||||
│ │ │ └── prog.h
|
||||
│ │ ├── kernel
|
||||
│ │ │ ├── base.h
|
||||
│ │ │ ├── buf.h
|
||||
│ │ │ ├── cpu.h
|
||||
│ │ │ ├── heap.h
|
||||
│ │ │ ├── iomisc.h
|
||||
│ │ │ ├── log.h
|
||||
│ │ │ ├── mboot.h
|
||||
│ │ │ ├── mm.h
|
||||
│ │ │ ├── panic.h
|
||||
│ │ │ ├── proc.h
|
||||
│ │ │ └── sched.h
|
||||
│ │ ├── kalbase.h
|
||||
│ │ ├── kaleid.h
|
||||
│ │ └── kalext.h
|
||||
│ └── kernel
|
||||
│ ├── buf
|
||||
│ ├── kernel
|
||||
│ │ ├── cpu
|
||||
│ │ │ ├── cpuid.c
|
||||
│ │ │ └── idt.c
|
||||
│ │ ├── init
|
||||
│ │ │ ├── init.c
|
||||
│ │ │ └── table.c
|
||||
│ │ ├── io
|
||||
│ │ │ ├── ata.inc
|
||||
│ │ │ ├── cursor.c
|
||||
│ │ │ └── vga.c
|
||||
│ │ ├── ke
|
||||
│ │ │ ├── log.c
|
||||
│ │ │ └── panic.c
|
||||
│ │ ├── mm
|
||||
│ │ │ ├── gdt.c
|
||||
│ │ │ ├── heap.c
|
||||
│ │ │ ├── malloc.c
|
||||
│ │ │ └── map.c
|
||||
│ │ └── ps
|
||||
│ │ └── sched.c
|
||||
│ ├── libbuf
|
||||
│ │ ├── bprint.c
|
||||
│ │ ├── bput.c
|
||||
│ │ └── buf.c
|
||||
│ ├── cpu
|
||||
│ │ ├── cpuid.c
|
||||
│ │ └── idt.c
|
||||
│ ├── init
|
||||
│ │ ├── init.c
|
||||
│ │ └── table.c
|
||||
│ ├── io
|
||||
│ │ ├── ata.inc
|
||||
│ │ ├── cursor.c
|
||||
│ │ └── vga.c
|
||||
│ ├── ke
|
||||
│ │ ├── log.c
|
||||
│ │ └── panic.c
|
||||
│ ├── mm
|
||||
│ │ ├── gdt.c
|
||||
│ │ ├── heap.c
|
||||
│ │ ├── malloc.c
|
||||
│ │ └── map.c
|
||||
│ └── proc
|
||||
│ ├── Makefile
|
||||
│ └── sched.c
|
||||
│ └── libc
|
||||
│ ├── atoi.c
|
||||
│ ├── ctype.c
|
||||
│ ├── itoa.c
|
||||
│ ├── mem.c
|
||||
│ ├── rand.c
|
||||
│ ├── sprintf.c
|
||||
│ ├── status.c
|
||||
│ ├── string.c
|
||||
│ └── strtol.c
|
||||
├── AUTHORS
|
||||
├── ChangeLog
|
||||
├── COPYING
|
||||
├── Makefile
|
||||
├── ProjectTree
|
||||
└── Readme.md
|
||||
└── README.md
|
||||
|
||||
28 directories, 114 files
|
||||
|
|
|
@ -22,12 +22,12 @@
|
|||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#ifndef _KALKERN_BASE_H
|
||||
#include <kernel/base.h>
|
||||
#ifndef _KALEXTRAS_LOCKS_H
|
||||
#include <extras/locks.h>
|
||||
#endif
|
||||
|
||||
#ifndef _KALKERN_BUF_H
|
||||
#define _KALKERN_BUF_H
|
||||
#ifndef _KALEXTRAS_BUF_H
|
||||
#define _KALEXTRAS_BUF_H
|
||||
|
||||
//
|
||||
// Buffer flags
|
||||
|
@ -55,6 +55,7 @@ enum
|
|||
BS_WRONLY, // Only for writing
|
||||
};
|
||||
|
||||
typedef struct Buffer_t Buffer_t;
|
||||
typedef error_t (*BFlusher_t)(Buffer_t *);
|
||||
|
||||
struct Buffer_t
|
|
@ -35,7 +35,7 @@ extern "C" {
|
|||
|
||||
//------------------------------------------//
|
||||
|
||||
// Flags for KalAllocMemory
|
||||
// Flags for KalAllocMemoryEx
|
||||
enum
|
||||
{
|
||||
// Return zeroed-out memory
|
||||
|
@ -51,17 +51,18 @@ enum
|
|||
enum
|
||||
{
|
||||
// Default memory allocation alignment (in bytes)
|
||||
// Asking KalAllocMemory for an alignment of 0
|
||||
// Asking KalAllocMemoryEx for an alignment of 0
|
||||
// will cause it to use this value
|
||||
M_DEFAULT_ALIGNMENT = alignof(QWORD),
|
||||
|
||||
// Minimal memory allocation alignment (in bytes)
|
||||
// Asking KalAllocMemory for an nonzero alignment
|
||||
// Asking KalAllocMemoryEx for an nonzero alignment
|
||||
// lower than this value will cause a EALIGN error
|
||||
M_MINIMAL_ALIGNMENT = M_DEFAULT_ALIGNMENT
|
||||
};
|
||||
|
||||
error_t KalAllocMemory(void **ptr, size_t req, int flags, size_t align);
|
||||
error_t KalAllocMemoryEx(void **ptr, size_t req, int flags, size_t align);
|
||||
error_t KalAllocMemory(void **ptr, size_t req);
|
||||
error_t KalFreeMemory(void *ptr);
|
||||
|
||||
//------------------------------------------//
|
|
@ -39,28 +39,12 @@ typedef struct Lock_t Lock_t;
|
|||
typedef struct Buffer_t Buffer_t;
|
||||
typedef struct Thread_t Thread_t;
|
||||
typedef struct Process_t Process_t;
|
||||
typedef struct Terminal_t Terminal_t;
|
||||
typedef struct BootInfo_t BootInfo_t;
|
||||
typedef struct ListHead_t ListHead_t;
|
||||
typedef struct ListNode_t ListNode_t;
|
||||
typedef struct Processor_t Processor_t;
|
||||
typedef struct BootInfo_t BootInfo_t;
|
||||
|
||||
typedef enum ProcState_t ProcState_t;
|
||||
typedef enum TermColor_t TermColor_t;
|
||||
|
||||
//------------------------------------------//
|
||||
// Multiprocessor misc. //
|
||||
//------------------------------------------//
|
||||
|
||||
#ifndef NCPUS
|
||||
#define NCPUS 1
|
||||
#endif
|
||||
|
||||
// Current CPU number
|
||||
#define _KeCurCPU 0
|
||||
|
||||
// Process_t structure of current CPU
|
||||
//#define KeCurCPU (cpuTable[_KeCurCPU])
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
|
@ -104,83 +88,18 @@ struct Processor_t
|
|||
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 {
|
||||
ushort valid;
|
||||
uint grubFlags; //flags
|
||||
uint modulesCount; //mods_count
|
||||
void *modulesAddr; //mods_addr
|
||||
char *grubName; //boot_loader_name
|
||||
void *kernelAddr;
|
||||
void *kernelEndAddr;
|
||||
} btldr;
|
||||
|
||||
// Informations about drives
|
||||
struct {
|
||||
ushort drvValid;
|
||||
ushort bufferValid;
|
||||
uint bootDrv; //boot_device
|
||||
uint bufferLength; //drives_length
|
||||
void *bufferAddr; //drives_addr
|
||||
} drives;
|
||||
|
||||
// Informations about memory
|
||||
struct {
|
||||
ushort memValid;
|
||||
ushort mapValid;
|
||||
|
||||
//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
|
||||
|
||||
uint ramSize; //The ram (init by map.c)
|
||||
} memory;
|
||||
|
||||
// Informations about the video drive
|
||||
struct {
|
||||
ushort vbeValid;
|
||||
ushort fbuValid;
|
||||
void *vbeControl; //vbe_control_info
|
||||
void *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 {
|
||||
ushort apmValid;
|
||||
ushort romValid;
|
||||
uint apmTable; //apm_table
|
||||
uint romTable; //config_table
|
||||
} firmware;
|
||||
};
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
extern int KeCPUCount;
|
||||
extern Processor_t _KeCPUTable[NCPUS];
|
||||
#ifndef NCPUS
|
||||
#define NCPUS 1
|
||||
#endif
|
||||
|
||||
// Current CPU number
|
||||
#define _KeCurCPU 0
|
||||
|
||||
extern int KeCPUCount;
|
||||
extern volatile Processor_t *KeCurCPU;
|
||||
extern volatile BootInfo_t BtBootTab;
|
||||
extern Processor_t _KeCPUTable[NCPUS];
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
|
@ -197,6 +116,16 @@ extern volatile BootInfo_t BtBootTab;
|
|||
|
||||
//------------------------------------------//
|
||||
|
||||
error_t KernLog(const char *, ...);
|
||||
|
||||
#ifndef _NO_DEBUG
|
||||
void DebugLog(const char *, ...);
|
||||
#else
|
||||
#define DebugLog(fmt, ...) ((void)0)
|
||||
#endif
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
// Needed by basically everyone
|
||||
#ifndef _KALEXTRAS_LOCKS_H
|
||||
#include <extras/locks.h>
|
|
@ -0,0 +1,116 @@
|
|||
//----------------------------------------------------------------------------//
|
||||
// GNU GPL OS/K //
|
||||
// //
|
||||
// Desc: Kaleid kernel base include file //
|
||||
// //
|
||||
// //
|
||||
// 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/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#ifndef _KALKERN_BASE_H
|
||||
#include <kernel/base.h>
|
||||
#endif
|
||||
|
||||
#ifndef _KALKERN_BOOT_H
|
||||
#define _KALKERN_BOOT_H
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
#define FB_EGA_TEXT 2
|
||||
#define FB_INDEXED 0
|
||||
#define FB_RGB 1
|
||||
#define BINFO_SIZE 4096
|
||||
|
||||
struct BootInfo_t
|
||||
{
|
||||
// The Bootloader infos
|
||||
struct {
|
||||
ushort valid;
|
||||
uint grubFlags; //flags
|
||||
uint modulesCount; //mods_count
|
||||
void *modulesAddr; //mods_addr
|
||||
char *grubName; //boot_loader_name
|
||||
void *kernelAddr;
|
||||
void *kernelEndAddr;
|
||||
} btldr;
|
||||
|
||||
// Informations about drives
|
||||
struct {
|
||||
ushort drvValid;
|
||||
ushort bufferValid;
|
||||
uint bootDrv; //boot_device
|
||||
uint bufferLength; //drives_length
|
||||
void *bufferAddr; //drives_addr
|
||||
} drives;
|
||||
|
||||
// Informations about memory
|
||||
struct {
|
||||
ushort memValid;
|
||||
ushort mapValid;
|
||||
|
||||
//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
|
||||
|
||||
uint ramSize; //The ram (init by map.c)
|
||||
} memory;
|
||||
|
||||
// Informations about the video drive
|
||||
struct {
|
||||
ushort vbeValid;
|
||||
ushort fbuValid;
|
||||
void *vbeControl; //vbe_control_info
|
||||
void *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 {
|
||||
ushort apmValid;
|
||||
ushort romValid;
|
||||
uint apmTable; //apm_table
|
||||
uint romTable; //config_table
|
||||
} firmware;
|
||||
};
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
extern volatile BootInfo_t BtBootTab;
|
||||
|
||||
#define BtLoaderInfo (BtBootTab.btldr)
|
||||
#define BtDrivesInfo (BtBootTab.drives)
|
||||
#define BtMemoryInfo (BtBootTab.memory)
|
||||
#define BtVideoInfo (BtBootTab.video)
|
||||
#define BtFirmwareInfo (BtBootTab.firmware)
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
#endif
|
|
@ -70,9 +70,6 @@ struct Process_t
|
|||
|
||||
// Scheduler internals
|
||||
ListNode_t *schedNode;
|
||||
|
||||
// Standard output/debug
|
||||
Terminal_t *stdOut, *stdDbg;
|
||||
};
|
||||
|
||||
//------------------------------------------//
|
|
@ -1,40 +0,0 @@
|
|||
//----------------------------------------------------------------------------//
|
||||
// GNU GPL OS/K //
|
||||
// //
|
||||
// Desc: KernLog() and DebugLog() //
|
||||
// //
|
||||
// //
|
||||
// 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/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#ifndef _KALKERN_BASE_H
|
||||
#include <kernel/base.h>
|
||||
#endif
|
||||
|
||||
#ifndef _KALKERN_LOG_H
|
||||
#define _KALKERN_LOG_H
|
||||
|
||||
error_t KernLog(const char *, ...);
|
||||
|
||||
#ifndef _NO_DEBUG
|
||||
void DebugLog(const char *, ...);
|
||||
#else // _NO_DEBUG
|
||||
#define DebugLog(fmt, ...)
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -26,11 +26,9 @@
|
|||
#include <kernel/panic.h>
|
||||
#include <kernel/sched.h>
|
||||
#include <kernel/heap.h>
|
||||
#include <kernel/buf.h>
|
||||
#include <kernel/log.h>
|
||||
#include <kernel/boot.h>
|
||||
#include <kernel/mm.h>
|
||||
|
||||
|
||||
//
|
||||
// BootInfo_t initialization. It is necessary because grub will potentially be
|
||||
// wiped since it is below 1MB.... And we must reorganize all that stuff.
|
||||
|
@ -44,69 +42,69 @@ void BtInitBootInfo(multiboot_info_t *mbi)
|
|||
KalAlwaysAssert(mbi);
|
||||
|
||||
//Retrieves the bootloader flags to ensure infos are valid
|
||||
BtBootTab.btldr.grubFlags = mbi->flags;
|
||||
BtLoaderInfo.grubFlags = mbi->flags;
|
||||
|
||||
if (BtBootTab.btldr.grubFlags & MULTIBOOT_INFO_BOOT_LOADER_NAME) {
|
||||
BtBootTab.btldr.grubName = (char*)(ulong)(mbi->boot_loader_name);
|
||||
BtBootTab.btldr.kernelAddr = (void*)&MB_header;
|
||||
BtBootTab.btldr.kernelEndAddr = (void*)newKernelEnd;
|
||||
BtBootTab.btldr.valid = 1;
|
||||
if (BtLoaderInfo.grubFlags & MULTIBOOT_INFO_BOOT_LOADER_NAME) {
|
||||
BtLoaderInfo.grubName = (char*)(ulong)(mbi->boot_loader_name);
|
||||
BtLoaderInfo.kernelAddr = (void*)&MB_header;
|
||||
BtLoaderInfo.kernelEndAddr = (void*)newKernelEnd;
|
||||
BtLoaderInfo.valid = 1;
|
||||
}
|
||||
if (BtBootTab.btldr.grubFlags & MULTIBOOT_INFO_MODS) {
|
||||
BtBootTab.btldr.modulesCount = mbi->mods_count;
|
||||
BtBootTab.btldr.modulesAddr = (void*)(ulong)mbi->mods_addr;
|
||||
if (BtLoaderInfo.grubFlags & MULTIBOOT_INFO_MODS) {
|
||||
BtLoaderInfo.modulesCount = mbi->mods_count;
|
||||
BtLoaderInfo.modulesAddr = (void*)(ulong)mbi->mods_addr;
|
||||
}
|
||||
//Retrieves the drives informations
|
||||
if (BtBootTab.btldr.grubFlags & MULTIBOOT_INFO_DRIVE_INFO) {
|
||||
if (BtLoaderInfo.grubFlags & MULTIBOOT_INFO_DRIVE_INFO) {
|
||||
BtBootTab.drives.bufferLength = mbi->drives_length;
|
||||
BtBootTab.drives.bufferAddr = (void*)(ulong)mbi->drives_addr;
|
||||
BtBootTab.drives.bufferValid = 1;
|
||||
}
|
||||
if (BtBootTab.btldr.grubFlags & MULTIBOOT_INFO_BOOTDEV) {
|
||||
if (BtLoaderInfo.grubFlags & MULTIBOOT_INFO_BOOTDEV) {
|
||||
BtBootTab.drives.bootDrv = mbi->boot_device;
|
||||
BtBootTab.drives.drvValid = 1;
|
||||
}
|
||||
|
||||
//Retrieves the memory informations
|
||||
if (BtBootTab.btldr.grubFlags & MULTIBOOT_INFO_MEMORY) {
|
||||
BtBootTab.memory.lowMemory = mbi->mem_lower;
|
||||
BtBootTab.memory.upMemory = mbi->mem_upper;
|
||||
BtBootTab.memory.memValid = 1;
|
||||
if (BtLoaderInfo.grubFlags & MULTIBOOT_INFO_MEMORY) {
|
||||
BtMemoryInfo.lowMemory = mbi->mem_lower;
|
||||
BtMemoryInfo.upMemory = mbi->mem_upper;
|
||||
BtMemoryInfo.memValid = 1;
|
||||
}
|
||||
if (BtBootTab.btldr.grubFlags & MULTIBOOT_INFO_MEM_MAP) {
|
||||
BtBootTab.memory.mapAddr = (void*)(ulong)mbi->mmap_addr;
|
||||
BtBootTab.memory.mapLength = mbi->mmap_length;
|
||||
BtBootTab.memory.mapValid = 1;
|
||||
if (BtLoaderInfo.grubFlags & MULTIBOOT_INFO_MEM_MAP) {
|
||||
BtMemoryInfo.mapAddr = (void*)(ulong)mbi->mmap_addr;
|
||||
BtMemoryInfo.mapLength = mbi->mmap_length;
|
||||
BtMemoryInfo.mapValid = 1;
|
||||
}
|
||||
|
||||
// Retrieves video mode informations
|
||||
if (BtBootTab.btldr.grubFlags & MULTIBOOT_INFO_VBE_INFO) {
|
||||
BtBootTab.video.vbeControl = (void*)(ulong)mbi->vbe_control_info;
|
||||
BtBootTab.video.vbeModeInfo = (void*)(ulong)mbi->vbe_mode_info;
|
||||
BtBootTab.video.vbeMode = mbi->vbe_mode;
|
||||
BtBootTab.video.vbeInterfaceSeg = mbi->vbe_interface_seg;
|
||||
BtBootTab.video.vbeInterfaceOff = mbi->vbe_interface_off;
|
||||
BtBootTab.video.vbeInterfaceLen = mbi->vbe_interface_len;
|
||||
BtBootTab.video.vbeValid = 1;
|
||||
if (BtLoaderInfo.grubFlags & MULTIBOOT_INFO_VBE_INFO) {
|
||||
BtVideoInfo.vbeControl = (void*)(ulong)mbi->vbe_control_info;
|
||||
BtVideoInfo.vbeModeInfo = (void*)(ulong)mbi->vbe_mode_info;
|
||||
BtVideoInfo.vbeMode = mbi->vbe_mode;
|
||||
BtVideoInfo.vbeInterfaceSeg = mbi->vbe_interface_seg;
|
||||
BtVideoInfo.vbeInterfaceOff = mbi->vbe_interface_off;
|
||||
BtVideoInfo.vbeInterfaceLen = mbi->vbe_interface_len;
|
||||
BtVideoInfo.vbeValid = 1;
|
||||
}
|
||||
if (BtBootTab.btldr.grubFlags & MULTIBOOT_INFO_FRAMEBUFFER_INFO) {
|
||||
BtBootTab.video.framebufferAddr = (void*)mbi->framebuffer_addr;
|
||||
BtBootTab.video.framebufferPitch = mbi->framebuffer_pitch;
|
||||
BtBootTab.video.framebufferWidth = mbi->framebuffer_width;
|
||||
BtBootTab.video.framebufferHeight= mbi->framebuffer_height;
|
||||
BtBootTab.video.framebufferBpp = mbi->framebuffer_bpp;
|
||||
BtBootTab.video.framebufferType = mbi->framebuffer_type;
|
||||
BtBootTab.video.fbuValid = 1;
|
||||
if (BtLoaderInfo.grubFlags & MULTIBOOT_INFO_FRAMEBUFFER_INFO) {
|
||||
BtVideoInfo.framebufferAddr = (void*)mbi->framebuffer_addr;
|
||||
BtVideoInfo.framebufferPitch = mbi->framebuffer_pitch;
|
||||
BtVideoInfo.framebufferWidth = mbi->framebuffer_width;
|
||||
BtVideoInfo.framebufferHeight= mbi->framebuffer_height;
|
||||
BtVideoInfo.framebufferBpp = mbi->framebuffer_bpp;
|
||||
BtVideoInfo.framebufferType = mbi->framebuffer_type;
|
||||
BtVideoInfo.fbuValid = 1;
|
||||
}
|
||||
|
||||
// Retrieves the firmware infos
|
||||
if (BtBootTab.btldr.grubFlags & MULTIBOOT_INFO_CONFIG_TABLE) {
|
||||
BtBootTab.firmware.romTable = mbi->config_table;
|
||||
BtBootTab.firmware.romValid = 1;
|
||||
if (BtLoaderInfo.grubFlags & MULTIBOOT_INFO_CONFIG_TABLE) {
|
||||
BtFirmwareInfo.romTable = mbi->config_table;
|
||||
BtFirmwareInfo.romValid = 1;
|
||||
}
|
||||
if (BtBootTab.btldr.grubFlags & MULTIBOOT_INFO_APM_TABLE) {
|
||||
BtBootTab.firmware.apmTable = mbi->apm_table;
|
||||
BtBootTab.firmware.apmValid = 1;
|
||||
if (BtLoaderInfo.grubFlags & MULTIBOOT_INFO_APM_TABLE) {
|
||||
BtFirmwareInfo.apmTable = mbi->apm_table;
|
||||
BtFirmwareInfo.apmValid = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,11 +116,11 @@ void BtInitSanity(uint mbMagic){
|
|||
if (!(mbMagic == MULTIBOOT_BOOTLOADER_MAGIC))
|
||||
KeStartPanic("[Init] Magic number %x is incorrect\n", mbMagic);
|
||||
|
||||
tmp = (BtBootTab.btldr.kernelEndAddr
|
||||
- BtBootTab.btldr.kernelAddr) / KB;
|
||||
tmp = (BtLoaderInfo.kernelEndAddr
|
||||
- BtLoaderInfo.kernelAddr) / KB;
|
||||
DebugLog("[Init] Kernel successfully loaded at %p with %x magic\n"
|
||||
" and it uses %d Kio\n\n",
|
||||
BtBootTab.btldr.kernelAddr,
|
||||
BtLoaderInfo.kernelAddr,
|
||||
mbMagic,tmp);
|
||||
}
|
||||
|
||||
|
@ -152,7 +150,7 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic)
|
|||
MmInitHeap();
|
||||
PsInitSched();
|
||||
|
||||
KeStartPanic("Test Panic %d", 4);
|
||||
KeStartPanic("Test Panic %x", 4);
|
||||
|
||||
// End this machine's suffering
|
||||
KeCrashSystem();
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <kernel/base.h>
|
||||
#include <kernel/boot.h>
|
||||
|
||||
int KeCPUCount = 1;
|
||||
Processor_t _KeCPUTable[NCPUS] = {0};
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <kernel/buf.h>
|
||||
#include <extras/buf.h>
|
||||
#include <kernel/boot.h>
|
||||
|
||||
//----------------------------------------------------------//
|
||||
// Internal functions for VGA terminals //
|
||||
|
@ -41,7 +42,7 @@
|
|||
//
|
||||
error_t bvgaflusher(Buffer_t *buf)
|
||||
{
|
||||
ushort *fbp = BtBootTab.video.framebufferAddr;
|
||||
ushort *fbp = BtVideoInfo.framebufferAddr;
|
||||
const uchar color = 0xf;
|
||||
|
||||
uchar *currentLine = buf->wp - buf->lineLen - buf->lastLF;
|
||||
|
@ -54,7 +55,7 @@ error_t bvgaflusher(Buffer_t *buf)
|
|||
}
|
||||
|
||||
const size_t bufSize = buf->nLines * buf->lineLen;
|
||||
ushort *fbe = BtBootTab.video.framebufferAddr
|
||||
ushort *fbe = BtVideoInfo.framebufferAddr
|
||||
+ (bufSize * sizeof(ushort));
|
||||
|
||||
if (fbp < fbe) {
|
||||
|
@ -73,8 +74,8 @@ error_t IoInitVGABuffer(void)
|
|||
static char bvgabuffer[1 * MB];
|
||||
|
||||
BStdOut = BOpenLineBuf(bvgabuffer, BS_WRONLY,
|
||||
BtBootTab.video.framebufferWidth,
|
||||
BtBootTab.video.framebufferHeight,
|
||||
BtVideoInfo.framebufferWidth,
|
||||
BtVideoInfo.framebufferHeight,
|
||||
8, bvgaflusher);
|
||||
|
||||
BStdDbg = BStdOut;
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <kernel/buf.h>
|
||||
#include <extras/buf.h>
|
||||
#include <kernel/base.h>
|
||||
|
||||
//
|
||||
// Prints formatted string on standard output
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <kernel/buf.h>
|
||||
#include <extras/buf.h>
|
||||
#include <kernel/proc.h>
|
||||
#include <kernel/sched.h>
|
||||
#include <kernel/panic.h>
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <kernel/mm.h>
|
||||
#include <kernel/log.h>
|
||||
#include <kernel/heap.h>
|
||||
|
||||
// Least address out of the heap
|
||||
|
|
|
@ -25,7 +25,12 @@
|
|||
#include <kernel/heap.h>
|
||||
#include <extras/malloc.h>
|
||||
|
||||
error_t KalAllocMemory(void **ptr, size_t req, int flags, size_t align)
|
||||
error_t KalAllocMemory(void **ptr, size_t req)
|
||||
{
|
||||
return KalAllocMemoryEx(ptr, req, 0, 0);
|
||||
}
|
||||
|
||||
error_t KalAllocMemoryEx(void **ptr, size_t req, int flags, size_t align)
|
||||
{
|
||||
error_t rc;
|
||||
size_t brk;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <kernel/mm.h>
|
||||
#include <kernel/log.h>
|
||||
#include <kernel/boot.h>
|
||||
#include <kernel/mboot.h>
|
||||
|
||||
// Initializes globally the memory map
|
||||
|
@ -52,19 +52,19 @@ static error_t InitMemoryMap(void)
|
|||
uint i = 0;
|
||||
|
||||
// sanity checks
|
||||
if (!BtBootTab.memory.memValid && BtBootTab.memory.mapValid)
|
||||
if (!BtMemoryInfo.memValid && BtMemoryInfo.mapValid)
|
||||
return ENXIO;
|
||||
|
||||
if ((BtBootTab.memory.upMemory / (MB/KB)) <= MINIMUM_RAM_SIZE)
|
||||
if ((BtMemoryInfo.upMemory / (MB/KB)) <= MINIMUM_RAM_SIZE)
|
||||
return ENOMEM;
|
||||
|
||||
// Ok then we can work ------------------------------------------------------ //
|
||||
|
||||
// the memory map provided by GRUB via the BIOS
|
||||
currentEntry = (multiboot_memory_map_t*)BtBootTab.memory.mapAddr;
|
||||
currentEntry = (multiboot_memory_map_t*)BtMemoryInfo.mapAddr;
|
||||
// End address of the map
|
||||
mapEnd = (multiboot_memory_map_t*)
|
||||
((ulong)currentEntry + (ulong)BtBootTab.memory.mapLength);
|
||||
((ulong)currentEntry + (ulong)BtMemoryInfo.mapLength);
|
||||
|
||||
// fill the map
|
||||
while (currentEntry < mapEnd) {
|
||||
|
@ -112,7 +112,7 @@ size_t MmGetAvailZoneSize(void *start) {
|
|||
uint i;
|
||||
|
||||
// Because the kernel is the kernel
|
||||
if (start < BtBootTab.btldr.kernelEndAddr)
|
||||
if (start < BtLoaderInfo.kernelEndAddr)
|
||||
return 0;
|
||||
|
||||
// Search the zone where the start address is
|
||||
|
@ -137,8 +137,8 @@ void *MmGetFirstAvailZone(void *start) {
|
|||
void *current = 0;
|
||||
|
||||
// Because the kernel is the kernel
|
||||
if ((ulong)start < (ulong)BtBootTab.btldr.kernelEndAddr) {
|
||||
return MmGetFirstAvailZone(BtBootTab.btldr.kernelEndAddr);
|
||||
if ((ulong)start < (ulong)BtLoaderInfo.kernelEndAddr) {
|
||||
return MmGetFirstAvailZone(BtLoaderInfo.kernelEndAddr);
|
||||
}
|
||||
|
||||
// Search the zone where the start address is
|
||||
|
|
|
@ -25,23 +25,22 @@
|
|||
#include <extras/list.h>
|
||||
#include <kernel/proc.h>
|
||||
#include <kernel/sched.h>
|
||||
#include <kernel/log.h>
|
||||
|
||||
//
|
||||
// For test purpose only
|
||||
//
|
||||
int procslen = 10;
|
||||
Process_t procs[] = {
|
||||
{ 0, 0, 0, 12, 12, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL, NULL, NULL },
|
||||
{ 1, 2, 2, 16, 16, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL, NULL, NULL },
|
||||
{ 2, 3, 3, 31, 31, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL, NULL, NULL },
|
||||
{ 3, 2, 2, 1, 1, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL, NULL, NULL },
|
||||
{ 4, 3, 3, 5, 5, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL, NULL, NULL },
|
||||
{ 5, 0, 0, 30, 30, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL, NULL, NULL },
|
||||
{ 6, 1, 1, 19, 19, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL, NULL, NULL },
|
||||
{ 7, 1, 1, 0, 0, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL, NULL, NULL },
|
||||
{ 8, 3, 3, 12, 12, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL, NULL, NULL },
|
||||
{ 9, 2, 2, 21, 21, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL, NULL, NULL },
|
||||
{ 0, 0, 0, 12, 12, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL },
|
||||
{ 1, 2, 2, 16, 16, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL },
|
||||
{ 2, 3, 3, 31, 31, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL },
|
||||
{ 3, 2, 2, 1, 1, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL },
|
||||
{ 4, 3, 3, 5, 5, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL },
|
||||
{ 5, 0, 0, 30, 30, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL },
|
||||
{ 6, 1, 1, 19, 19, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL },
|
||||
{ 7, 1, 1, 0, 0, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL },
|
||||
{ 8, 3, 3, 12, 12, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL },
|
||||
{ 9, 2, 2, 21, 21, STATE_RUNNABLE, DEF_PROC_TSLICE, DEF_PROC_TSLICE, NULL },
|
||||
};
|
||||
|
||||
//------------------------------------------//
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <kernel/buf.h>
|
||||
#include <extras/buf.h>
|
||||
#include <extras/locks.h>
|
||||
|
||||
error_t bputc(Buffer_t *buf, uchar ch);
|
||||
error_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap);
|
||||
|
@ -352,7 +353,7 @@ error_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap)
|
|||
if (*s == '-') { rc = bputc(buf, '-'); s++, len--; }
|
||||
else if (sgn && plus) rc = bputc(buf, '+');
|
||||
else if (sgn && space) rc = bputc(buf, ' ');
|
||||
else bprinthash(buf, base, cap);
|
||||
else if (hash) bprinthash(buf, base, cap);
|
||||
|
||||
// Deal with padding by zeroes
|
||||
// The 'minus' flag makes no sense with the 'zero' one
|
|
@ -22,7 +22,8 @@
|
|||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <kernel/buf.h>
|
||||
#include <extras/buf.h>
|
||||
#include <extras/locks.h>
|
||||
|
||||
error_t bputc(Buffer_t *buf, uchar ch);
|
||||
|
|
@ -22,7 +22,8 @@
|
|||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <kernel/buf.h>
|
||||
#include <extras/buf.h>
|
||||
#include <extras/locks.h>
|
||||
#include <extras/malloc.h>
|
||||
|
||||
Buffer_t *BStdOut, *BStdDbg;
|
||||
|
@ -57,7 +58,7 @@ error_t BCloseBuf(Buffer_t *buf)
|
|||
}
|
||||
|
||||
if (buf->flags & BF_ALLOC) {
|
||||
free(buf->buf);
|
||||
KalFreeMemory(buf->buf);
|
||||
}
|
||||
|
||||
buf->buf = buf->rp = buf->wp = NULL;
|
||||
|
@ -110,7 +111,7 @@ Buffer_t *BOpenLineBuf(char *source, int mode,
|
|||
buf->size = lineLen * nLines * (pbCount + 1);
|
||||
|
||||
if (source == NULL) {
|
||||
buf->buf = calloc(buf->size, 1);
|
||||
KalAllocMemoryEx((void **)&buf->buf, buf->size, M_ZEROED, 0);
|
||||
} else {
|
||||
buf->buf = (uchar *)source;
|
||||
}
|
|
@ -36,7 +36,7 @@ void *malloc(size_t n)
|
|||
void *ptr;
|
||||
error_t rc;
|
||||
|
||||
rc = KalAllocMemory(&ptr, n, 0, 0);
|
||||
rc = KalAllocMemory(&ptr, n);
|
||||
if (rc > 0) seterrno(rc);
|
||||
|
||||
return ptr;
|
||||
|
@ -44,9 +44,13 @@ void *malloc(size_t n)
|
|||
|
||||
void *calloc(size_t n, size_t m)
|
||||
{
|
||||
char *mem = malloc(n * m);
|
||||
memzero(mem, n * m);
|
||||
return mem;
|
||||
void *ptr;
|
||||
error_t rc;
|
||||
|
||||
rc = KalAllocMemoryEx(&ptr, n * m, M_ZEROED, 0);
|
||||
if (rc > 0) seterrno(rc);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void free(void *ptr)
|
|
@ -31,12 +31,6 @@
|
|||
//
|
||||
// Format str according to fmt using ellipsed arguments
|
||||
//
|
||||
// Standard is dumb so we won't follow it:
|
||||
// 1) we return a size_t instead of int
|
||||
// 2) for (v)snprintf we return the number of characters written
|
||||
// instead of the number of characters that would have been written
|
||||
// given large enough n
|
||||
//
|
||||
size_t sprintf(char *str, const char *fmt, ...)
|
||||
{
|
||||
int ret;
|
Loading…
Reference in New Issue