ALIGN 8
[global gIDT]
gIDT:
- times 256 dd 0x00080000,0x00000F00
+ ; CS = 0x08, Type = 32-bit Interrupt (0xE = 1 110)
+ times 256 dd 0x00080000,0x00000E00
[global gIDTPtr]
gIDTPtr:
dw 256 * 16 - 1 ; Limit
jmp 0x08:.pl0code
.pl0code:
- ; Set IDT
+ ; Set up IDT
%macro SETISR 1
mov eax, Isr%1
mov WORD [gIDT + %1*8], ax
or ax, 0x8000
mov WORD [gIDT + %1*8 + 4], ax
%endmacro
-%macro SETUSER 1
- mov ax, WORD [gIDT + %1*8 + 4]
- or ax, 0x6000
- mov WORD [gIDT + %1*8 + 4], ax
+%macro SET_USER 1
+ or WORD [gIDT + %1*8 + 4], 0x6000
+%endmacro
+%macro SET_TRAP 1
+ or WORD [gIDT + %1*8 + 4], 0x0100
%endmacro
+
%assign i 0
%rep 32
SETISR i
%endrep
SETISR 0xAC
- SETUSER 0xAC
+ SET_USER 0xAC
+ SET_TRAP 0xAC ; Interruptable
%if USE_MP
SETISR 0xEE ; 0xEE Timer
SETISR 0xEF ; 0xEF Spurious Interrupt
%endif
-
+
+ ; IRQs
%assign i 0xF0
%rep 16
SETISR i
MM_InstallVirtual(); // Clean up virtual address space
Heap_Install(); // Create initial heap
- // Start Timers
- Time_Setup();
-
//Log_Log("Arch", "Starting Multitasking...");
// Start Multitasking
Threads_Init();
+ // Start Timers
+ Time_Setup();
+
Log_Log("Arch", "Starting VFS...");
// Load Virtual Filesystem
VFS_Init();
; Export a place for the user to jump to to call a syscall
; - Allows the kernel to change the method easily
User_Syscall:
+ xchg bx, bx
int 0xAC
; A place to return to and exit
eip = GetEIP();
if(eip == SWITCH_MAGIC) {
outb(0x20, 0x20); // ACK Timer and return as child
+ __asm__ __volatile__ ("sti"); // Restart interrupts
return 0;
}
// === MACROS ===
#define TIMER_QUANTUM 100
// 2^(15-rate), 15: 1HZ, 5: 1024Hz, 2: 8192Hz
-#define TIMER_RATE 12 // (Max: 15, Min: 2) - 15 = 1Hz, 13 = 4Hz, 12 = 8Hz, 11 = 16Hz 10 = 32Hz, 2
+// (Max: 15, Min: 2) - 15 = 1Hz, 13 = 4Hz, 12 = 8Hz, 11 = 16Hz 10 = 32Hz, 2 = 8192Hz
+#define TIMER_RATE 12
+//#define TIMER_RATE 15
#define TIMER_FREQ (0x8000>>TIMER_RATE) //Hz
#define MS_PER_TICK_WHOLE (1000/(TIMER_FREQ))
#define MS_PER_TICK_FRACT ((0x80000000*(1000%TIMER_FREQ))/TIMER_FREQ)
outb(0x70, 0x0B); // Set the index again (a read will reset the index to register D)
outb(0x71, val | 0x40); // Write the previous value or'd with 0x40. This turns on bit 6 of register D
- __asm__ __volatile__ ("sti"); // Disable normal interrupts
- outb(0x70, inb(0x70)|0x80); // Disable NMIs
+ __asm__ __volatile__ ("sti"); // Re-enable normal interrupts
+ outb(0x70, inb(0x70)|0x80); // Re-enable NMIs
// Install IRQ Handler
IRQ_AddHandler(8, Time_Interrupt);
*/
void Time_Interrupt(int irq)
{
+ //Log("RTC Tick");
+
giTicks ++;
giTimestamp += MS_PER_TICK_WHOLE;
giPartMiliseconds += MS_PER_TICK_FRACT;
cur->ThreadName = "Idle Thread";
Threads_SetTickets(0); // Never called randomly
cur->Quantum = 1; // 1 slice quantum
- HALT();
- for(;;) {
- HALT(); // Just yeilds
- }
+ for(;;) HALT(); // Just yeilds
}
#endif
// === CONSTANTS ===\r
#define FLAG_LFB 0x1\r
#define VESA_DEFAULT_FRAMEBUFFER (KERNEL_BASE|0xA0000)\r
-#define VESA_CURSOR_PERIOD 1000\r
+#define BLINKING_CURSOR 0\r
+#if BLINKING_CURSOR\r
+# define VESA_CURSOR_PERIOD 1000\r
+#endif\r
\r
// === PROTOTYPES ===\r
int Vesa_Install(char **Arguments);\r
return ret;\r
\r
case VIDEO_IOCTL_SETCURSOR: // Set cursor position\r
+ #if !BLINKING_CURSOR\r
+ if(giVesaCursorX > 0 && giVesaCursorY)\r
+ Vesa_FlipCursor(Node);\r
+ #endif\r
giVesaCursorX = ((tVideo_IOCtl_Pos*)Data)->x;\r
giVesaCursorY = ((tVideo_IOCtl_Pos*)Data)->y;\r
//Log_Debug("VESA", "Cursor position (%i,%i)", giVesaCursorX, giVesaCursorY);\r
|| giVesaCursorX >= gpVesaCurMode->width/giVT_CharWidth\r
|| giVesaCursorY >= gpVesaCurMode->height/giVT_CharHeight)\r
{\r
+ #if BLINKING_CURSOR\r
if(giVesaCursorTimer != -1) {\r
Time_RemoveTimer(giVesaCursorTimer);\r
giVesaCursorTimer = -1;\r
}\r
+ #endif\r
giVesaCursorX = -1;\r
giVesaCursorY = -1;\r
}\r
else {\r
+ #if BLINKING_CURSOR\r
// Log_Debug("VESA", "Updating timer %i?", giVesaCursorTimer);\r
if(giVesaCursorTimer == -1)\r
giVesaCursorTimer = Time_CreateTimer(VESA_CURSOR_PERIOD, Vesa_FlipCursor, Node);\r
+ #else\r
+ Vesa_FlipCursor(Node);\r
+ #endif\r
}\r
//Log_Debug("VESA", "Cursor position (%i,%i) Timer %i", giVesaCursorX, giVesaCursorY, giVesaCursorTimer);\r
return 0;\r
for( i = 1; i < giVT_CharHeight-1; i++, fb += pitch )\r
*fb = ~*fb;\r
\r
+ #if BLINKING_CURSOR\r
giVesaCursorTimer = Time_CreateTimer(VESA_CURSOR_PERIOD, Vesa_FlipCursor, Arg);\r
+ #endif\r
}\r
\r
// ------------------------\r
Log_Warning("UDI", "_udiprops is not defined, this is usually bad");
}
else {
- if( Binary_FindSymbol(Base, "_udiprops_size", (Uint*)&udiprops_size) == 0)
- Log_Warning("UDI", "_udiprops_size is not defined");
- Log_Log("UDI", "udiprops = %p, udiprops_size = 0x%x", udiprops, udiprops_size);
+ Uint udiprops_end = 0;
+ int i, j, nLines;
+ char **udipropsptrs;
+
+ if( Binary_FindSymbol(Base, "_udiprops_end", (Uint*)&udiprops_end) == 0)
+ Log_Warning("UDI", "_udiprops_end is not defined");
+ Log_Debug("UDI", "udiprops_end = %p", udiprops_end);
+ udiprops_size = udiprops_end - (Uint)udiprops;
+ Log_Debug("UDI", "udiprops = %p, udiprops_size = 0x%x", udiprops, udiprops_size);
+
+ Debug_HexDump("UDI_LoadDriver", udiprops, udiprops_size);
+
+ nLines = 1;
+ for( i = 0; i < udiprops_size; i++ )
+ {
+ if( udiprops[i] == '\0' )
+ nLines ++;
+ }
+
+ Log_Debug("UDI", "nLines = %i", nLines);
+
+ udipropsptrs = malloc( sizeof(char*)*nLines );
+ udipropsptrs[0] = udiprops;
+ j = 0;
+ for( i = 0; i < udiprops_size; i++ )
+ {
+ if( udiprops[i] == '\0' ) {
+ //Log_Debug("UDI", "udipropsptrs[%i] = '%s'", j, udipropsptrs[j]);
+ udipropsptrs[j++] = &udiprops[i+1];
+ }
+ }
+ Log_Debug("UDI", "udipropsptrs[%i] = '%s'", j, udipropsptrs[j]);
+ Log_Debug("UDI", "udiprops = \"%s\"", udiprops);
}
MAR1, MAR2, MAR3,
MAR4, MAR5, MAR6, MAR7,
- RBSTART = 0x30, //!< Recieve Buffer Start
+ RBSTART = 0x30, //!< Recieve Buffer Start (DWord)
+ // 0x31, 0x32, 0x33
+
// ??, ??, ??, RST, RE, TE, ??, ??
CMD = 0x37,
IMR = 0x3C,
// --- Root Functions ---
char *RTL8139_ReadDir(tVFS_Node *Node, int Pos)
{
- return NULL;
+ if( Pos < 0 || Pos > giRTL8139_CardCount ) return NULL;
+
+ return strdup( gpRTL8139_Cards[Pos].Name );
}
tVFS_Node *RTL8139_FindDir(tVFS_Node *Node, const char *Filename)
{
- return NULL;
+ //TODO: It might be an idea to supprt >10 cards
+ if(Filename[0] == '\0' || Filename[0] != '\0') return NULL;
+ if(Filename[0] < '0' || Filename[0] > '9') return NULL;
+ return &gpRTL8139_Cards[ Filename[0]-'0' ].Node;
}
+const char *csaRTL8139_RootIOCtls[] = {DRV_IOCTLNAMES, NULL};
int RTL8139_RootIOCtl(tVFS_Node *Node, int ID, void *Arg)
{
+ switch(ID)
+ {
+ BASE_IOCTLS(DRV_TYPE_NETWORK, "RTL8139", VERSION, csaRTL8139_RootIOCtls);
+ }
return 0;
}
return 0;
}
+const char *csaRTL8139_NodeIOCtls[] = {DRV_IOCTLNAMES, NULL};
int RTL8139_IOCtl(tVFS_Node *Node, int ID, void *Arg)
{
+ switch(ID)
+ {
+ BASE_IOCTLS(DRV_TYPE_NETWORK, "RTL8139", VERSION, csaRTL8139_NodeIOCtls);
+ }
return 0;
}
* Acess2 IDE Harddisk Driver
* - main.c
*/
-#define DEBUG 0
+#define DEBUG 1
#include <acess.h>
#include <modules.h>
#include <vfs.h>
{
int ret = DrvUtil_ReadBlock(Offset, Length, Buffer, ATA_ReadRaw, SECTOR_SIZE, disk);
+ Log("ATA_ReadFS: disk=%i, Offset=%lli, Length=%lli", disk, Offset, Length);
Debug_HexDump("ATA_ReadFS", Buffer, Length);
LEAVE('i', ret);
return ret;
ATA_int_BusMasterWriteByte( cont << 3, 9 ); // Read and start
// Wait for transfer to complete
- val = 0;
- while( gaATA_IRQs[cont] == 0 && !(val & 0x4) ) {
- val = ATA_int_BusMasterReadByte( (cont << 3) + 2 );
- //LOG("val = 0x%02x", val);
- Threads_Yield();
- }
+ while( gaATA_IRQs[cont] == 0 ) Threads_Yield();
// Complete Transfer
ATA_int_BusMasterWriteByte( cont << 3, 8 ); // Read and stop
ENTRY(start)
+OUTPUT_FORMAT(elf32-i386)
+
SECTIONS
{
. = 0;
.udiprops : {
*(.udiprops)
}
- _udiprops_size = . - _udiprops;
+ _udiprops_end = .;
. = (. + 0xFFF) & ~ 0xFFF;
#!/bin/sh
-ld -T link.ld -shared -o $1.drv $1
+ld -melf_i386 -T link.ld -shared -o $1.drv $1
%include "../../../Kernel/include/syscalls.inc.asm"
-SYSCALL_JUMP equ 0xCFFF0000
+;%define SYSCALL_OP jmp 0xCFFF0000
+%define SYSCALL_OP int 0xAC
; System Call - No Arguments
%macro SYSCALL0 2
%1:
push ebx
mov eax, %2
- jmp SYSCALL_JUMP
+ SYSCALL_OP
mov [_errno], ebx
pop ebx
ret
push ebx
mov eax, %2
mov ebx, [ebp+8]
- jmp SYSCALL_JUMP
+ SYSCALL_OP
mov [_errno], ebx
pop ebx
pop ebp
mov eax, %2
mov ebx, [ebp+8]
mov ecx, [ebp+12]
- jmp SYSCALL_JUMP
+ SYSCALL_OP
mov [_errno], ebx
pop ebx
pop ebp
mov ebx, [ebp+8]
mov ecx, [ebp+12]
mov edx, [ebp+16]
- jmp SYSCALL_JUMP
+ SYSCALL_OP
mov [_errno], ebx
pop ebx
pop ebp
mov ecx, [ebp+12]
mov edx, [ebp+16]
mov edi, [ebp+20]
- jmp SYSCALL_JUMP
+ SYSCALL_OP
mov [_errno], ebx
pop edi
pop ebx
mov edx, [ebp+16]
mov edi, [ebp+20]
mov esi, [ebp+24]
- jmp SYSCALL_JUMP
+ SYSCALL_OP
mov [_errno], ebx
pop esi
pop edi
mov edi, [ebp+20]
mov esi, [ebp+24]
mov ebp, [ebp+28]
- jmp SYSCALL_JUMP
+ SYSCALL_OP
mov [_errno], ebx
pop esi
pop edi