Header stuff
This commit is contained in:
parent
426c07f30b
commit
a3a7132470
|
@ -144,6 +144,8 @@ error_t BPutOnBuf(Buffer_t *, uchar);
|
|||
error_t BPrintOnBuf(Buffer_t *, const char *fmt, ...);
|
||||
error_t BPrintOnBufV(Buffer_t *, const char *fmt, va_list);
|
||||
|
||||
// Internal, non-locking functions; don't use unless you
|
||||
// have a good reason why
|
||||
error_t bputc(Buffer_t *buf, uchar ch);
|
||||
error_t bprintf(Buffer_t *buf, const char *fmt, ...);
|
||||
error_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap);
|
||||
|
|
|
@ -33,12 +33,6 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(_OSK_SOURCE) && !defined(_KALEID_UNMASKED)
|
||||
#ifndef _KALBASE_MASKS_H
|
||||
#include <base/masks.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
#ifndef _KALBASE_BDEFS_H
|
||||
|
|
|
@ -33,20 +33,32 @@
|
|||
#ifndef _KALKERN_BASE_H
|
||||
#define _KALKERN_BASE_H
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
typedef struct Lock_t Lock_t;
|
||||
typedef struct Buffer_t Buffer_t;
|
||||
typedef struct ListHead_t ListHead_t;
|
||||
typedef struct ListNode_t ListNode_t;
|
||||
|
||||
typedef struct Thread_t Thread_t;
|
||||
typedef struct Process_t Process_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 ISRFrame_t ISRFrame_t;
|
||||
typedef enum ProcState_t ProcState_t;
|
||||
|
||||
//------------------------------------------//
|
||||
typedef struct IdtDescriptor_t IdtDescriptor_t;
|
||||
typedef struct IdtEntry_t IdtEntry_t;
|
||||
typedef struct IdtPtr_t IdtPtr_t;
|
||||
typedef struct IRQList_t IRQList_t;
|
||||
typedef struct ISRFrame_t ISRFrame_t;
|
||||
|
||||
typedef struct MemoryMap_t MemoryMap_t;
|
||||
typedef struct MapEntry_t MapEntry_t;
|
||||
typedef struct GdtEntry_t GdtEntry_t;
|
||||
typedef struct GdtPtr_t GdtPtr_t;
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
//
|
||||
// Holds all CPU-local variables
|
||||
|
@ -105,7 +117,7 @@ struct ISRFrame_t {
|
|||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#ifndef NCPUS
|
||||
#define NCPUS 1
|
||||
|
@ -118,7 +130,7 @@ extern int KeCPUCount;
|
|||
extern volatile Processor_t *KeCurCPU;
|
||||
extern Processor_t _KeCPUTable[NCPUS];
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#define DEC_PER_CPU(pref, name, field, type) \
|
||||
static inline type pref##Get##name() { return KeGetCurCPU()->field; } \
|
||||
|
@ -131,7 +143,7 @@ extern Processor_t _KeCPUTable[NCPUS];
|
|||
__sync_synchronize(); \
|
||||
} while(0)
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
error_t KernLog(const char *, ...);
|
||||
|
||||
|
@ -141,12 +153,12 @@ void DebugLog(const char *, ...);
|
|||
#define DebugLog(fmt, ...) ((void)0)
|
||||
#endif
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
extern volatile bool KeIsPanicking;
|
||||
noreturn void KeStartPanic(const char *, ...);
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#define XBUG(c) do { \
|
||||
volatile ushort *_vga \
|
||||
|
@ -157,7 +169,8 @@ noreturn void KeStartPanic(const char *, ...);
|
|||
}while(0)
|
||||
#define BUG() XBUG('B')
|
||||
#define BUGON(x) if(x)BUG()
|
||||
//------------------------------------------//
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#ifndef _KALKERN_BOOT_H
|
||||
#define _KALKERN_BOOT_H
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#define FB_EGA_TEXT 2
|
||||
#define FB_INDEXED 0
|
||||
|
@ -102,7 +102,7 @@ struct BootInfo_t
|
|||
} firmware;
|
||||
};
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
extern volatile BootInfo_t BtBootTab;
|
||||
|
||||
|
@ -112,6 +112,6 @@ extern volatile BootInfo_t BtBootTab;
|
|||
#define BtVideoInfo (BtBootTab.video)
|
||||
#define BtFirmwareInfo (BtBootTab.firmware)
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#ifndef _KALKERN_HEAP_H
|
||||
#define _KALKERN_HEAP_H
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// Address of the heap
|
||||
void *_heap_start;
|
||||
|
@ -46,7 +46,7 @@ error_t MmSetMaxHeapSize(size_t);
|
|||
error_t MmGrowHeap(size_t);
|
||||
error_t MmShrinkHeap(size_t);
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
//----------------------------------------------------------------------------//
|
||||
// GNU GPL OS/K //
|
||||
// //
|
||||
// Desc: Interrupt related functions //
|
||||
// //
|
||||
// //
|
||||
// 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
|
||||
|
@ -5,19 +29,10 @@
|
|||
#ifndef _KALKERN_IDT_H
|
||||
#define _KALKERN_IDT_H
|
||||
|
||||
typedef struct IdtDescriptor_t IdtDescriptor_t;
|
||||
typedef struct IdtEntry_t IdtEntry_t;
|
||||
typedef struct IdtPtr_t IdtPtr_t;
|
||||
typedef struct IRQList_t IRQList_t;
|
||||
typedef struct ISRFrame_t ISRFrame_t;
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
#define interrupt(n) asm volatile ("int %0" : : "N" (n) : "cc", "memory")
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
struct IdtDescriptor_t {
|
||||
struct IdtDescriptor_t
|
||||
{
|
||||
ushort limit;
|
||||
ulong base;
|
||||
} __attribute__((packed));
|
||||
|
@ -55,111 +70,32 @@ typedef struct
|
|||
|
||||
} __attribute__((__packed__)) cpu_state_t;
|
||||
|
||||
static char *IsrExceptions[32] = {
|
||||
"Divide Error Fault",
|
||||
"Debug Exception Trap",
|
||||
"Non-maskable Interrupt",
|
||||
"Breakpoint Trap",
|
||||
"Overflow Trap",
|
||||
"Bound Range Exceeded Fault",
|
||||
"Invalid Opcode Fault",
|
||||
"Device Not Available or No Math Coprocessor Fault",
|
||||
"Double Fault Abort",
|
||||
"Coprocessor Segment Overrun Fault (Legacy)",
|
||||
"Invalid TSS Fault",
|
||||
"Segment Not Present Fault",
|
||||
"Stack Segment fault",
|
||||
"General Protection Fault",
|
||||
"Page Fault",
|
||||
"Intel Reserved",
|
||||
"x87 FPU Floating Point or Math Fault",
|
||||
"Alignment Check Fault",
|
||||
"Machine Check Abort",
|
||||
"SIMD Floating Point Fault",
|
||||
"Virtualization Exception Fault",
|
||||
"Intel Reserved",
|
||||
"Intel Reserved",
|
||||
"Intel Reserved",
|
||||
"Intel Reserved",
|
||||
"Intel Reserved",
|
||||
"Intel Reserved",
|
||||
"Intel Reserved",
|
||||
"Intel Reserved",
|
||||
"Intel Reserved",
|
||||
"Security Exception",
|
||||
"Intel Reserved"
|
||||
};
|
||||
extern char *IsrExceptions[32];
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
void IdtRegisterIrq(void (*isr)(ISRFrame_t *regs), uchar irq, uchar flags);
|
||||
void IdtInit(void);
|
||||
void IdtSetup(void);
|
||||
void IdtSetGate(uchar rank, ulong base, ushort selector, uchar flags);
|
||||
void IdtExceptionHandler(ISRFrame_t *regs);
|
||||
static void EnablePIC(void);
|
||||
void SendEOItoPIC(uchar isr);
|
||||
|
||||
extern void IdtInit();
|
||||
extern void isr0();
|
||||
extern void isr1();
|
||||
extern void isr2();
|
||||
extern void isr3();
|
||||
extern void isr4();
|
||||
extern void isr5();
|
||||
extern void isr6();
|
||||
extern void isr7();
|
||||
extern void isr8();
|
||||
extern void isr9();
|
||||
extern void isr10();
|
||||
extern void isr11();
|
||||
extern void isr12();
|
||||
extern void isr13();
|
||||
extern void isr14();
|
||||
extern void isr15();
|
||||
extern void isr16();
|
||||
extern void isr17();
|
||||
extern void isr18();
|
||||
extern void isr19();
|
||||
extern void isr20();
|
||||
extern void isr21();
|
||||
extern void isr22();
|
||||
extern void isr23();
|
||||
extern void isr24();
|
||||
extern void isr25();
|
||||
extern void isr26();
|
||||
extern void isr27();
|
||||
extern void isr28();
|
||||
extern void isr29();
|
||||
extern void isr30();
|
||||
extern void isr31();
|
||||
extern void isr32();
|
||||
extern void isr33();
|
||||
extern void isr34();
|
||||
extern void isr35();
|
||||
extern void isr36();
|
||||
extern void isr37();
|
||||
extern void isr38();
|
||||
extern void isr39();
|
||||
extern void isr40();
|
||||
extern void isr41();
|
||||
extern void isr42();
|
||||
extern void isr43();
|
||||
extern void isr44();
|
||||
extern void isr45();
|
||||
extern void isr46();
|
||||
extern void isr47();
|
||||
extern void isr48();
|
||||
extern void isr49();
|
||||
extern void isr50();
|
||||
extern void isr51();
|
||||
extern void isr52();
|
||||
extern void isr53();
|
||||
extern void isr54();
|
||||
extern void isr55();
|
||||
extern void isr56();
|
||||
extern void isr57();
|
||||
extern void isr58();
|
||||
extern void isr59();
|
||||
extern void isr60();
|
||||
void IoSendEOItoPIC(uchar isr);
|
||||
void IdtExceptionHandler(ISRFrame_t *regs);
|
||||
void IdtSetGate(uchar rank, ulong base, ushort selector, uchar flags);
|
||||
void IdtRegisterIrq(void (*isr)(ISRFrame_t *regs), uchar irq, uchar flags);
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#define _isr0(a,b,c,d,e) \
|
||||
void isr##a(); void isr##b(); void isr##c(); void isr##d(); void isr##e()
|
||||
|
||||
#define _isr1(a,b,c,d,e,f,g,h,i,j) _isr0(a,b,c,d,e); _isr0(f,g,h,i,j)
|
||||
|
||||
_isr1(0,1,2,3,4,5,6,7,8,9); _isr1(10,11,12,13,14,15,16,17,18,19);
|
||||
_isr1(20,21,22,23,24,25,26,27,28,29); _isr1(30,31,32,33,34,35,36,37,38,39);
|
||||
_isr1(40,41,42,43,44,45,46,47,48,49); _isr1(50,51,52,53,54,55,56,57,58,59);
|
||||
|
||||
#undef _isr1
|
||||
#undef _isr0
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#endif
|
||||
|
|
|
@ -40,11 +40,6 @@
|
|||
#define BADRAM_ZONE 5 // Invalid zone because material problem...
|
||||
#define MAX_ENTRIES 2048 // Max number of memory map entries
|
||||
|
||||
typedef struct MemoryMap_t MemoryMap_t;
|
||||
typedef struct MapEntry_t MapEntry_t;
|
||||
typedef struct GdtEntry_t GdtEntry_t;
|
||||
typedef struct GdtPtr_t GdtPtr_t;
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// The entry structure of the map
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#ifndef _KALKERN_PROC_H
|
||||
#define _KALKERN_PROC_H
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// States for a process
|
||||
enum ProcState_t
|
||||
|
@ -72,7 +72,7 @@ struct Process_t
|
|||
ListNode_t *schedNode;
|
||||
};
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#define PsCurProc (KeCurCPU->process)
|
||||
#define PsCurThread (KeCurCPU->thread)
|
||||
|
@ -80,7 +80,7 @@ struct Process_t
|
|||
//DEC_PER_CPU(Ps, CurProc, process, Process_t *);
|
||||
//DEC_PER_CPU(Ps, CurThread, thread, Thread_t *);
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#ifndef _KALKERN_SCHED_H
|
||||
#define _KALKERN_SCHED_H
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
//
|
||||
// Value of the preemption count indicating that preemption is activated
|
||||
|
@ -55,7 +55,7 @@ enum
|
|||
// Names of the priority classes
|
||||
extern const char *PsPrioClassesNames[];
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
//
|
||||
// Re-scheduling and preemption
|
||||
|
@ -66,7 +66,7 @@ extern const char *PsPrioClassesNames[];
|
|||
#define PsEnablePreemption() do { assert(KeCurCPU->preemptCount > 0); \
|
||||
--KeCurCPU->preemptCount; } while(0)
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
void PsInitSched(void);
|
||||
void PsFiniSched(void);
|
||||
|
@ -74,7 +74,7 @@ void PsFiniSched(void);
|
|||
void PsSchedThisProc(Process_t *);
|
||||
void PsSchedOnTick(void);
|
||||
|
||||
//------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -33,6 +33,44 @@ IdtPtr_t idtPtr;
|
|||
|
||||
IRQList_t irqList = { 0 };
|
||||
|
||||
char *IsrExceptions[32] = {
|
||||
"Divide Error Fault",
|
||||
"Debug Exception Trap",
|
||||
"Non-maskable Interrupt",
|
||||
"Breakpoint Trap",
|
||||
"Overflow Trap",
|
||||
"Bound Range Exceeded Fault",
|
||||
"Invalid Opcode Fault",
|
||||
"Device Not Available or No Math Coprocessor Fault",
|
||||
"Double Fault Abort",
|
||||
"Coprocessor Segment Overrun Fault (Legacy)",
|
||||
"Invalid TSS Fault",
|
||||
"Segment Not Present Fault",
|
||||
"Stack Segment fault",
|
||||
"General Protection Fault",
|
||||
"Page Fault",
|
||||
"Intel Reserved",
|
||||
"x87 FPU Floating Point or Math Fault",
|
||||
"Alignment Check Fault",
|
||||
"Machine Check Abort",
|
||||
"SIMD Floating Point Fault",
|
||||
"Virtualization Exception Fault",
|
||||
"Intel Reserved",
|
||||
"Intel Reserved",
|
||||
"Intel Reserved",
|
||||
"Intel Reserved",
|
||||
"Intel Reserved",
|
||||
"Intel Reserved",
|
||||
"Intel Reserved",
|
||||
"Intel Reserved",
|
||||
"Intel Reserved",
|
||||
"Security Exception",
|
||||
"Intel Reserved"
|
||||
};
|
||||
|
||||
static void EnablePIC(void);
|
||||
|
||||
#define interrupt(n) asm volatile ("int %0" : : "N" (n) : "cc", "memory")
|
||||
|
||||
//
|
||||
// Registers an isr with his IRQ to handle driver interrupts
|
||||
|
|
|
@ -93,10 +93,7 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg)
|
|||
i++;
|
||||
}
|
||||
|
||||
//divideByZero();
|
||||
|
||||
KernLog("Goodbye after %d ticks\n", IoGetRtcTicks());
|
||||
// End this machine's suffering
|
||||
BFlushBuf(BStdOut);
|
||||
KeCrashSystem();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue