include/vfs.h include/vfs_ext.h \
include/fs_devfs.h \
include/iocache.h \
- include/apidoc/arch_x86.h
+ include/apidoc/arch_x86.h \
+ include/tpl_drv_common.h \
+ include/tpl_drv_video.h
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
-BUILD_NUM = 1696
+BUILD_NUM = 1740
dd gGDT
; IDT
ALIGN 8
+[global gIDT]
gIDT:
times 256 dd 0x00080000,0x00000F00
[global gIDTPtr]
%macro DEF_IRQ 1
[global Isr%1]
Isr%1:
- ;cli ; HACK!
push 0
push %1
jmp IRQCommon
push fs
push gs
+ mov ax, 0x10
+ mov ds, ax
+ mov es, ax
+ mov fs, ax
+ mov gs, ax
+
push esp
call ErrorHandler
add esp, 4
push fs
push gs
+ mov ax, 0x10
+ mov ds, ax
+ mov es, ax
+ mov fs, ax
+ mov gs, ax
+
push esp
call IRQ_Handler
add esp, 4
push fs
push gs
+ mov ax, 0x10
+ mov ds, ax
+ mov es, ax
+ mov fs, ax
+ mov gs, ax
+
mov eax, [esp+12*4] ; CPU Number
push eax ; Pus as argument
void ErrorHandler(tRegs *Regs)
{
Uint cr;
- __asm__ __volatile__ ("cli");
+ //if( Regs && !(Regs->int_num == 13 && Regs->eflags & 0x20000) )
+ // __asm__ __volatile__ ("xchg %bx, %bx");
+ //Log_Debug("X86", "Regs = %p", Regs);
//Log_Debug("X86", "Error %i at 0x%08x", Regs->int_num, Regs->eip);
+ __asm__ __volatile__ ("cli");
+
// Page Fault
if(Regs->int_num == 14)
{
Warning("CPU Error %i - %s, Code: 0x%x",
Regs->int_num, csaERROR_NAMES[Regs->int_num], Regs->err_code);
Warning(" CS:EIP = 0x%04x:%08x", Regs->cs, Regs->eip);
- Warning(" SS:ESP = 0x%04x:%08x", Regs->ss, Regs->esp);
+ if(Regs->cs == 0x08)
+ Warning(" SS:ESP = 0x0010:%08x", 0x10, (Uint)Regs+sizeof(tRegs));
+ else
+ Warning(" SS:ESP = 0x%04x:%08x", Regs->ss, Regs->esp);
Warning(" EFLAGS = 0x%08x", Regs->eflags);
Warning(" EAX %08x ECX %08x EDX %08x EBX %08x",
Regs->eax, Regs->ecx, Regs->edx, Regs->ebx);
switch( Regs->int_num )
{
- case 6:
+ case 6: // #UD
Warning(" Offending bytes: %02x %02x %02x %02x",
*(Uint8*)Regs->eip+0, *(Uint8*)Regs->eip+1,
*(Uint8*)Regs->eip+2, *(Uint8*)Regs->eip+3);
Uint Resvd4[1]; // SS
} tSyscallRegs;
-typedef struct {
- Uint16 LimitLow;
- Uint16 BaseLow;
- Uint8 BaseMid;
- Uint8 Access;
- struct {
- unsigned LimitHi: 4;
- unsigned Flags: 4;
- } __attribute__ ((packed));
- Uint8 BaseHi;
-} __attribute__ ((packed)) tGDT;
-
typedef struct {
#if USE_PAE
Uint PDPT[4];
--- /dev/null
+/**
+ */
+#ifndef _DESCTAB_H_
+#define _DESCTAB_H_
+
+typedef struct {
+ Uint16 LimitLow;
+ Uint16 BaseLow;
+ Uint8 BaseMid;
+ Uint8 Access;
+ struct {
+ unsigned LimitHi: 4;
+ unsigned Flags: 4;
+ } __attribute__ ((packed));
+ Uint8 BaseHi;
+} __attribute__ ((packed)) tGDT;
+
+typedef struct {
+ Uint16 OffsetLo;
+ Uint16 CS;
+ Uint16 Flags;
+ Uint16 OffsetHi;
+} __attribute__ ((packed)) tIDT;
+
+#endif
* 0xFE - Unused
* 0xFF - System Calls / Kernel's User Code
*/
-#define DEBUG 1
+#define DEBUG 0
#define SANITY 1
#include <acess.h>
#include <mm_phys.h>
(ErrorCode&1?"bad/locked":"non-present"),
(ErrorCode&16?" (Instruction Fetch)":"")
);
- Warning("User Pagefault: Instruction at %p accessed %p", Regs->eip, Addr);
+ Warning("User Pagefault: Instruction at %04x:%08x accessed %p", Regs->cs, Regs->eip, Addr);
__asm__ __volatile__ ("sti"); // Restart IRQs
Threads_SegFault(Addr);
return ;
*/
#include <acess.h>
#include <proc.h>
+#include <desctab.h>
#include <mm_virt.h>
#include <errno.h>
#if USE_MP
// === IMPORTS ===
extern tGDT gGDT[];
+extern tIDT gIDT[];
extern void APStartup(); // 16-bit AP startup code
extern Uint GetEIP(); // start.asm
extern Uint32 gaInitPageDir[1024]; // start.asm
extern tThread *Threads_GetNextToRun(int CPU);
extern void Threads_Dump();
extern tThread *Threads_CloneTCB(Uint *Err, Uint Flags);
-extern void Isr7();
+extern void Isr8(); // Double Fault
// === PROTOTYPES ===
void ArchThreads_Init();
tTSS gDoubleFault_TSS = {
.ESP0 = (Uint)&gaDoubleFaultStack[1023],
.SS0 = 0x10,
- .EIP = (Uint)Isr7
+ .CR3 = (Uint)gaInitPageDir - KERNEL_BASE,
+ .EIP = (Uint)Isr8,
+ .ESP = (Uint)&gaDoubleFaultStack[1023],
+ .CS = 0x08, .SS = 0x10,
+ .DS = 0x10, .ES = 0x10,
+ .FS = 0x10, .GS = 0x10,
};
// === CODE ===
gGDT[5].BaseMid = (Uint)&gDoubleFault_TSS >> 16;
gGDT[5].BaseHi = (Uint)&gDoubleFault_TSS >> 24;
+ Log_Debug("Proc", "gIDT[8] = {OffsetLo:%04x, CS:%04x, Flags:%04x, OffsetHi:%04x}",
+ gIDT[8].OffsetLo, gIDT[8].CS, gIDT[8].Flags, gIDT[8].OffsetHi);
+ gIDT[8].OffsetLo = 0;
+ gIDT[8].CS = 5<<3;
+ gIDT[8].Flags = 0x8500;
+ gIDT[8].OffsetHi = 0;
+ Log_Debug("Proc", "gIDT[8] = {OffsetLo:%04x, CS:%04x, Flags:%04x, OffsetHi:%04x}",
+ gIDT[8].OffsetLo, gIDT[8].CS, gIDT[8].Flags, gIDT[8].OffsetHi);
+
+ //__asm__ __volatile__ ("xchg %bx, %bx");
+
#if USE_MP
// Initialise Normal TSS(s)
for(pos=0;pos<giNumCPUs;pos++)
VM8086_OP_PUSHF = 0x9C,
VM8086_OP_POPF = 0x9D,
VM8086_OP_INT_I = 0xCD,
- VM8086_OP_IRET = 0xCF
+ VM8086_OP_IRET = 0xCF,
+ VM8086_OP_IN_AD = 0xEC,
+ VM8086_OP_IN_ADX= 0xED
};
#define VM8086_PAGES_PER_INST 4
// Map ROM Area
for(i=0xA0;i<0x100;i++) {
MM_Map( i * 0x1000, i * 0x1000 );
- MM_SetFlags( i * 0x1000, MM_PFLAG_RO, MM_PFLAG_RO ); // Set Read Only
+ //MM_SetFlags( i * 0x1000, MM_PFLAG_RO, MM_PFLAG_RO ); // Set Read Only
}
MM_Map( 0, 0 ); // IVT / BDA
for(i=0x70;i<0x80;i++) {
//Log_Log("VM8086", "gpVM8086_State = %p", gpVM8086_State);
}
- //Log_Log("VM8086", "We have a task");
+ //Log_Log("VM8086", "We have a task (%p)", gpVM8086_State);
Regs->esp -= 2; *(Uint16*)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = VM8086_MAGIC_CS;
Regs->esp -= 2; *(Uint16*)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = VM8086_MAGIC_IP;
Regs->esp -= 2; *(Uint16*)( (Regs->ss<<4) + (Regs->esp&0xFFFF) ) = gpVM8086_State->CS;
}
break;
- case 0xCF: //IRET
+ case VM8086_OP_IRET: //IRET
Regs->eip = *(Uint16*)( Regs->ss*16 + (Regs->esp&0xFFFF) ); Regs->esp += 2;
Regs->cs = *(Uint16*)( Regs->ss*16 + (Regs->esp&0xFFFF) ); Regs->esp += 2;
#if TRACE_EMU
#endif
break;
+
+ case VM8086_OP_IN_AD: //IN AL, DX
+ Regs->eax &= 0xFFFFFF00;
+ Regs->eax |= inb(Regs->edx&0xFFFF);
+ #if TRACE_EMU
+ Log_Debug("VM8086", "Emulated IN AL, DX (Port 0x%x)\n", Regs->edx&0xFFFF);
+ #endif
+ break;
+ case VM8086_OP_IN_ADX: //IN AX, DX
+ Regs->eax &= 0xFFFF0000;
+ Regs->eax |= inw(Regs->edx&0xFFFF);
+ #if TRACE_EMU
+ Log_Debug("VM8086", "Emulated IN AX, DX (Port 0x%x)\n", Regs->edx&0xFFFF);
+ #endif
+ break;
+
+ case 0xEE: //OUT DX, AL
+ outb(Regs->edx&0xFFFF, Regs->eax&0xFF);
+ #if TRACE_EMU
+ Log_Debug("VM8086", "Emulated OUT DX, AL (*0x%04x = 0x%02x)\n", Regs->edx&0xFFFF, Regs->eax&0xFF);
+ #endif
+ break;
+ case 0xEF: //OUT DX, AX
+ outw(Regs->edx&0xFFFF, Regs->eax&0xFFFF);
+ #if TRACE_EMU
+ Log_Debug("VM8086", "Emulated OUT DX, AX (*0x%04x = 0x%04x)\n", Regs->edx&0xFFFF, Regs->eax&0xFFFF);
+ #endif
+ break;
+
+ // TODO: Decide on allowing VM8086 Apps to enable/disable interrupts
+ case 0xFA: //CLI
+ break;
+ case 0xFB: //STI
+ break;
+
+ case 0x66:
+ Log_Warning("VM8086", "Code at %04x:%04x attempted to use an operand override, ignored",
+ Regs->cs, Regs->eip);
+ break;
+
default:
Log_Error("VM8086", "Error - Unknown opcode %02x caused a GPF at %04x:%04x",
opcode, Regs->cs, Regs->eip);
if(giDebug_KTerm != -1)
VFS_Close(giDebug_KTerm);
giDebug_KTerm = VFS_Open(File, VFS_OPENFLAG_WRITE);
- Log("Opened '%s' as 0x%x", File, giDebug_KTerm);
+ Log_Log("Debug", "Opened '%s' as 0x%x", File, giDebug_KTerm);
}
void Debug_Enter(char *FuncName, char *ArgTypes, ...)
//if( inportb(0x64) & 0x20 ) return;
scancode = inb(0x60); // Read from the keyboard's data buffer
- Log_Debug("KB", "scancode = %02x");
+ //Log_Debug("Keyboard", "scancode = %02x", scancode);
//Log("KB_IRQHandler: scancode = 0x%02x", scancode);
//keyNum = giKB_KeyLayer * 256 + scancode;
// Check for unknown key
if(!ch && !gbKB_KeyUp)
- Warning("UNK %i %x", giKB_KeyLayer, scancode);
+ Log_Warning("Keyboard", "UNK %i %x", giKB_KeyLayer, scancode);
// Key Up?
if (gbKB_KeyUp)
#if USE_KERNEL_MAGIC
if(ch == KEY_LCTRL) {
gbKB_MagicState |= 1;
- Log_Log("KB", "Kernel Magic LCTRL Down\n");
+ //Log_Log("Keyboard", "Kernel Magic LCTRL Down\n");
}
if(ch == KEY_LALT) {
gbKB_MagicState |= 2;
- Log_Log("KB", "Kernel Magic LALT Down\n");
+ //Log_Log("Keyboard", "Kernel Magic LALT Down\n");
}
if(gbKB_MagicState == 3)
{
if(devInfo.oc == PCI_OC_PCIBRIDGE)\r
{\r
#if LIST_DEVICES\r
- Log("[PCI ] Bridge @ %i,%i:%i (0x%x:0x%x)",\r
+ Log_Log("PCI", "Bridge @ %i,%i:%i (0x%x:0x%x)",\r
bus, dev, fcn, devInfo.vendor, devInfo.device);\r
#endif\r
giPCI_BusCount++;\r
else\r
{\r
#if LIST_DEVICES\r
- Log("[PCI ] Device %i,%i:%i %04x => 0x%04x:0x%04x",\r
+ Log_Log("PCI", "Device %i,%i:%i %04x => 0x%04x:0x%04x",\r
bus, dev, fcn, devInfo.oc, devInfo.vendor, devInfo.device);\r
#endif\r
}\r
return MODULE_ERR_MALLOC;\r
gPCI_Devices = tmpPtr;\r
\r
- // Complete Driver Structure \r
+ // Complete Driver Structure\r
gPCI_DriverStruct.RootNode.Size = giPCI_DeviceCount;\r
\r
// And add to DevFS\r
if(!gsVT_OutputDevice) gsVT_OutputDevice = "/Devices/"DEFAULT_OUTPUT;
if(!gsVT_InputDevice) gsVT_InputDevice = "/Devices/"DEFAULT_INPUT;
- LOG("Using '%s' as output", gsVT_OutputDevice);
- LOG("Using '%s' as input", gsVT_InputDevice);
+ Log_Log("VTerm", "Using '%s' as output", gsVT_OutputDevice);
+ Log_Log("VTerm", "Using '%s' as input", gsVT_InputDevice);
// Create Nodes
for( i = 0; i < NUM_VTS; i++ )
VFS_IOCtl( giVT_OutputDevHandle, VIDEO_IOCTL_GETSETMODE, &modeNum );
// Update current terminal ID
- Log("Changed terminal from %i to %i", giVT_CurrentTerminal, ID);
+ Log_Log("VTerm", "Changed terminal from %i to %i", giVT_CurrentTerminal, ID);
giVT_CurrentTerminal = ID;
// Update the screen
System_ParseCommandLine(ArgString);
// - Execute the Config Script
- Log_Log("CFG", "Executing config script...");
+ Log_Log("Config", "Executing config script...");
System_ExecuteScript();
}
int i;
char *str;
- Log_Log("CFG", "Kernel Invocation \"%s\"", ArgString);
+ Log_Log("Config", "Kernel Invocation \"%s\"", ArgString);
// --- Get Arguments ---
str = ArgString;
// Check if the equals was found
if( *value == '\0' ) {
- Log_Warning("CFG", "Expected '=' in the string '%s'", Arg);
+ Log_Warning("Config", "Expected '=' in the string '%s'", Arg);
return ;
}
// - Symbolic Link <link>=<destination>
if(value[0] == '/')
{
- Log_Log("CFG", "Symbolic link '%s' pointing to '%s'", Arg, value);
+ Log_Log("Config", "Symbolic link '%s' pointing to '%s'", Arg, value);
VFS_Symlink(Arg, value);
}
// - Mount <mountpoint>=<fs>:<device>
}
// Create Mountpoint
if( (fd = VFS_Open(Arg, 0)) == -1 ) {
- Log_Log("CFG", "Creating directory '%s'", Arg, value);
+ Log_Log("Config", "Creating directory '%s'", Arg, value);
VFS_MkDir( Arg );
} else {
VFS_Close(fd);
}
// Mount
- Log_Log("CFG", "Mounting '%s' to '%s' ('%s')", dev, Arg, value);
+ Log_Log("Config", "Mounting '%s' to '%s' ('%s')", dev, Arg, value);
VFS_Mount(dev, Arg, value, "");
}
}
{
//if(strcmp(Arg, "") == 0) {
//} else {
- Log_Warning("CFG", "Kernel flag '%s' is not recognised", Arg);
+ Log_Warning("Config", "Kernel flag '%s' is not recognised", Arg);
//}
}
else
value ++; // and eat it's position
if(strcmp(Arg, "SCRIPT") == 0) {
- Log_Log("CFG", "Config Script: '%s'", value);
+ Log_Log("Config", "Config Script: '%s'", value);
gsConfigScript = value;
} else {
- Log_Warning("CFG", "Kernel config setting '%s' is not recognised", Arg);
+ Log_Warning("Config", "Kernel config setting '%s' is not recognised", Arg);
}
}
// Open Script
fp = VFS_Open(gsConfigScript, VFS_OPENFLAG_READ);
if(fp == -1) {
- Log_Warning("CFG", "Passed script '%s' does not exist", gsConfigScript);
+ Log_Warning("Config", "Passed script '%s' does not exist", gsConfigScript);
return;
}
if( strcmp(line->Parts[0], "mount") == 0 )
{
if( line->nParts != 4 ) {
- Log_Warning("CFG", "Configuration command 'mount' requires 3 arguments, %i given",
+ Log_Warning("Config", "Configuration command 'mount' requires 3 arguments, %i given",
line->nParts-1);
continue;
}
- //Log_Log("CFG", "Mount '%s' to '%s' (%s)",
+ //Log_Log("Config", "Mount '%s' to '%s' (%s)",
// line->Parts[1], line->Parts[2], line->Parts[3]);
//! \todo Use an optional 4th argument for the options string
VFS_Mount(line->Parts[1], line->Parts[2], line->Parts[3], "");
else if(strcmp(line->Parts[0], "udimod") == 0)
{
if( line->nParts != 2 ) {
- Log_Warning("CFG", "Configuration command 'udimod' requires 1 argument, %i given",
+ Log_Warning("Config", "Configuration command 'udimod' requires 1 argument, %i given",
line->nParts-1);
continue;
}
- Log_Log("CFG", "Load UDI Module '%s'", line->Parts[1]);
+ Log_Log("Config", "Load UDI Module '%s'", line->Parts[1]);
Module_LoadFile(line->Parts[1], "");
}
// Load a EDI Module
else if(strcmp(line->Parts[0], "edimod") == 0)
{
if( line->nParts != 2 ) {
- Log_Warning("CFG", "Configuration command 'edimod' requires 1 argument, %i given",
+ Log_Warning("Config", "Configuration command 'edimod' requires 1 argument, %i given",
line->nParts-1);
continue;
}
- Log_Log("CFG", "Load EDI Module '%s'", line->Parts[1]);
+ Log_Log("Config", "Load EDI Module '%s'", line->Parts[1]);
Module_LoadFile(line->Parts[1], "");
}
// Create a Symbolic Link
else if(strcmp(line->Parts[0], "symlink") == 0)
{
if( line->nParts != 3 ) {
- Log_Warning("CFG", "Configuration command 'symlink' requires 2 arguments, %i given",
+ Log_Warning("Config", "Configuration command 'symlink' requires 2 arguments, %i given",
line->nParts-1);
continue;
}
- Log_Log("CFG", "Symlink '%s' pointing to '%s'",
+ Log_Log("Config", "Symlink '%s' pointing to '%s'",
line->Parts[1], line->Parts[2]);
VFS_Symlink(line->Parts[1], line->Parts[2]);
}
else if(strcmp(line->Parts[0], "mkdir") == 0)
{
if( line->nParts != 2 ) {
- Log_Warning("CFG", "Configuration command 'mkdir' requires 1 argument, %i given",
+ Log_Warning("Config", "Configuration command 'mkdir' requires 1 argument, %i given",
line->nParts-1);
continue;
}
- Log_Log("CFG", "New Directory '%s'", line->Parts[1]);
+ Log_Log("Config", "New Directory '%s'", line->Parts[1]);
VFS_MkDir(line->Parts[1]);
}
// Spawn a process
else if(strcmp(line->Parts[0], "spawn") == 0)
{
if( line->nParts != 2 ) {
- Log_Warning("CFG", "Configuration command 'spawn' requires 1 argument, %i given",
+ Log_Warning("Config", "Configuration command 'spawn' requires 1 argument, %i given",
line->nParts-1);
continue;
}
- Log_Log("CFG", "Starting '%s' as a new task", line->Parts[1]);
+ Log_Log("Config", "Starting '%s' as a new task", line->Parts[1]);
Proc_Spawn(line->Parts[1]);
}
else {
- Log_Warning("CFG", "Unknown configuration command '%s' on line %i",
+ Log_Warning("Config", "Unknown configuration command '%s' on line %i",
line->Parts[0],
line->TrueLine
);
tThread *cur = Proc_GetCurThread();
tThread *thread;
- Log_Log("Threads", "%i going to sleep", cur->TID);
+ //Log_Log("Threads", "%i going to sleep", cur->TID);
// Acquire Spinlock
LOCK( &giThreadListLock );
// Release Spinlock
RELEASE( &giThreadListLock );
- while(cur->Status == THREAD_STAT_SLEEPING) HALT();
- //HALT();
- Log_Debug("VM8086", "What a lovely sleep");
+ while(cur->Status != THREAD_STAT_ACTIVE) HALT();
}
{
case THREAD_STAT_ACTIVE: break;
case THREAD_STAT_SLEEPING:
- Log_Log("Threads", "Waking %i (%p) from sleeping", Thread->TID, Thread);
+ //Log_Log("Threads", "Waking %i (%p) from sleeping", Thread->TID, Thread);
LOCK( &giThreadListLock );
prev = Threads_int_GetPrev(&gSleepingThreads, Thread);
prev->Next = Thread->Next; // Remove from sleeping queue
/**\r
* \file drv_bochsvbe.c\r
- * \brief BGA (Bochs Graphic Adapter) Driver\r
- * \note for Acess2\r
+ * \brief BGA (Bochs Graphic Adapter) Driver for Acess2\r
* \warning This driver does NOT support the Bochs PCI VGA driver\r
*/\r
#define DEBUG 0\r
*/
int IPStack_AddFile(tSocketFile *File)
{
- Log("IPStack_AddFile: %s", File->Name);
+ Log_Log("IPStack", "Added file '%s'", File->Name);
File->Next = gIP_FileTemplates;
gIP_FileTemplates = File;
return 0;
{
// Ooh, Goodie! Add it to the recieved list
TCP_INT_AppendRecieved(Connection, pkt);
- Connection->NextSequenceRcv ++;
+ if(dataLen)
+ Connection->NextSequenceRcv += dataLen;
+ else
+ Connection->NextSequenceRcv += 1;
// TODO: This should be moved out of the watcher thread,
// so that a single lost packet on one connection doesn't cause
}
// TODO: Check ACK code validity
- Header->AcknowlegementNumber = ntohl(pkt->Sequence);
+ Header->AcknowlegementNumber = ntohl(pkt->Sequence) + dataLen;
Header->SequenceNumber = ntohl(Connection->NextSequenceSend);
Header->Flags &= TCP_FLAG_SYN;
Header->Flags = TCP_FLAG_ACK;
--- /dev/null
+CATEGORY = USB
+
+-include ../../Makefile.tpl