change name

This commit is contained in:
hyperassembler 2014-06-03 00:05:45 -07:00
parent a0c48a991e
commit e9dfc095fa
13 changed files with 198 additions and 193 deletions

View File

@ -27,6 +27,7 @@ typedef struct {
ULONG16 OffsetHigh;
} IAGATE32,*PIAGATE32;
typedef struct {
ULONG32 BackLine;
ULONG32 esp0;

View File

@ -1,7 +1,7 @@
#ifndef _KeDef_h_
#define _KeDef_h_
// calling conventions
#define KeNativeAPI _cdecl
#define HYPKERNELAPI _cdecl
//asdadadadsasdadas
//Struct Naming:
//AAXXXXBB

View File

@ -7,13 +7,13 @@
#define DOSGraphMaxBytes 4000
#define DOSGraphBase 0xb8000
VOID KeNativeAPI _asm_KePrintHex32(ULONG32 Hex);
VOID KeNativeAPI _asm_KePrintStr32(PCHAR OffsetStr);
ULONG32 KeNativeAPI _asm_KeSetGraphPosition32(ULONG32 Row,ULONG32 Column);
VOID KeNativeAPI _asm_KeClearGraph32(VOID);
ULONG32 KeNativeAPI _asm_KeGraphRowOverflow(ULONG32 GraphPosition);
ULONG32 KeNativeAPI KeCheckGraphRowForPrint(ULONG32 GraphPosition);
ULONG32 KeNativeAPI KeCheckGraphRowForReturn(ULONG32 GraphPosition);
ULONG32 KeNativeAPI _asm_KeGetCurrentGraphPosition32(VOID);
ULONG32 KeNativeAPI KeGetCurrentGraphRow(ULONG32 GraphPosition);
VOID HYPKERNELAPI _asm_KePrintHex32(ULONG32 Hex);
VOID HYPKERNELAPI _asm_KePrintStr32(PCHAR OffsetStr);
ULONG32 HYPKERNELAPI _asm_KeSetGraphPosition32(ULONG32 Row,ULONG32 Column);
VOID HYPKERNELAPI _asm_KeClearGraph32(VOID);
ULONG32 HYPKERNELAPI _asm_KeGraphRowOverflow(ULONG32 GraphPosition);
ULONG32 HYPKERNELAPI KeCheckGraphRowForPrint(ULONG32 GraphPosition);
ULONG32 HYPKERNELAPI KeCheckGraphRowForReturn(ULONG32 GraphPosition);
ULONG32 HYPKERNELAPI _asm_KeGetCurrentGraphPosition32(VOID);
ULONG32 HYPKERNELAPI KeGetCurrentGraphRow(ULONG32 GraphPosition);
#endif

View File

@ -12,51 +12,51 @@
typedef VOID (*PExceptionHandler)(VOID);
VOID KeNativeAPI _asm_KeWritePort(ULONG16 Port,ULONG8 Value);
ULONG8 KeNativeAPI _asm_KeReadPort(ULONG16 Port);
VOID KeNativeAPI _asm_KeLoadIDT(VOID);
VOID KeNativeAPI KeInit8259A(VOID);
VOID KeNativeAPI KeInitInterrupt(VOID);
VOID KeNativeAPI KeSwitchGDT(VOID);
VOID KeNativeAPI KeInitIDT(VOID);
VOID KeNativeAPI KeWriteGDT(ULONG32 Index,PIAGDT32 Dest, PKeGDTDescriptor32 Src);
VOID KeNativeAPI KeWriteIDT(ULONG32 Index,PIAGATE32 Dest ,PKeIDTDescriptor32 Src);
VOID KeNativeAPI KeExceptionHandler(ULONG32 VectorNumber,ULONG32 ErrorCode,ULONG32 eip,ULONG32 cs,ULONG32 eFlags);
VOID KeNativeAPI _asm_KeDivideError(VOID);
VOID KeNativeAPI _asm_KeSingleStepException(VOID);
VOID KeNativeAPI _asm_KeNMI(VOID);
VOID KeNativeAPI _asm_KeBreakpointException(VOID);
VOID KeNativeAPI _asm_KeOverflow(VOID);
VOID KeNativeAPI _asm_KeBoundsCheck(VOID);
VOID KeNativeAPI _asm_KeInvalidOpcode(VOID);
VOID KeNativeAPI _asm_KeCoprNotAvailable(VOID);
VOID KeNativeAPI _asm_KeDoubleFault(VOID);
VOID KeNativeAPI _asm_KeCoprSegmentOverrun(VOID);
VOID KeNativeAPI _asm_KeInvalidTSS(VOID);
VOID KeNativeAPI _asm_KeSegmentNotPresent(VOID);
VOID KeNativeAPI _asm_KeStackException(VOID);
VOID KeNativeAPI _asm_KeGeneralProtection(VOID);
VOID KeNativeAPI _asm_KePageFault(VOID);
VOID KeNativeAPI _asm_KeCoprError(VOID);
VOID KeNativeAPI KeIrqIntHandler(ULONG32 IrqNumber);
VOID KeNativeAPI _asm_KeIrqInt00(VOID);
VOID KeNativeAPI _asm_KeIrqInt01(VOID);
VOID KeNativeAPI _asm_KeIrqInt02(VOID);
VOID KeNativeAPI _asm_KeIrqInt03(VOID);
VOID KeNativeAPI _asm_KeIrqInt04(VOID);
VOID KeNativeAPI _asm_KeIrqInt05(VOID);
VOID KeNativeAPI _asm_KeIrqInt06(VOID);
VOID KeNativeAPI _asm_KeIrqInt07(VOID);
VOID KeNativeAPI _asm_KeIrqInt08(VOID);
VOID KeNativeAPI _asm_KeIrqInt09(VOID);
VOID KeNativeAPI _asm_KeIrqInt10(VOID);
VOID KeNativeAPI _asm_KeIrqInt11(VOID);
VOID KeNativeAPI _asm_KeIrqInt12(VOID);
VOID KeNativeAPI _asm_KeIrqInt13(VOID);
VOID KeNativeAPI _asm_KeIrqInt14(VOID);
VOID KeNativeAPI _asm_KeIrqInt15(VOID);
VOID KeNativeAPI KeInitializeKeGDTDescriptor32(PKeGDTDescriptor32 Desc, ULONG32 Base, ULONG32 Limit, ULONG32 G, ULONG32 P, ULONG32 S, ULONG32 Type, ULONG32 DPL, ULONG32 DB, ULONG32 AVL);
VOID KeNativeAPI KeInitializeKeIDTDescriptor32(PKeIDTDescriptor32 Desc,ULONG32 GateType, ULONG32 DPL, ULONG32 D, ULONG32 P, ULONG32 Selector, ULONG32 Offset);
VOID HYPKERNELAPI _asm_KeWritePort(ULONG16 Port,ULONG8 Value);
ULONG8 HYPKERNELAPI _asm_KeReadPort(ULONG16 Port);
VOID HYPKERNELAPI _asm_KeLoadIDT(VOID);
VOID HYPKERNELAPI KeInit8259A(VOID);
VOID HYPKERNELAPI KeInitInterrupt(VOID);
VOID HYPKERNELAPI KeSwitchGDT(VOID);
VOID HYPKERNELAPI KeInitIDT(VOID);
VOID HYPKERNELAPI KeWriteGDT(ULONG32 Index,PIAGDT32 Dest, PKeGDTDescriptor32 Src);
VOID HYPKERNELAPI KeWriteIDT(ULONG32 Index,PIAGATE32 Dest ,PKeIDTDescriptor32 Src);
VOID HYPKERNELAPI KeExceptionHandler(ULONG32 VectorNumber,ULONG32 ErrorCode,ULONG32 eip,ULONG32 cs,ULONG32 eFlags);
VOID HYPKERNELAPI _asm_KeDivideError(VOID);
VOID HYPKERNELAPI _asm_KeSingleStepException(VOID);
VOID HYPKERNELAPI _asm_KeNMI(VOID);
VOID HYPKERNELAPI _asm_KeBreakpointException(VOID);
VOID HYPKERNELAPI _asm_KeOverflow(VOID);
VOID HYPKERNELAPI _asm_KeBoundsCheck(VOID);
VOID HYPKERNELAPI _asm_KeInvalidOpcode(VOID);
VOID HYPKERNELAPI _asm_KeCoprNotAvailable(VOID);
VOID HYPKERNELAPI _asm_KeDoubleFault(VOID);
VOID HYPKERNELAPI _asm_KeCoprSegmentOverrun(VOID);
VOID HYPKERNELAPI _asm_KeInvalidTSS(VOID);
VOID HYPKERNELAPI _asm_KeSegmentNotPresent(VOID);
VOID HYPKERNELAPI _asm_KeStackException(VOID);
VOID HYPKERNELAPI _asm_KeGeneralProtection(VOID);
VOID HYPKERNELAPI _asm_KePageFault(VOID);
VOID HYPKERNELAPI _asm_KeCoprError(VOID);
VOID HYPKERNELAPI KeIrqIntHandler(ULONG32 IrqNumber);
VOID HYPKERNELAPI _asm_KeIrqInt00(VOID);
VOID HYPKERNELAPI _asm_KeIrqInt01(VOID);
VOID HYPKERNELAPI _asm_KeIrqInt02(VOID);
VOID HYPKERNELAPI _asm_KeIrqInt03(VOID);
VOID HYPKERNELAPI _asm_KeIrqInt04(VOID);
VOID HYPKERNELAPI _asm_KeIrqInt05(VOID);
VOID HYPKERNELAPI _asm_KeIrqInt06(VOID);
VOID HYPKERNELAPI _asm_KeIrqInt07(VOID);
VOID HYPKERNELAPI _asm_KeIrqInt08(VOID);
VOID HYPKERNELAPI _asm_KeIrqInt09(VOID);
VOID HYPKERNELAPI _asm_KeIrqInt10(VOID);
VOID HYPKERNELAPI _asm_KeIrqInt11(VOID);
VOID HYPKERNELAPI _asm_KeIrqInt12(VOID);
VOID HYPKERNELAPI _asm_KeIrqInt13(VOID);
VOID HYPKERNELAPI _asm_KeIrqInt14(VOID);
VOID HYPKERNELAPI _asm_KeIrqInt15(VOID);
VOID HYPKERNELAPI KeInitializeKeGDTDescriptor32(PKeGDTDescriptor32 Desc, ULONG32 Base, ULONG32 Limit, ULONG32 G, ULONG32 P, ULONG32 S, ULONG32 Type, ULONG32 DPL, ULONG32 DB, ULONG32 AVL);
VOID HYPKERNELAPI KeInitializeKeIDTDescriptor32(PKeIDTDescriptor32 Desc,ULONG32 GateType, ULONG32 DPL, ULONG32 D, ULONG32 P, ULONG32 Selector, ULONG32 Offset);
//KeWriteGDT
#define KeWriteGDT_AVL_1 0x00100000

View File

@ -5,8 +5,8 @@
#include "KeIO32.h"
#include "KeProcess32.h"
VOID KeNativeAPI KeSystemInit(VOID);
VOID KeNativeAPI KeRawDelay(ULONG32 time);
VOID HYPKERNELAPI KeSystemInit(VOID);
VOID HYPKERNELAPI KeRawDelay(ULONG32 time);
VOID ProcessA(VOID);

View File

@ -2,13 +2,13 @@
#include "KeDef.h"
#include "KeGraph32.h"
ULONG32 KeNativeAPI SegmentToPhyscicalAddress(ULONG16 Segment)
ULONG32 HYPKERNELAPI SegmentToPhyscicalAddress(ULONG16 Segment)
{
PIAGDT32 PDescriptor = &KeGDT[(Segment>>3)];
return (PDescriptor->BaseHigh<<24 | PDescriptor->BaseMid<<16 | PDescriptor->BaseLow);
};
PVOID KeNativeAPI KeMemorySet(PVOID Source, BYTE Value, ULONG32 Length)
PVOID HYPKERNELAPI KeMemorySet(PVOID Source, BYTE Value, ULONG32 Length)
{
PBYTE src = (PBYTE)Source;
while(Length > 0)
@ -22,7 +22,7 @@ PVOID KeNativeAPI KeMemorySet(PVOID Source, BYTE Value, ULONG32 Length)
return 0;
}
PVOID KeNativeAPI KeMemoryCopy(PVOID src, PVOID dst, ULONG32 size)
PVOID HYPKERNELAPI KeMemoryCopy(PVOID src, PVOID dst, ULONG32 size)
{
ULONG32 i = 0;
for(i=0;i<size;i++)
@ -33,7 +33,7 @@ PVOID KeNativeAPI KeMemoryCopy(PVOID src, PVOID dst, ULONG32 size)
}
VOID KeNativeAPI KeInitializeWritePDE4KDescriptor32(PKePDE4KDescriptor32 Desc,ULONG32 P,ULONG32 RW, ULONG32 US,ULONG32 PWT,ULONG32 PCD,ULONG32 A,ULONG32 PS,ULONG32 Address)
VOID HYPKERNELAPI KeInitializeWritePDE4KDescriptor32(PKePDE4KDescriptor32 Desc,ULONG32 P,ULONG32 RW, ULONG32 US,ULONG32 PWT,ULONG32 PCD,ULONG32 A,ULONG32 PS,ULONG32 Address)
{
Desc->P = P;
Desc->Address = Address;
@ -46,7 +46,7 @@ VOID KeNativeAPI KeInitializeWritePDE4KDescriptor32(PKePDE4KDescriptor32 Desc,UL
return;
}
VOID KeNativeAPI KeWritePDE4K32(PKePDE4KDescriptor32 Desc, PVOID Dst)
VOID HYPKERNELAPI KeWritePDE4K32(PKePDE4KDescriptor32 Desc, PVOID Dst)
{
ULONG32 temp = 0;
temp = Desc->Address;
@ -63,7 +63,7 @@ VOID KeNativeAPI KeWritePDE4K32(PKePDE4KDescriptor32 Desc, PVOID Dst)
}
VOID KeNativeAPI KeInitializeWritePTE4K32Descriptor(PKePTE4KDescriptor32 Desc,ULONG32 P,ULONG32 RW, ULONG32 US,ULONG32 PWT,ULONG32 PCD,ULONG32 A,ULONG32 D,ULONG32 PS,ULONG32 G,ULONG32 Address)
VOID HYPKERNELAPI KeInitializeWritePTE4K32Descriptor(PKePTE4KDescriptor32 Desc,ULONG32 P,ULONG32 RW, ULONG32 US,ULONG32 PWT,ULONG32 PCD,ULONG32 A,ULONG32 D,ULONG32 PS,ULONG32 G,ULONG32 Address)
{
Desc->P = P;
Desc->Address = Address;
@ -78,7 +78,7 @@ VOID KeNativeAPI KeInitializeWritePTE4K32Descriptor(PKePTE4KDescriptor32 Desc,UL
return;
}
VOID KeNativeAPI KeGetPDEInfo(PKePDE4KDescriptor32 pDesc,ULONG32 Virtual_Address)
VOID HYPKERNELAPI KeGetPDEInfo(PKePDE4KDescriptor32 pDesc,ULONG32 Virtual_Address)
{
ULONG32 temp = *(PULONG32)Virtual_Address;
pDesc->Address = (temp >> 12) << 12;
@ -92,7 +92,7 @@ VOID KeNativeAPI KeGetPDEInfo(PKePDE4KDescriptor32 pDesc,ULONG32 Virtual_Address
return;
}
VOID KeNativeAPI KeGetPTEInfo(PKePTE4KDescriptor32 pDesc,ULONG32 Virtual_Address)
VOID HYPKERNELAPI KeGetPTEInfo(PKePTE4KDescriptor32 pDesc,ULONG32 Virtual_Address)
{
ULONG32 temp = *(PULONG32)Virtual_Address;
pDesc->Address = (temp>>12)<<12;
@ -107,7 +107,7 @@ VOID KeNativeAPI KeGetPTEInfo(PKePTE4KDescriptor32 pDesc,ULONG32 Virtual_Address
return;
}
VOID KeNativeAPI KeWritePTE4K32(PKePTE4KDescriptor32 Desc,PVOID Dst )
VOID HYPKERNELAPI KeWritePTE4K32(PKePTE4KDescriptor32 Desc,PVOID Dst )
{
ULONG32 temp = 0;
temp = Desc->Address;
@ -124,22 +124,23 @@ VOID KeNativeAPI KeWritePTE4K32(PKePTE4KDescriptor32 Desc,PVOID Dst )
*(PULONG32)Dst = temp;
}
ULONG32 KeNativeAPI KeGetPDEIndex4K32(ULONG32 Virtual_Address)
ULONG32 HYPKERNELAPI KeGetPDEIndex4K32(ULONG32 Virtual_Address)
{
return Virtual_Address >> 22;
}
ULONG32 KeNativeAPI KeGetPTEIndex4K32(ULONG32 Virtual_Address)
ULONG32 HYPKERNELAPI KeGetPTEIndex4K32(ULONG32 Virtual_Address)
{
return (Virtual_Address << 10) >> 22;
}
ULONG32 KeNativeAPI KeSetMappingAddress(PVOID PDE_Dir_Address,ULONG32 Physical_Address,ULONG32 Virtual_Address)
ULONG32 HYPKERNELAPI MmMapVirtualAddress(PIAPDE32 PDE_Ptr, ULONG32 PhysicalAddress, ULONG32 VirtualAddress, PKePTE4KDescriptor32 PTEDesc)
{
ULONG32 PDEIndex = KeGetPDEIndex4K32(Virtual_Address);
ULONG32 PTEIndex = KeGetPDEIndex4K32(Virtual_Address);
ULONG32 PTEBase = (*(PULONG32)((ULONG32)PDE_Dir_Address + PDEIndex * 4) >> 12) << 12; // PTE Address
ULONG32 PDEIndex = KeGetPDEIndex4K32(VirtualAddress);
ULONG32 PTEIndex = KeGetPDEIndex4K32(VirtualAddress);
ULONG32 PTEBase = (*(PULONG32)((ULONG32)PDE_Ptr + PDEIndex * 4) >> 12) << 12; // PTE Address
PVOID Target = (PVOID)((*(PULONG32)(PTEBase + PTEIndex * 4) >> 12) << 12);
return 0;
}

View File

@ -8,16 +8,16 @@
#include "KeCPUStruct32.h"
#define KeVirtualAddressToPhysicalAddress(SegmentBase,VirtualAddress) (ULONG32)((ULONG32)SegmentBase+(ULONG32)(VirtualAddress))
PVOID KeNativeAPI KeMemorySet(PVOID Source,BYTE Value,ULONG32 Length);
PVOID KeNativeAPI _asm_KeMemoryCopy(PVOID src,PVOID dst,ULONG32 size);
PVOID KeNativeAPI KeMemoryCopy(PVOID src,PVOID dst,ULONG32 size);
VOID KeNativeAPI KeInitializeWritePDE4KDescriptor32(PKePDE4KDescriptor32 Desc,ULONG32 P,ULONG32 RW, ULONG32 US,ULONG32 PWT,ULONG32 PCD,ULONG32 A,ULONG32 PS,ULONG32 Address);
VOID KeNativeAPI KeWritePDE4K32(PKePDE4KDescriptor32 Desc, PVOID Dst);
VOID KeNativeAPI KeInitializeWritePTE4KDescriptor32(PKePTE4KDescriptor32 Desc,ULONG32 P,ULONG32 RW, ULONG32 US,ULONG32 PWT,ULONG32 PCD,ULONG32 A,ULONG32 D,ULONG32 PS,ULONG32 G,ULONG32 Address);
VOID KeNativeAPI KeWritePTE4K32(PKePTE4KDescriptor32 Desc,PVOID Dst );
ULONG32 KeNativeAPI KeGetPDEIndex4K32(ULONG32 Virtual_Address);
ULONG32 KeNativeAPI KeGetPTEIndex4K32(ULONG32 Virtual_Address);
ULONG32 KeNativeAPI KeSetMappingAddress(PVOID PDE_Dir_Address,ULONG32 Physical_Address,ULONG32 Virtual_Address);
PVOID HYPKERNELAPI KeMemorySet(PVOID Source,BYTE Value,ULONG32 Length);
PVOID HYPKERNELAPI _asm_KeMemoryCopy(PVOID src,PVOID dst,ULONG32 size);
PVOID HYPKERNELAPI KeMemoryCopy(PVOID src,PVOID dst,ULONG32 size);
VOID HYPKERNELAPI KeInitializeWritePDE4KDescriptor32(PKePDE4KDescriptor32 Desc,ULONG32 P,ULONG32 RW, ULONG32 US,ULONG32 PWT,ULONG32 PCD,ULONG32 A,ULONG32 PS,ULONG32 Address);
VOID HYPKERNELAPI KeWritePDE4K32(PKePDE4KDescriptor32 Desc, PVOID Dst);
VOID HYPKERNELAPI KeInitializeWritePTE4KDescriptor32(PKePTE4KDescriptor32 Desc,ULONG32 P,ULONG32 RW, ULONG32 US,ULONG32 PWT,ULONG32 PCD,ULONG32 A,ULONG32 D,ULONG32 PS,ULONG32 G,ULONG32 Address);
VOID HYPKERNELAPI KeWritePTE4K32(PKePTE4KDescriptor32 Desc,PVOID Dst );
ULONG32 HYPKERNELAPI KeGetPDEIndex4K32(ULONG32 Virtual_Address);
ULONG32 HYPKERNELAPI KeGetPTEIndex4K32(ULONG32 Virtual_Address);
ULONG32 HYPKERNELAPI KeSetMappingAddress(PVOID PDE_Dir_Address,ULONG32 Physical_Address,ULONG32 Virtual_Address);
#define KeWritePDE4K32_P_0 0 // 0 for not present

View File

@ -44,8 +44,8 @@ typedef struct {
VOID KeNativeAPI KeCreateProcess(ULONG32 ProcessID,PVOID ProcessAddress,PVOID ProcessStack,PROCESSPRIVILEGE Privilege);
VOID KeNativeAPI KeInitProcess(VOID);
VOID KeNativeAPI _asm_KeLoadTSS(ULONG32 Selector_TSS);
VOID KeNativeAPI _asm_Restart();
VOID HYPKERNELAPI KeCreateProcess(ULONG32 ProcessID,PVOID ProcessAddress,PVOID ProcessStack,PROCESSPRIVILEGE Privilege);
VOID HYPKERNELAPI KeInitProcess(VOID);
VOID HYPKERNELAPI _asm_KeLoadTSS(ULONG32 Selector_TSS);
VOID HYPKERNELAPI _asm_Restart();
#endif

View File

View File

@ -0,0 +1,5 @@
#ifndef _KeMemoryManager32_h_
#define _KeMemoryManager32_h_
#endif

Binary file not shown.

106
makefile
View File

@ -1,2 +1,104 @@
build:
cl /c /Od /I ".\kclib\" /X /Fo ".\kclib\KeIO32.obj" /W4 /nologo /Gd /TC ".\kclib\KeIO32.c"
ENTRYPOINT = 0x30000
ASM = nasm
ASMBOOTFLAGS = -I inc/ -I lib/
ASMLOADERFLAGS = -I inc/ -I lib/
ASMKERNELFLAGS = -f elf
CFLAGS = -I kclib/ -c -fno-builtin
LDFLAGS = -e _start -Ttext $(ENTRYPOINT)
CC = gcc
LD = ld
OPY = objcopy
#Add corresponding .o files from kclib and kalib
KERNELBINPRE = kernel/kernel.o kclib/KeKernelEntry.o kalib/_asm_KeMemory32.o kalib/_asm_KeGraph32.o kalib/_asm_KeIO32.o kalib/_asm_KeProcess32.o kclib/KeProcess32.o kclib/KeGraph32.o kclib/KeIO32.o kclib/KeMemory32.o
#Add all .o files
OBJECTFILES = kernel/kernel.o kclib/KeKernelEntry.o kalib/_asm_KeMemory32.o kalib/_asm_KeGraph32.o kalib/_asm_KeIO32.o kalib/_asm_KeProcess32.o kclib/KeProcess32.o kclib/KeGraph32.o kclib/KeIO32.o kclib/KeMemory32.o
#Add all .bin files
BINFILES = boot/boot.bin boot/loader.bin kernel/kernel.bin
#Add all temp files
TEMPFILES = kernel/kernel.out
#Prerequisites
#Add new .h/.c files form kclib
KEKERNELENTRYPRE = kclib/KeKernelEntry.c kclib/KeGraph32.h kclib/KeDef.h kclib/KeGlobalVariables.h kclib/KeMemory32.h kclib/KeIO32.h kclib/KeProcess32.h kclib/KeProcess32.c kclib/KeGraph32.c kclib/KeMemory32.c kclib/KeProcess32.c kclib/KeIO32.c kclib/KeKernelStruct32.h
#No need to change
_ASM_KEGRAPH32PRE = kalib/_asm_KeGraph32.asm
_ASM_KEMEMORY32PRE = kalib/_asm_KeMemory32.asm
KERNELOPRE = kernel/kernel.asm
BOOTBINPRE = boot/boot.asm inc/FAT12Header.inc lib/fat12readfile.lib
LOADERBINPRE = boot/loader.asm inc/FAT12Header.inc inc/pm.inc lib/fat12readfile.lib lib/io16.lib lib/io32.lib lib/mem32.lib
_ASM_KEIO32PRE = kalib/_asm_KeIO32.asm
_ASM_KEPROCESS32PRE = kalib/_asm_KeProcess32.asm
.PHONY : everything clean all image buildimg
everything : $(BINFILES) $(OBJECTFILES) $(TEMPFILES)
all : clean everything
image: all buildimg
clean:
rm -rf $(BINFILES) $(OBJECTFILES) $(TEMPFILES)
buildimg:
dd if=boot/boot.bin of=a.img bs=512 count=1 conv=notrunc
cp -f kernel/kernel.bin kernel.bin
cp -f boot/loader.bin loader.bin
rm -rf $(BINFILES) $(OBJECTFILES) $(TEMPFILES)
boot/boot.bin: $(BOOTBINPRE)
$(ASM) $(ASMBOOTFLAGS) -o boot/boot.bin boot/boot.asm
boot/loader.bin: $(LOADERPRE)
$(ASM) $(ASMBOOTFLAGS) -o boot/loader.bin boot/loader.asm
kernel/kernel.o: $(KERNELOPRE)
$(ASM) $(ASMKERNELFLAGS) -o kernel/kernel.o kernel/kernel.asm
kalib/_asm_KeMemory32.o: $(_ASM_KEMEMORY32PRE)
$(ASM) $(ASMKERNELFLAGS) -o kalib/_asm_KeMemory32.o kalib/_asm_KeMemory32.asm
kalib/_asm_KeGraph32.o: $(_ASM_KEGRAPH32PRE)
$(ASM) $(ASMKERNELFLAGS) -o kalib/_asm_KeGraph32.o kalib/_asm_KeGraph32.asm
kalib/_asm_KeProcess32.o: $(_ASM_KEGRAPH32PRE)
$(ASM) $(ASMKERNELFLAGS) -o kalib/_asm_KeProcess32.o kalib/_asm_KeProcess32.asm
kernel/kernel.bin: $(KERNELBINPRE)
$(LD) $(OBJECTFILES) $(LDFLAGS) -o kernel/kernel.out
$(OPY) kernel/kernel.out -O binary kernel/kernel.bin
kalib/_asm_KeIO32.o: $(_ASM_KEIO32PRE)
$(ASM) $(ASMKERNELFLAGS) -o kalib/_asm_KeIO32.o kalib/_asm_KeIO32.asm
#C LIBS
kclib/KeKernelEntry.o: $(KEKERNELENTRYPRE)
$(CC) $(CFLAGS) -o kclib/KeKernelEntry.o kclib/KeKernelEntry.c
kclib/KeIO32.o: $(KERNELBINPRE)
$(CC) $(CFLAGS) -o kclib/KeIO32.o kclib/KeIO32.c
kclib/KeGraph32.o: $(KERNELBINPRE)
$(CC) $(CFLAGS) -o kclib/KeGraph32.o kclib/KeGraph32.c
kclib/KeProcess32.o: $(KERNELBINPRE)
$(CC) $(CFLAGS) -o kclib/KeProcess32.o kclib/KeProcess32.c
kclib/KeMemory32.o: $(KERNELBINPRE)
$(CC) $(CFLAGS) -o kclib/KeMemory32.o kclib/KeMemory32.c

104
makefile2
View File

@ -1,104 +0,0 @@
ENTRYPOINT = 0x30000
ASM = nasm
ASMBOOTFLAGS = -I inc/ -I lib/
ASMLOADERFLAGS = -I inc/ -I lib/
ASMKERNELFLAGS = -f elf
CFLAGS = -I kclib/ -c -fno-builtin
LDFLAGS = -e _start -Ttext $(ENTRYPOINT)
CC = gcc
LD = ld
OPY = objcopy
#Add corresponding .o files from kclib and kalib
KERNELBINPRE = kernel/kernel.o kclib/KeKernelEntry.o kalib/_asm_KeMemory32.o kalib/_asm_KeGraph32.o kalib/_asm_KeIO32.o kalib/_asm_KeProcess32.o kclib/KeProcess32.o kclib/KeGraph32.o kclib/KeIO32.o kclib/KeMemory32.o
#Add all .o files
OBJECTFILES = kernel/kernel.o kclib/KeKernelEntry.o kalib/_asm_KeMemory32.o kalib/_asm_KeGraph32.o kalib/_asm_KeIO32.o kalib/_asm_KeProcess32.o kclib/KeProcess32.o kclib/KeGraph32.o kclib/KeIO32.o kclib/KeMemory32.o
#Add all .bin files
BINFILES = boot/boot.bin boot/loader.bin kernel/kernel.bin
#Add all temp files
TEMPFILES = kernel/kernel.out
#Prerequisites
#Add new .h/.c files form kclib
KEKERNELENTRYPRE = kclib/KeKernelEntry.c kclib/KeGraph32.h kclib/KeDef.h kclib/KeGlobalVariables.h kclib/KeMemory32.h kclib/KeIO32.h kclib/KeProcess32.h kclib/KeProcess32.c kclib/KeGraph32.c kclib/KeMemory32.c kclib/KeProcess32.c kclib/KeIO32.c kclib/KeKernelStruct32.h
#No need to change
_ASM_KEGRAPH32PRE = kalib/_asm_KeGraph32.asm
_ASM_KEMEMORY32PRE = kalib/_asm_KeMemory32.asm
KERNELOPRE = kernel/kernel.asm
BOOTBINPRE = boot/boot.asm inc/FAT12Header.inc lib/fat12readfile.lib
LOADERBINPRE = boot/loader.asm inc/FAT12Header.inc inc/pm.inc lib/fat12readfile.lib lib/io16.lib lib/io32.lib lib/mem32.lib
_ASM_KEIO32PRE = kalib/_asm_KeIO32.asm
_ASM_KEPROCESS32PRE = kalib/_asm_KeProcess32.asm
.PHONY : everything clean all image buildimg
everything : $(BINFILES) $(OBJECTFILES) $(TEMPFILES)
all : clean everything
image: all buildimg
clean:
rm -rf $(BINFILES) $(OBJECTFILES) $(TEMPFILES)
buildimg:
dd if=boot/boot.bin of=a.img bs=512 count=1 conv=notrunc
cp -f kernel/kernel.bin kernel.bin
cp -f boot/loader.bin loader.bin
rm -rf $(BINFILES) $(OBJECTFILES) $(TEMPFILES)
boot/boot.bin: $(BOOTBINPRE)
$(ASM) $(ASMBOOTFLAGS) -o boot/boot.bin boot/boot.asm
boot/loader.bin: $(LOADERPRE)
$(ASM) $(ASMBOOTFLAGS) -o boot/loader.bin boot/loader.asm
kernel/kernel.o: $(KERNELOPRE)
$(ASM) $(ASMKERNELFLAGS) -o kernel/kernel.o kernel/kernel.asm
kalib/_asm_KeMemory32.o: $(_ASM_KEMEMORY32PRE)
$(ASM) $(ASMKERNELFLAGS) -o kalib/_asm_KeMemory32.o kalib/_asm_KeMemory32.asm
kalib/_asm_KeGraph32.o: $(_ASM_KEGRAPH32PRE)
$(ASM) $(ASMKERNELFLAGS) -o kalib/_asm_KeGraph32.o kalib/_asm_KeGraph32.asm
kalib/_asm_KeProcess32.o: $(_ASM_KEGRAPH32PRE)
$(ASM) $(ASMKERNELFLAGS) -o kalib/_asm_KeProcess32.o kalib/_asm_KeProcess32.asm
kernel/kernel.bin: $(KERNELBINPRE)
$(LD) $(OBJECTFILES) $(LDFLAGS) -o kernel/kernel.out
$(OPY) kernel/kernel.out -O binary kernel/kernel.bin
kalib/_asm_KeIO32.o: $(_ASM_KEIO32PRE)
$(ASM) $(ASMKERNELFLAGS) -o kalib/_asm_KeIO32.o kalib/_asm_KeIO32.asm
#C LIBS
kclib/KeKernelEntry.o: $(KEKERNELENTRYPRE)
$(CC) $(CFLAGS) -o kclib/KeKernelEntry.o kclib/KeKernelEntry.c
kclib/KeIO32.o: $(KERNELBINPRE)
$(CC) $(CFLAGS) -o kclib/KeIO32.o kclib/KeIO32.c
kclib/KeGraph32.o: $(KERNELBINPRE)
$(CC) $(CFLAGS) -o kclib/KeGraph32.o kclib/KeGraph32.c
kclib/KeProcess32.o: $(KERNELBINPRE)
$(CC) $(CFLAGS) -o kclib/KeProcess32.o kclib/KeProcess32.c
kclib/KeMemory32.o: $(KERNELBINPRE)
$(CC) $(CFLAGS) -o kclib/KeMemory32.o kclib/KeMemory32.c