CPPFLAGS += -I./include -I./arch/$(ARCHDIR)/include
CPPFLAGS += -DARCH=$(ARCH) -DARCHDIR=$(ARCHDIR) -DKERNEL_VERSION=$(KERNEL_VERSION) -DBUILD_NUM=$(BUILD_NUM)
-CFLAGS += -Wall -Werror -O3 -fno-stack-protector -fno-builtin
+CFLAGS += -Wall -Werror -O3 -fno-stack-protector -fno-builtin -Wstrict-prototypes
ASFLAGS += -D ARCH=\"$(ARCH)\" -D ARCHDIR=\"$(ARCHDIR)\"
LDFLAGS += -T arch/$(ARCHDIR)/link.ld
};
// === CODE ===
-void __stack_chk_fail()
+void __stack_chk_fail(void)
{
Panic("FATAL ERROR: Stack Check Failed\n");
for(;;);
#define _MM_PHYS_H
// === FUNCTIONS ===
-extern tPAddr MM_AllocPhys();
+extern tPAddr MM_AllocPhys(void);
extern tPAddr MM_AllocPhysRange(int Pages, int MaxBits);
extern void MM_RefPhys(tPAddr PAddr);
extern void MM_DerefPhys(tPAddr PAddr);
#define MM_MODULE_MAX 0xF0000000 // 512 MiB
// === FUNCTIONS ===
-extern void MM_FinishVirtualInit();
+extern void MM_FinishVirtualInit(void);
extern void MM_SetCR3(Uint CR3);
extern tPAddr MM_Allocate(tVAddr VAddr);
extern void MM_Deallocate(tVAddr VAddr);
extern int MM_Map(tVAddr VAddr, tPAddr PAddr);
-extern tPAddr MM_Clone();
-extern tVAddr MM_NewKStack();
-extern tVAddr MM_NewWorkerStack();
+extern tPAddr MM_Clone(void);
+extern tVAddr MM_NewKStack(void);
+extern tVAddr MM_NewWorkerStack(void);
#endif
} __attribute__((packed)) tTSS;
// === FUNCTIONS ===
-extern void Proc_Start();
+extern void Proc_Start(void);
extern int Proc_Clone(Uint *Err, Uint Flags);
#endif
/**
* \brief Sets the screen mode for a kernel panic
*/
-void KernelPanic_SetMode()
+void KernelPanic_SetMode(void)
{
int i;
extern int Time_Setup(void);
extern Uint Proc_Clone(Uint *Err, Uint Flags);
extern void Threads_Sleep(void);
-extern void Threads_Exit(void);
// --- Core ---
extern void System_Init(char *Commandline);
extern void gKernelEnd;
// === PROTOTYPES ===
-tPAddr MM_AllocPhys();
+tPAddr MM_AllocPhys(void);
tPAddr MM_AllocPhysRange(int Pages, int MaxBits);
void MM_RefPhys(tPAddr PAddr);
void MM_DerefPhys(tPAddr PAddr);
}
/**
- * \fn tPAddr MM_AllocPhys()
+ * \fn tPAddr MM_AllocPhys(void)
* \brief Allocates a physical page from the general pool
*/
-tPAddr MM_AllocPhys()
+tPAddr MM_AllocPhys(void)
{
// int a, b, c;
int indx;
extern void Error_Backtrace(Uint eip, Uint ebp);
// === PROTOTYPES ===
-void MM_PreinitVirtual();
-void MM_InstallVirtual();
+void MM_PreinitVirtual(void);
+void MM_InstallVirtual(void);
void MM_PageFault(tVAddr Addr, Uint ErrorCode, tRegs *Regs);
void MM_DumpTables(tVAddr Start, tVAddr End);
tPAddr MM_DuplicatePage(tVAddr VAddr);
// === CODE ===
/**
- * \fn void MM_PreinitVirtual()
+ * \fn void MM_PreinitVirtual(void)
* \brief Maps the fractal mappings
*/
-void MM_PreinitVirtual()
+void MM_PreinitVirtual(void)
{
#if USE_PAE
gaInitPageDir[ ((PAGE_TABLE_ADDR >> TAB)-3*512+3)*2 ] = ((tTabEnt)&gaInitPageDir - KERNEL_BASE) | 3;
}
/**
- * \fn void MM_InstallVirtual()
+ * \fn void MM_InstallVirtual(void)
* \brief Sets up the constant page mappings
*/
-void MM_InstallVirtual()
+void MM_InstallVirtual(void)
{
int i;
/**
* \brief Cleans up the SMP required mappings
*/
-void MM_FinishVirtualInit()
+void MM_FinishVirtualInit(void)
{
#if USE_PAE
gaInitPDPT[ 0 ] = 0;
* \fn tVAddr MM_ClearUser()
* \brief Clear user's address space
*/
-tVAddr MM_ClearUser()
+tVAddr MM_ClearUser(void)
{
Uint i, j;
}
/**
- * \fn tPAddr MM_Clone()
+ * \fn tPAddr MM_Clone(void)
* \brief Clone the current address space
*/
-tPAddr MM_Clone()
+tPAddr MM_Clone(void)
{
Uint i, j;
tVAddr ret;
}
/**
- * \fn tVAddr MM_NewKStack()
+ * \fn tVAddr MM_NewKStack(void)
* \brief Create a new kernel stack
*/
-tVAddr MM_NewKStack()
+tVAddr MM_NewKStack(void)
{
tVAddr base = KERNEL_STACKS;
Uint i;
// === IMPORTS ===
extern tGDT gGDT[];
extern tIDT gIDT[];
-extern void APStartup(); // 16-bit AP startup code
-extern Uint GetEIP(); // start.asm
+extern void APStartup(void); // 16-bit AP startup code
+extern Uint GetEIP(void); // start.asm
extern Uint32 gaInitPageDir[1024]; // start.asm
extern void Kernel_Stack_Top;
extern tSpinlock glThreadListLock;
extern tThread *gSleepingThreads;
extern tThread *gDeleteThreads;
extern tThread *Threads_GetNextToRun(int CPU);
-extern void Threads_Dump();
+extern void Threads_Dump(void);
extern tThread *Threads_CloneTCB(Uint *Err, Uint Flags);
-extern void Isr8(); // Double Fault
-extern void Proc_ReturnToUser();
+extern void Isr8(void); // Double Fault
+extern void Proc_ReturnToUser(void);
// === PROTOTYPES ===
-void ArchThreads_Init();
+void ArchThreads_Init(void);
#if USE_MP
void MP_StartAP(int CPU);
void MP_SendIPI(Uint8 APICID, int Vector, int DeliveryMode);
#endif
-void Proc_Start();
-tThread *Proc_GetCurThread();
-void Proc_ChangeStack();
+void Proc_Start(void);
+tThread *Proc_GetCurThread(void);
+void Proc_ChangeStack(void);
int Proc_Clone(Uint *Err, Uint Flags);
void Proc_StartProcess(Uint16 SS, Uint Stack, Uint Flags, Uint16 CS, Uint IP);
void Proc_CallFaultHandler(tThread *Thread);
-void Proc_Scheduler();
+void Proc_Scheduler(int CPU);
// === GLOBALS ===
// --- Multiprocessing ---
// === CODE ===
/**
- * \fn void ArchThreads_Init()
+ * \fn void ArchThreads_Init(void)
* \brief Starts the process scheduler
*/
-void ArchThreads_Init()
+void ArchThreads_Init(void)
{
Uint pos = 0;
#endif
/**
- * \fn void Proc_Start()
+ * \fn void Proc_Start(void)
* \brief Start process scheduler
*/
-void Proc_Start()
+void Proc_Start(void)
{
// Start Interrupts (and hence scheduler)
__asm__ __volatile__("sti");
}
/**
- * \fn tThread *Proc_GetCurThread()
+ * \fn tThread *Proc_GetCurThread(void)
* \brief Gets the current thread
*/
-tThread *Proc_GetCurThread()
+tThread *Proc_GetCurThread(void)
{
#if USE_MP
return gaCPUs[ gaAPIC_to_CPU[gpMP_LocalAPIC->ID.Val&0xFF] ].Current;
}
/**
- * \fn void Proc_ChangeStack()
+ * \fn void Proc_ChangeStack(void)
* \brief Swaps the current stack for a new one (in the proper stack reigon)
*/
-void Proc_ChangeStack()
+void Proc_ChangeStack(void)
{
Uint esp, ebp;
Uint tmpEbp, oldEsp;
}
/**
- * \fn int Proc_SpawnWorker()
+ * \fn int Proc_SpawnWorker(void)
* \brief Spawns a new worker thread
*/
-int Proc_SpawnWorker()
+int Proc_SpawnWorker(void)
{
tThread *new, *cur;
Uint eip, esp, ebp;
}
/**
- * \fn Uint Proc_MakeUserStack()
+ * \fn Uint Proc_MakeUserStack(void)
* \brief Creates a new user stack
*/
-Uint Proc_MakeUserStack()
+Uint Proc_MakeUserStack(void)
{
int i;
Uint base = USER_STACK_TOP - USER_STACK_SZ;
extern void Timer_CallTimers(void);
// === PROTOTYPES ===
-void Time_Interrupt();
+void Time_Interrupt(int);
// === CODE ===
/**
- * \fn int Time_Setup()
+ * \fn int Time_Setup(void)
* \brief Sets the system time from the Realtime-Clock
*/
-int Time_Setup()
+int Time_Setup(void)
{
Uint8 val;
}
/**
- * \fn void Time_Interrupt()
+ * \fn void Time_Interrupt(void)
* \brief Called on the timekeeping IRQ
*/
-void Time_Interrupt()
+void Time_Interrupt(int irq)
{
giTicks ++;
giTimestamp += MS_PER_TICK_WHOLE;
#if 0
/**
- * \fn void Time_TimerThread()
+ * \fn void Time_TimerThread(void)
*/
-void Time_TimerThread()
+void Time_TimerThread(void)
{
Sint64 next;
Threads_SetName("TIMER");
#define _ARCH_H_
#include <stdint.h>
-#define KERNEL_BASE 0xFFFF8000##00000000
+//#define KERNEL_BASE 0xFFFF8000##00000000
+#define KERNEL_BASE 0xFFFFFFFF##80000000
#define BITS 64
// === Core Types ===
* 0x00000000 00000000 - 0x00007FFF FFFFFFFF 47 128 TiB User Space
* 0x00008000 00000000 - 0xFFFF7FFF FFFFFFFF --- SIGN EXTENSION NULL ZONE
* 0xFFFF8000 00000000 - 0xFFFFFFFF FFFFFFFF 47 128 TiB Kernel Range
- * 8000 00000000 - 8000 7FFFFFFF 31 2 GiB Identity Map
- * 8000 80000000 - 9000 00000000 ~44 16 TiB Kernel Heap
+ * 8000 00000000 - 9000 00000000 44 16 TiB Kernel Heap
* 9000 00000000 - 9800 00000000 43 8 TiB Module Space
* 9800 00000000 - 9A00 00000000 41 2 TiB Kernel VFS
* A000 00000000 - B000 00000000 44 16 TiB Kernel Stacks
* FD00 00000000 - FD80 00000000 39 512 GiB Local APIC
* FE00 00000000 - FE80 00000000 39 512 GiB Fractal Mapping (PML4 510)
* FE80 00000000 - FF00 00000000 39 512 GiB Temp Fractal Mapping
+ * FF00 00000000 - FF80 00000000 39 512 GiB -- UNUSED --
+ * FF80 00000000 - FFFF 80000000 ~39 GiB -- UNUSED --
+ * FFFF 80000000 - FFFF 7FFFFFFF 31 2 GiB Identity Map
*/
#define MM_USER_MIN 0x00000000##00010000
* Linker Script
*/
-_kernel_base = 0xFFFF800000000000;
+/* _kernel_base = 0xFFFF800000000000; */
+/* -2 GiB */
+_kernel_base = 0xFFFFFFFF80000000;
OUTPUT_FORMAT(elf32-i386)
OUTPUT_ARCH(i386:x86-64)
case MULTIBOOT_MAGIC:
// Adjust Multiboot structure address
mbInfo = (void*)( (Uint)MbInfoPtr + KERNEL_BASE );
- gsBootCmdLine = (char*)(mbInfo->CommandLine + KERNEL_BASE);
+ gsBootCmdLine = (char*)( (Uint)mbInfo->CommandLine + KERNEL_BASE);
MM_InitPhys_Multiboot( mbInfo ); // Set up physical memory manager
break;
// === IMPORTS ===
extern tGDT gGDT[];
-extern void APStartup(); // 16-bit AP startup code
-extern Uint GetRIP(); // start.asm
+extern void APStartup(void); // 16-bit AP startup code
+extern Uint GetRIP(void); // start.asm
extern Uint64 gInitialPML4[512]; // start.asm
extern void gInitialKernelStack;
extern tSpinlock glThreadListLock;
extern void GetCPUNum(void);
// === PROTOTYPES ===
-void ArchThreads_Init();
+void ArchThreads_Init(void);
#if USE_MP
void MP_StartAP(int CPU);
void MP_SendIPI(Uint8 APICID, int Vector, int DeliveryMode);
#endif
-void Proc_Start();
-tThread *Proc_GetCurThread();
-void Proc_ChangeStack();
+void Proc_Start(void);
+tThread *Proc_GetCurThread(void);
+void Proc_ChangeStack(void);
int Proc_Clone(Uint *Err, Uint Flags);
void Proc_StartProcess(Uint16 SS, Uint Stack, Uint Flags, Uint16 CS, Uint IP);
void Proc_CallFaultHandler(tThread *Thread);
-void Proc_Scheduler();
+void Proc_Scheduler(int CPU);
// === GLOBALS ===
// --- Multiprocessing ---
// === CODE ===
/**
- * \fn void ArchThreads_Init()
+ * \fn void ArchThreads_Init(void)
* \brief Starts the process scheduler
*/
-void ArchThreads_Init()
+void ArchThreads_Init(void)
{
Uint pos = 0;
#endif
/**
- * \fn void Proc_Start()
+ * \fn void Proc_Start(void)
* \brief Start process scheduler
*/
-void Proc_Start()
+void Proc_Start(void)
{
// Start Interrupts (and hence scheduler)
__asm__ __volatile__("sti");
}
/**
- * \fn tThread *Proc_GetCurThread()
+ * \fn tThread *Proc_GetCurThread(void)
* \brief Gets the current thread
*/
-tThread *Proc_GetCurThread()
+tThread *Proc_GetCurThread(void)
{
#if USE_MP
//return gaCPUs[ gaAPIC_to_CPU[gpMP_LocalAPIC->ID.Val&0xFF] ].Current;
}
/**
- * \fn void Proc_ChangeStack()
+ * \fn void Proc_ChangeStack(void)
* \brief Swaps the current stack for a new one (in the proper stack reigon)
*/
-void Proc_ChangeStack()
+void Proc_ChangeStack(void)
{
Uint rsp, rbp;
Uint tmp_rbp, old_rsp;
}
/**
- * \fn int Proc_SpawnWorker()
+ * \fn int Proc_SpawnWorker(void)
* \brief Spawns a new worker thread
*/
-int Proc_SpawnWorker()
+int Proc_SpawnWorker(void)
{
tThread *new, *cur;
Uint rip, rsp, rbp;
}
/**
- * \fn Uint Proc_MakeUserStack()
+ * \fn Uint Proc_MakeUserStack(void)
* \brief Creates a new user stack
*/
-Uint Proc_MakeUserStack()
+Uint Proc_MakeUserStack(void)
{
int i;
Uint base = USER_STACK_TOP - USER_STACK_SZ;
[BITS 32]
-KERNEL_BASE equ 0xFFFF800000000000
+;KERNEL_BASE equ 0xFFFF800000000000
+KERNEL_BASE equ 0xFFFFFFFF80000000
[section .multiboot]
mboot:
test edx, 1<<29
jz .not64bitCapable
- ; Enable PAE
+ ; Enable PGE (Page Global Enable)
+ ; + PAE (Physical Address Extension)
+ ; + PSE (Page Size Extensions)
mov eax, cr4
- or eax, 0x80|0x20
+ or eax, 0x80|0x20|0x10
mov cr4, eax
; Load PDP4
[global gInitialPML4]
gInitialPML4: ; Covers 256 TiB (Full 48-bit Virtual Address Space)
dd gInitialPDP - KERNEL_BASE + 3, 0 ; Identity Map Low 4Mb
- times 256-1 dq 0
- dd gInitialPDP - KERNEL_BASE + 3, 0 ; Map Low 4Mb to kernel base
- times 256-1-4 dq 0
+ times 512-1-4 dq 0
dd gInitialPML4 - KERNEL_BASE + 3, 0 ; Fractal Mapping
dq 0
dq 0
- dq 0
+ dd gHighPDP - KERNEL_BASE + 3, 0 ; Map Low 4Mb to kernel base
gInitialPDP: ; Covers 512 GiB
dd gInitialPD - KERNEL_BASE + 3, 0
times 511 dq 0
+gHighPDP: ; Covers 512 GiB
+ times 510 dq 0
+ dq 0 + 0x143 ; 1 GiB Page from zero
+ dq 0
+
gInitialPD: ; Covers 1 GiB
dd gInitialPT1 - KERNEL_BASE + 3, 0
dd gInitialPT2 - KERNEL_BASE + 3, 0
gInitialPT1: ; Covers 2 MiB
%assign i 0
%rep 512
- dq i*4096+3
+ dq i*4096+0x103
%assign i i+1
%endrep
gInitialPT2: ; 2 MiB
%assign i 512
%rep 512
- dq i*4096+3
+ dq i*4096+0x103
%assign i i+1
%endrep
; Acess2 x86_64 Port
;
[bits 64]
-KERNEL_BASE equ 0xFFFF800000000000
+;KERNEL_BASE equ 0xFFFF800000000000
+KERNEL_BASE equ 0xFFFFFFFF80000000
[extern kmain]
extern int Proc_Clone(Uint *Err, Uint Flags);
extern char *Threads_GetName(int ID);
extern void Threads_Exit(int, int);
-extern Uint MM_ClearUser();
+extern Uint MM_ClearUser(void);
extern void Proc_StartUser(Uint Entrypoint, Uint *Bases, int ArgC, char **ArgV, char **EnvP, int DataSize);
extern tKernelSymbol gKernelSymbols[];
extern void gKernelSymbolsEnd;
// === PROTOTYPES ===
int putDebugChar(char ch);
- int getDebugChar();
+ int getDebugChar(void);
static void Debug_Putchar(char ch);
-static void Debug_Puts(char *Str);
+static void Debug_Puts(int DbgOnly, char *Str);
void Debug_Fmt(const char *format, va_list args);
// === GLOBALS ===
outb(GDB_SERIAL_PORT, ch);
return 0;
}
-int getDebugChar()
+int getDebugChar(void)
{
if(!gbGDB_SerialSetup) {
outb(GDB_SERIAL_PORT + 1, 0x00); // Disable all interrupts
return inb(GDB_SERIAL_PORT);
}
-static void Debug_Putchar(char ch)
+static void Debug_PutCharDebug(char ch)
{
#if DEBUG_TO_E9
__asm__ __volatile__ ( "outb %%al, $0xe9" :: "a"(((Uint8)ch)) );
while( (inb(SERIAL_PORT + 5) & 0x20) == 0 );
outb(SERIAL_PORT, ch);
#endif
-
+}
+
+static void Debug_Putchar(char ch)
+{
+ Debug_PutCharDebug(ch);
if( !gbDebug_IsKPanic )
{
if(gbInPutChar) return ;
KernelPanic_PutChar(ch);
}
-static void Debug_Puts(char *Str)
+static void Debug_Puts(int UseKTerm, char *Str)
{
int len = 0;
while( *Str )
{
- #if DEBUG_TO_E9
- __asm__ __volatile__ ( "outb %%al, $0xe9" :: "a" ((Uint8)*Str) );
- #endif
-
- #if DEBUG_TO_SERIAL
- if(!gbDebug_SerialSetup) {
- outb(SERIAL_PORT + 1, 0x00); // Disable all interrupts
- outb(SERIAL_PORT + 3, 0x80); // Enable DLAB (set baud rate divisor)
- outb(SERIAL_PORT + 0, 0x03); // Set divisor to 3 (lo byte) 38400 baud
- outb(SERIAL_PORT + 1, 0x00); // (hi byte)
- outb(SERIAL_PORT + 3, 0x03); // 8 bits, no parity, one stop bit
- outb(SERIAL_PORT + 2, 0xC7); // Enable FIFO with 14-byte threshold and clear it
- outb(SERIAL_PORT + 4, 0x0B); // IRQs enabled, RTS/DSR set
- gbDebug_SerialSetup = 1;
- }
- while( (inb(SERIAL_PORT + 5) & 0x20) == 0 );
- outb(SERIAL_PORT, *Str);
- #endif
+ Debug_PutCharDebug( *Str );
if( gbDebug_IsKPanic )
KernelPanic_PutChar(*Str);
Str -= len;
- if( !gbDebug_IsKPanic && giDebug_KTerm != -1)
+ if( UseKTerm && !gbDebug_IsKPanic && giDebug_KTerm != -1)
{
if(gbInPutChar) return ;
gbInPutChar = 1;
}
}
+void Debug_DbgOnlyFmt(const char *format, va_list args)
+{
+ char buf[DEBUG_MAX_LINE_LEN];
+ int len;
+ buf[DEBUG_MAX_LINE_LEN-1] = 0;
+ len = vsnprintf(buf, DEBUG_MAX_LINE_LEN-1, format, args);
+ //if( len < DEBUG_MAX_LINE )
+ // do something
+ Debug_Puts(0, buf);
+}
+
void Debug_Fmt(const char *format, va_list args)
{
- #if DEBUG_USE_VSNPRINTF
char buf[DEBUG_MAX_LINE_LEN];
int len;
buf[DEBUG_MAX_LINE_LEN-1] = 0;
len = vsnprintf(buf, DEBUG_MAX_LINE_LEN-1, format, args);
//if( len < DEBUG_MAX_LINE )
// do something
- Debug_Puts(buf);
+ Debug_Puts(1, buf);
return ;
- #else
- char c, pad = ' ';
- int minSize = 0, len;
- char tmpBuf[34]; // For Integers
- char *p = NULL;
- int isLongLong = 0;
- Uint64 arg;
- int bPadLeft = 0;
-
- while((c = *format++) != 0)
- {
- // Non control character
- if( c != '%' ) {
- Debug_Putchar(c);
- continue;
- }
-
- c = *format++;
-
- // Literal %
- if(c == '%') {
- Debug_Putchar('%');
- continue;
- }
-
- // Pointer
- if(c == 'p') {
- Uint ptr = va_arg(args, Uint);
- Debug_Putchar('*'); Debug_Putchar('0'); Debug_Putchar('x');
- p = tmpBuf;
- itoa(p, ptr, 16, BITS/4, '0');
- goto printString;
- }
-
- // Get Argument
- arg = va_arg(args, Uint);
-
- // - Padding Side Flag
- if(c == '+') {
- bPadLeft = 1;
- c = *format++;
- }
-
- // Padding
- if(c == '0') {
- pad = '0';
- c = *format++;
- } else
- pad = ' ';
-
- // Minimum length
- minSize = 1;
- if('1' <= c && c <= '9')
- {
- minSize = 0;
- while('0' <= c && c <= '9')
- {
- minSize *= 10;
- minSize += c - '0';
- c = *format++;
- }
- }
-
- // Long (default)
- isLongLong = 0;
- if(c == 'l') {
- c = *format++;
- if(c == 'l') {
- #if BITS == 32
- arg |= va_arg(args, Uint);
- #endif
- c = *format++;
- isLongLong = 1;
- }
- }
-
- p = tmpBuf;
- switch (c) {
- case 'd':
- case 'i':
- if( (isLongLong && arg >> 63) || (!isLongLong && arg >> 31) ) {
- Debug_Putchar('-');
- arg = -arg;
- }
- itoa(p, arg, 10, minSize, pad);
- goto printString;
- case 'u':
- itoa(p, arg, 10, minSize, pad);
- goto printString;
- case 'x':
- itoa(p, arg, 16, minSize, pad);
- goto printString;
- case 'o':
- itoa(p, arg, 8, minSize, pad);
- goto printString;
- case 'b':
- itoa(p, arg, 2, minSize, pad);
- goto printString;
-
- printString:
- if(!p) p = "(null)";
- while(*p) Debug_Putchar(*p++);
- break;
-
- case 'B': //Boolean
- if(arg) Debug_Puts("True");
- else Debug_Puts("False");
- break;
-
- case 's':
- p = (char*)(Uint)arg;
- if(!p) p = "(null)";
- len = strlen(p);
- if( !bPadLeft ) while(len++ < minSize) Debug_Putchar(pad);
- while(*p) Debug_Putchar(*p++);
- if( bPadLeft ) while(len++ < minSize) Debug_Putchar(pad);
- break;
-
- // Single Character / Array
- case 'c':
- if(minSize == 1) {
- Debug_Putchar(arg);
- break;
- }
- p = (char*)(Uint)arg;
- if(!p) goto printString;
- while(minSize--) Debug_Putchar(*p++);
- break;
-
- default:
- Debug_Putchar(arg);
- break;
- }
- }
- #endif
}
void Debug_KernelPanic()
va_end(args);
}
+/**
+ * \fn void Debug(char *Msg, ...)
+ * \brief Print only to the debug channel
+ */
+void Debug(char *Fmt, ...)
+{
+ va_list args;
+
+ Debug_Puts(0, "Debug: ");
+ va_start(args, Fmt);
+ Debug_DbgOnlyFmt(Fmt, args);
+ va_end(args);
+ Debug_PutCharDebug('\n');
+}
/**
* \fn void Log(char *Msg, ...)
*/
{
va_list args;
- Debug_Puts("Log: ");
+ Debug_Puts(1, "Log: ");
va_start(args, Fmt);
Debug_Fmt(Fmt, args);
va_end(args);
void Warning(char *Fmt, ...)
{
va_list args;
- Debug_Puts("Warning: ");
+ Debug_Puts(1, "Warning: ");
va_start(args, Fmt);
Debug_Fmt(Fmt, args);
va_end(args);
Debug_KernelPanic();
- Debug_Puts("Panic: ");
+ Debug_Puts(1, "Panic: ");
va_start(args, Fmt);
Debug_Fmt(Fmt, args);
va_end(args);
while(i--) Debug_Putchar(' ');
- Debug_Puts(FuncName); Debug_Puts(": (");
+ Debug_Puts(1, FuncName); Debug_Puts(1, ": (");
while(*ArgTypes)
{
pos = strpos(ArgTypes, ' ');
if(pos != -1) ArgTypes[pos] = '\0';
if(pos == -1 || pos > 1) {
- Debug_Puts(ArgTypes+1);
+ Debug_Puts(1, ArgTypes+1);
Debug_Putchar('=');
}
if(pos != -1) ArgTypes[pos] = ' ';
while(i--) Debug_Putchar(' ');
- Debug_Puts(FuncName); Debug_Puts(": ");
+ Debug_Puts(1, FuncName); Debug_Puts(1, ": ");
Debug_Fmt(Fmt, args);
va_end(args);
// Indenting
while(i--) Debug_Putchar(' ');
- Debug_Puts(FuncName); Debug_Puts(": RETURN");
+ Debug_Puts(1, FuncName); Debug_Puts(1, ": RETURN");
// No Return
if(RetType == '-') {
Debug_Putchar(' ');
switch(RetType)
{
- case 'n': Debug_Puts("NULL"); break;
+ case 'n': Debug_Puts(1, "NULL"); break;
case 'p': Debug_Fmt("%p", args); break;
case 's': Debug_Fmt("'%s'", args); break;
case 'i': Debug_Fmt("%i", args); break;
{
Uint8 *cdat = Data;
Uint pos = 0;
- Debug_Puts(Header);
+ Debug_Puts(1, Header);
LogF(" (Hexdump of %p)\n", Data);
while(Length >= 16)
}
// --- EXPORTS ---
+EXPORT(Debug);
EXPORT(Log);
EXPORT(Warning);
EXPORT(Debug_Enter);
} t_dmaChannel;\r
\r
// === PROTOTYPES ===\r
- int DMA_Install();\r
+ int DMA_Install(char **Arguments);\r
void DMA_SetChannel(int Channel, int length, int read);\r
int DMA_ReadData(int channel, int count, void *buffer);\r
\r
\r
// === CODE ===\r
/**\r
- * \fn int DMA_Install()\r
+ * \fn int DMA_Install(void)\r
* \brief Initialise DMA channels\r
*/\r
-int DMA_Install()\r
+int DMA_Install(char **Arguments)\r
{\r
Uint i;\r
for(i=8;i--;)\r
#define USE_KERNEL_MAGIC 1
// === IMPORTS ===
-void Threads_Dump();
+void Threads_Dump(void);
// === PROTOTYPES ===
int KB_Install(char **Arguments);
-void KB_IRQHandler();
+void KB_IRQHandler(int IRQNum);
void KB_AddBuffer(char ch);
Uint64 KB_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Dest);
-void KB_UpdateLEDs();
+void KB_UpdateLEDs(void);
int KB_IOCtl(tVFS_Node *Node, int Id, void *Data);
// === GLOBALS ===
* \fn void KB_IRQHandler()
* \brief Called on a keyboard IRQ
*/
-void KB_IRQHandler()
+void KB_IRQHandler(int IRQNum)
{
Uint8 scancode;
Uint32 ch;
}
/**
- * \fn void KB_UpdateLEDs()
+ * \fn void KB_UpdateLEDs(void)
* \brief Updates the status of the keyboard LEDs
*/
-void KB_UpdateLEDs()
+void KB_UpdateLEDs(void)
{
Uint8 leds;
\r
// Build Portmap\r
gaPCI_PortBitmap = malloc( 1 << 13 );\r
+ if( !gaPCI_PortBitmap ) {\r
+ Log_Error("PCI", "Unable to allocate %i bytes for bitmap", 1 << 13);\r
+ return MODULE_ERR_MALLOC;\r
+ }\r
memset( gaPCI_PortBitmap, 0, 1 << 13 );\r
for( i = 0; i < MAX_RESERVED_PORT / 32; i ++ )\r
gaPCI_PortBitmap[i] = -1;\r
space += SPACE_STEP;\r
tmpPtr = realloc(gPCI_Devices, space*sizeof(tPCIDevice));\r
if(tmpPtr == NULL)\r
- break;\r
+ return MODULE_ERR_MALLOC;\r
gPCI_Devices = tmpPtr;\r
}\r
if(devInfo.oc == PCI_OC_PCIBRIDGE)\r
break;\r
}\r
}\r
- if(tmpPtr != gPCI_Devices)\r
- break;\r
}\r
- if(tmpPtr != gPCI_Devices)\r
- break;\r
}\r
\r
- if(giPCI_DeviceCount == 0)\r
+ if(giPCI_DeviceCount == 0) {\r
+ Log_Notice("PCI", "No devices were found");\r
return MODULE_ERR_NOTNEEDED;\r
+ }\r
\r
tmpPtr = realloc(gPCI_Devices, giPCI_DeviceCount*sizeof(tPCIDevice));\r
if(tmpPtr == NULL)\r
((tVideo_IOCtl_Mode*)Data)->height = VGA_HEIGHT;
((tVideo_IOCtl_Mode*)Data)->bpp = 4;
return 1;
+
+ case VIDEO_IOCTL_SETBUFFORMAT:
+ return 0;
+
case VIDEO_IOCTL_SETCURSOR:
VGA_int_SetCursor( ((tVideo_IOCtl_Pos*)Data)->x, ((tVideo_IOCtl_Pos*)Data)->y );
return 1;
{
Uint32 val;
int i;
+
+ // Iterate
for( i = 0; i < Count; i++ )
{
- if( Buffer[i] == 0x1B ) // Escape Sequence
+ // Handle escape sequences
+ if( Buffer[i] == 0x1B )
{
i ++;
i += VT_int_ParseEscape(Term, (char*)&Buffer[i]) - 1;
continue;
}
+ // Fast check for non UTF-8
if( Buffer[i] < 128 ) // Plain ASCII
VT_int_PutChar(Term, Buffer[i]);
else { // UTF-8
- i += ReadUTF8(&Buffer[i], &val);
+ i += ReadUTF8(&Buffer[i], &val) - 1;
VT_int_PutChar(Term, val);
}
}
void VT_int_PutChar(tVTerm *Term, Uint32 Ch)
{
int i;
- //ENTER("pTerm xCh", Term, Ch);
- //LOG("Term = {WritePos:%i, ViewPos:%i}", Term->WritePos, Term->ViewPos);
-
+
switch(Ch)
{
case '\0': return; // Ignore NULL byte
}
// Move Screen
+ // - Check if we need to scroll the entire scrollback buffer
if(Term->WritePos >= Term->Width*Term->Height*(giVT_Scrollback+1))
{
int base, i;
+
+ //Debug("Scrolling entire buffer");
+
+ // Move back by one
Term->WritePos -= Term->Width;
+ // Update the scren
VT_int_UpdateScreen( Term, 0 );
// Update view position
- base = Term->Width*Term->Height*(giVT_Scrollback-1);
- if(Term->ViewPos < base) Term->ViewPos += Term->Width;
- if(Term->ViewPos > base) Term->ViewPos = base;
+ base = Term->Width*Term->Height*(giVT_Scrollback);
+ if(Term->ViewPos < base)
+ Term->ViewPos += Term->Width;
+ if(Term->ViewPos > base)
+ Term->ViewPos = base;
// Scroll terminal cache
base = Term->Width*(Term->Height*(giVT_Scrollback+1)-1);
-
- // Scroll Back
memcpy(
Term->Text,
&Term->Text[Term->Width],
Term->Text[ base + i ].Colour = Term->CurColour;
}
- //LOG("Scrolled buffer");
VT_int_ScrollFramebuffer( Term );
VT_int_UpdateScreen( Term, 0 );
}
+ // Ok, so we only need to scroll the screen
else if(Term->WritePos >= Term->ViewPos + Term->Width*Term->Height)
{
- //LOG("Scrolled screen");
+ //Debug("Term->WritePos (%i) >= %i",
+ // Term->WritePos,
+ // Term->ViewPos + Term->Width*Term->Height
+ // );
+ //Debug("Scrolling screen only");
+
+ // Update the last line
Term->WritePos -= Term->Width;
VT_int_UpdateScreen( Term, 0 );
Term->WritePos += Term->Width;
+ // Scroll
Term->ViewPos += Term->Width;
+ //Debug("Term->ViewPos = %i", Term->ViewPos);
VT_int_ScrollFramebuffer( Term );
VT_int_UpdateScreen( Term, 0 );
}
Uint16 SrcX, SrcY;
Uint16 W, H;
} PACKED buf;
+
// Only update if this is the current terminal
if( Term != gpVT_CurTerm ) return;
- // This should only be called in text mode
-
+ // Switch to 2D Command Stream
tmp = VIDEO_BUFFMT_2DSTREAM;
VFS_IOCtl(giVT_OutputDevHandle, VIDEO_IOCTL_SETBUFFORMAT, &tmp);
+ // BLIT from 0,0 to 0,giVT_CharHeight
buf.Op = VIDEO_2DOP_BLIT;
buf.DstX = 0; buf.DstY = 0;
buf.SrcX = 0; buf.SrcY = giVT_CharHeight;
buf.W = Term->Width * giVT_CharWidth;
buf.H = (Term->Height-1) * giVT_CharHeight;
+ VFS_WriteAt(giVT_OutputDevHandle, 0, sizeof(buf), &buf);
- VFS_WriteAt(giVT_OutputDevHandle, 0, 1+12, &buf);
-
- // Restore old mode
+ // Restore old mode (this function is only called during text mode)
tmp = VIDEO_BUFFMT_TEXT;
VFS_IOCtl(giVT_OutputDevHandle, VIDEO_IOCTL_SETBUFFORMAT, &tmp);
}
switch( Term->Mode )
{
case TERM_MODE_TEXT:
+ // Re copy the entire screen?
if(UpdateAll) {
- //LOG("UpdateAll = 1");
- //LOG("VFS_WriteAt(0x%x, 0, %i*sizeof(tVT_Char), &Term->Text[%i])",
- // giVT_OutputDevHandle, Term->Width*Term->Height, Term->ViewPos);
VFS_WriteAt(
giVT_OutputDevHandle,
0,
Term->Width*Term->Height*sizeof(tVT_Char),
&Term->Text[Term->ViewPos]
);
- } else {
+ }
+ // Only copy the current line
+ else {
int pos = Term->WritePos - Term->WritePos % Term->Width;
- //LOG("UpdateAll = 0");
- //LOG("VFS_WriteAt(0x%x, %i*sizeof(tVT_Char), %i*sizeof(tVT_Char), &Term->Text[%i])",
- // giVT_OutputDevHandle, (pos - Term->ViewPos), Term->Width, pos);
VFS_WriteAt(
giVT_OutputDevHandle,
(pos - Term->ViewPos)*sizeof(tVT_Char),
return Length-rem;
}
+ //Log("Handlers->Blit{%}}(%p, %i,%i, %i,%i, %i,%i)",
+ // Handlers->Blit, Ent,
+ // *(Uint16*)(&stream[0]), *(Uint16*)(&stream[2]),
+ // *(Uint16*)(&stream[4]), *(Uint16*)(&stream[6]),
+ // *(Uint16*)(&stream[8]), *(Uint16*)(&stream[10])
+ // );
Handlers->Blit(
Ent,
*(Uint16*)(&stream[0]), *(Uint16*)(&stream[2]),
#define MAGIC_USED 0x862B0505 // MAGIC_FOOT ^ MAGIC_FREE
// === PROTOTYPES ===
-void Heap_Install();
+void Heap_Install(void);
void *Heap_Extend(int Bytes);
void *Heap_Merge(tHeapHead *Head);
void *malloc(size_t Bytes);
void free(void *Ptr);
-void Heap_Dump();
+void Heap_Dump(void);
// === GLOBALS ===
tSpinlock glHeap;
void *gHeapEnd;
// === CODE ===
-void Heap_Install()
+void Heap_Install(void)
{
gHeapStart = (void*)MM_KHEAP_BASE;
gHeapEnd = (void*)MM_KHEAP_BASE;
}
#if WARNINGS
-void Heap_Dump()
+void Heap_Dump(void)
{
tHeapHead *head;
tHeapFoot *foot;
* \name Debugging and Errors
* \{
*/
-extern void Debug_KernelPanic(); //!< Initiate a kernel panic
+extern void Debug_KernelPanic(void); //!< Initiate a kernel panic
extern void Panic(char *Msg, ...); //!< Print a panic message (initiates a kernel panic)
extern void Warning(char *Msg, ...); //!< Print a warning message
extern void LogF(char *Fmt, ...); //!< Print a log message without a trailing newline
extern void Log(char *Fmt, ...); //!< Print a log message
+extern void Debug(char *Fmt, ...); //!< Print a debug message (doesn't go to KTerm)
extern void LogV(char *Fmt, va_list Args); //!< va_list Log message
extern void Debug_Enter(char *FuncName, char *ArgTypes, ...);
extern void Debug_Log(char *FuncName, char *Fmt, ...);
* \brief Allocate a single physical page
* \return Physical address allocated
*/
-extern tPAddr MM_AllocPhys();
+extern tPAddr MM_AllocPhys(void);
/**
* \brief Allocate a contiguous range of physical pages
* \param Pages Number of pages to allocate
* \}
*/
-extern Uint rand();
+extern Uint rand(void);
extern int CallWithArgArray(void *Function, int NArgs, Uint *Args);
// --- Heap ---
* \brief Create a timestamp from a time
*/
extern Sint64 timestamp(int sec, int mins, int hrs, int day, int month, int year);
-extern Sint64 now();
+extern Sint64 now(void);
extern int Time_CreateTimer(int Delta, void *Callback, void *Argument);
extern void Time_RemoveTimer(int ID);
extern void Time_Delay(int Delay);
* \name Threads and Processes
* \{
*/
-extern int Proc_SpawnWorker();
+extern int Proc_SpawnWorker(void);
extern int Proc_Spawn(char *Path);
-extern void Threads_Exit();
-extern void Threads_Yield();
-extern void Threads_Sleep();
+extern void Threads_Exit(int TID, int Status);
+extern void Threads_Yield(void);
+extern void Threads_Sleep(void);
extern void Threads_WakeTID(tTID Thread);
-extern tPID Threads_GetPID();
-extern tTID Threads_GetTID();
-extern tUID Threads_GetUID();
-extern tGID Threads_GetGID();
+extern tPID Threads_GetPID(void);
+extern tTID Threads_GetTID(void);
+extern tUID Threads_GetUID(void);
+extern tGID Threads_GetGID(void);
extern int SpawnTask(tThreadFunction Function, void *Arg);
extern Uint *Threads_GetCfgPtr(int Id);
extern int Threads_SetName(char *NewName);
struct sModule *Next; //!< Next module in list (not to be touched by the driver)
char *Name; //!< Module Name/Identifier
int (*Init)(char **Arguments); //!< Module initialiser / entrypoint
- void (*Deinit)(); //!< Cleanup Function
+ void (*Deinit)(void); //!< Cleanup Function
char **Dependencies; //!< NULL terminated list of dependencies
} PACKED tModule;
#define GETMSG_IGNORE ((void*)-1)
// === FUNCTIONS ===
-extern tThread *Proc_GetCurThread();
+extern tThread *Proc_GetCurThread(void);
extern tThread *Threads_GetThread(Uint TID);
extern void Threads_Wake(tThread *Thread);
extern void Threads_AddActive(tThread *Thread);
* \{
*/
/**
- * \fn int Inode_GetHandle()
+ * \fn int Inode_GetHandle(void)
* \brief Gets a unique handle to the Node Cache
* \return A unique handle for use for the rest of the Inode_* functions
*/
-extern int Inode_GetHandle();
+extern int Inode_GetHandle(void);
/**
* \fn tVFS_Node *Inode_GetCache(int Handle, Uint64 Inode)
* \brief Gets an inode from the node cache
* \brief Initialise the VFS (called by system.c)
* \return Boolean Success
*/
-extern int VFS_Init();
+extern int VFS_Init(void);
/**
* \brief Open a file
extern int Proc_Execve(char *File, char **ArgV, char **EnvP);
extern Uint Binary_Load(char *file, Uint *entryPoint);
extern int Threads_SetName(char *NewName);
-extern int Threads_GetPID();
-extern int Threads_GetTID();
-extern tUID Threads_GetUID();
extern int Threads_SetUID(Uint *errno, tUID ID);
-extern tGID Threads_GetGID();
extern int Threads_SetGID(Uint *errno, tGID ID);
extern int Threads_SetFaultHandler(Uint Handler);
} tConfigCommand;
// === IMPORTS ===
-extern void Arch_LoadBootModules();
-extern int Modules_LoadBuiltins();
+extern void Arch_LoadBootModules(void);
+extern int Modules_LoadBuiltins(void);
extern void Modules_SetBuiltinParams(char *Name, char *ArgString);
extern void Debug_SetKTerminal(char *File);
};
// === IMPORTS ===
-extern void ArchThreads_Init();
-extern void Proc_Start();
-extern tThread *Proc_GetCurThread();
+extern void ArchThreads_Init(void);
+extern void Proc_Start(void);
+extern tThread *Proc_GetCurThread(void);
extern int Proc_Clone(Uint *Err, Uint Flags);
extern void Proc_CallFaultHandler(tThread *Thread);
// === PROTOTYPES ===
-void Threads_Init();
+void Threads_Init(void);
int Threads_SetName(char *NewName);
char *Threads_GetName(int ID);
void Threads_SetTickets(int Num);
tThread *Threads_int_GetPrev(tThread **List, tThread *Thread);
void Threads_Exit(int TID, int Status);
void Threads_Kill(tThread *Thread, int Status);
-void Threads_Yield();
-void Threads_Sleep();
+void Threads_Yield(void);
+void Threads_Sleep(void);
void Threads_Wake(tThread *Thread);
void Threads_AddActive(tThread *Thread);
- int Threads_GetPID();
- int Threads_GetTID();
-tUID Threads_GetUID();
+ int Threads_GetPID(void);
+ int Threads_GetTID(void);
+tUID Threads_GetUID(void);
int Threads_SetUID(Uint *Errno, tUID ID);
-tGID Threads_GetGID();
+tGID Threads_GetGID(void);
int Threads_SetGID(Uint *Errno, tUID ID);
-void Threads_Dump();
+void Threads_Dump(void);
// === GLOBALS ===
// -- Core Thread --
// === CODE ===
/**
- * \fn void Threads_Init()
+ * \fn void Threads_Init(void)
* \brief Initialse the thread list
*/
-void Threads_Init()
+void Threads_Init(void)
{
ArchThreads_Init();
}
/**
- * \fn void Threads_Yield()
+ * \fn void Threads_Yield(void)
* \brief Yield remainder of timeslice
*/
-void Threads_Yield()
+void Threads_Yield(void)
{
Proc_GetCurThread()->Remaining = 0;
HALT();
}
/**
- * \fn void Threads_Sleep()
+ * \fn void Threads_Sleep(void)
* \brief Take the current process off the run queue
*/
-void Threads_Sleep()
+void Threads_Sleep(void)
{
tThread *cur = Proc_GetCurThread();
tThread *thread;
}
// --- Process Structure Access Functions ---
-tPID Threads_GetPID()
+tPID Threads_GetPID(void)
{
return Proc_GetCurThread()->TGID;
}
-tTID Threads_GetTID()
+tTID Threads_GetTID(void)
{
return Proc_GetCurThread()->TID;
}
-tUID Threads_GetUID()
+tUID Threads_GetUID(void)
{
return Proc_GetCurThread()->UID;
}
-tGID Threads_GetGID()
+tGID Threads_GetGID(void)
{
return Proc_GetCurThread()->GID;
}
}
/**
- * \fn void Threads_Dump()
+ * \fn void Threads_Dump(void)
* \brief Dums a list of currently running threads
*/
-void Threads_Dump()
+void Threads_Dump(void)
{
tThread *thread;
tThread *cur = Proc_GetCurThread();
} tTimer;
// === PROTOTYPES ===
-void Timer_CallTimers();
+Sint64 now(void);
+void Timer_CallTimers(void);
// === GLOBALS ===
Uint64 giTicks = 0;
* \fn Sint64 now()
* \brief Return the current timestamp
*/
-Sint64 now()
+Sint64 now(void)
{
return giTimestamp;
}
char *Root_ReadDir(tVFS_Node *Node, int Pos);
Uint64 Root_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
Uint64 Root_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
-tRamFS_File *Root_int_AllocFile();
+tRamFS_File *Root_int_AllocFile(void);
// === GLOBALS ===
tVFS_Driver gRootFS_Info = {
}
/**
- * \fn tRamFS_File *Root_int_AllocFile()
+ * \fn tRamFS_File *Root_int_AllocFile(void)
* \brief Allocates a file from the pool
*/
-tRamFS_File *Root_int_AllocFile()
+tRamFS_File *Root_int_AllocFile(void)
{
int i;
for( i = 0; i < MAX_FILES; i ++ )
extern tVFS_Driver gDevFS_Info;
// === PROTOTYPES ===
- int VFS_Init();
+ int VFS_Init(void);
char *VFS_GetTruePath(char *Path);
void VFS_GetMemPath(char *Dest, void *Base, Uint Length);
tVFS_Driver *VFS_GetFSByName(char *Name);
int VFS_AddDriver(tVFS_Driver *Info);
-void VFS_UpdateDriverFile();
+void VFS_UpdateDriverFile(void);
// === EXPORTS ===
EXPORT(VFS_AddDriver);
// === CODE ===
/**
- * \fn int VFS_Init()
+ * \fn int VFS_Init(void)
* \brief Initialises the VFS for use by the kernel and user
*/
-int VFS_Init()
+int VFS_Init(void)
{
// Core Drivers
gVFS_Drivers = &gRootFS_Info;
}
/**
- * \fn void VFS_UpdateDriverFile()
+ * \fn void VFS_UpdateDriverFile(void)
* \brief Updates the driver list file
*/
-void VFS_UpdateDriverFile()
+void VFS_UpdateDriverFile(void)
{
tVFS_Driver *drv;
int len = 0;
// === PROTOTYPES ===
int VFS_Mount(char *Device, char *MountPoint, char *Filesystem, char *Options);
-void VFS_UpdateMountFile();
+void VFS_UpdateMountFile(void);
// === GLOBALS ===
int glVFS_MountList = 0;
*
* Updates the ProcFS mounts file buffer to match the current mounts list.
*/
-void VFS_UpdateMountFile()
+void VFS_UpdateMountFile(void)
{
int len = 0;
char *buf;
ARCHDIR = x86
+DYNMOD_FLAGS := -mcmodel=small -fPIC
+
LD = ld
DISASM = objdump -d -M x86-64
-KERNEL_CFLAGS = -mcmodel=large -nostdlib
+KERNEL_CFLAGS := -mcmodel=kernel -nostdlib
+DYNMOD_CFLAGS := -mcmodel=small -fPIC
ARCHDIR = x86_64
Vesa_2D_Blit\r
};\r
\r
-//CODE\r
+// === CODE ===\r
int Vesa_Install(char **Arguments)\r
{\r
tVesa_CallInfo *info;\r
);\r
\r
// Sanity Check\r
- if(y > heightInChars) {\r
+ if(y >= heightInChars) {\r
LEAVE('i', 0);\r
return 0;\r
}\r
\r
void Vesa_2D_Blit(void *Ent, Uint16 DstX, Uint16 DstY, Uint16 SrcX, Uint16 SrcY, Uint16 W, Uint16 H)\r
{\r
- int scrnwidth = gVesa_Modes[giVesaCurrentMode].width;\r
- int dst = DstY*scrnwidth + DstX;\r
- int src = SrcY*scrnwidth + SrcX;\r
+ int scrnpitch = gVesa_Modes[giVesaCurrentMode].pitch;\r
+ int dst = DstY*scrnpitch + DstX;\r
+ int src = SrcY*scrnpitch + SrcX;\r
int tmp;\r
\r
//Log("Vesa_2D_Blit: (Ent=%p, DstX=%i, DstY=%i, SrcX=%i, SrcY=%i, W=%i, H=%i)",\r
// Ent, DstX, DstY, SrcX, SrcY, W, H);\r
\r
- if(SrcX + W > scrnwidth)\r
- W = scrnwidth - SrcX;\r
- if(DstX + W > scrnwidth)\r
- W = scrnwidth - DstX;\r
+ if(SrcX + W > gVesa_Modes[giVesaCurrentMode].width)\r
+ W = gVesa_Modes[giVesaCurrentMode].width - SrcX;\r
+ if(DstX + W > gVesa_Modes[giVesaCurrentMode].width)\r
+ W = gVesa_Modes[giVesaCurrentMode].width - DstX;\r
if(SrcY + H > gVesa_Modes[giVesaCurrentMode].height)\r
H = gVesa_Modes[giVesaCurrentMode].height - SrcY;\r
if(DstY + H > gVesa_Modes[giVesaCurrentMode].height)\r
H = gVesa_Modes[giVesaCurrentMode].height - DstY;\r
\r
+ //Debug("W = %i, H = %i", W, H);\r
+ \r
if( dst > src ) {\r
// Reverse copy\r
- dst += H*scrnwidth;\r
- src += H*scrnwidth;\r
+ Debug("Reverse scroll");\r
+ dst += H*scrnpitch;\r
+ src += H*scrnpitch;\r
while( H -- ) {\r
- dst -= scrnwidth;\r
- src -= scrnwidth;\r
+ dst -= scrnpitch;\r
+ src -= scrnpitch;\r
tmp = W;\r
for( tmp = W; tmp --; ) {\r
- *((Uint32*)gpVesa_Framebuffer + dst + tmp) = *((Uint32*)gpVesa_Framebuffer + src + tmp);\r
+ *(Uint32*)(gpVesa_Framebuffer + dst + tmp) = *(Uint32*)(gpVesa_Framebuffer + src + tmp);\r
}\r
}\r
}\r
else {\r
// Normal copy is OK\r
+ Debug("memcpy scroll");\r
while( H -- ) {\r
- memcpy((Uint32*)gpVesa_Framebuffer + dst, (Uint32*)gpVesa_Framebuffer + src, W);\r
- dst += scrnwidth;\r
- src += scrnwidth;\r
+ memcpy((void*)gpVesa_Framebuffer + dst, (void*)gpVesa_Framebuffer + src, W);\r
+ dst += scrnpitch;\r
+ src += scrnpitch;\r
}\r
}\r
}\r
OBJ += ipv4.o icmp.o
OBJ += ipv6.o
OBJ += udp.o tcp.o
-NAME = IPStack
+NAME := IPStack
+CATEGORY :=
-include ../Makefile.tpl
-include $(CFGFILES)
CPPFLAGS := -I$(ACESSDIR)/Kernel/include -I$(ACESSDIR)/Kernel/arch/$(ARCHDIR)/include -DARCH=$(ARCH) $(_CPPFLAGS)
-CFLAGS := $(KERNEL_CFLAGS) -Wall -Werror -fno-stack-protector $(CPPFLAGS) -O3 -fno-builtin
+CFLAGS := -Wall -Werror -fno-stack-protector $(CPPFLAGS) -O3 -fno-builtin
ifeq ($(BUILDTYPE),dynamic)
_SUFFIX := dyn_$(ARCH)
else
BIN := ../$(NAME).kmd.$(ARCH)
endif
- CFLAGS += -fPIC
+ CFLAGS += $(DYNMOD_CFLAGS) -fPIC
else
_SUFFIX := st_$(ARCH)
+ CFLAGS += $(KERNEL_CFLAGS)
BIN := ../$(NAME).xo.$(ARCH)
endif