extern void Threads_Fault(int Num);
// === PROTOTYPES ===
+void __stack_chk_fail(void);
+void ErrorHandler(tRegs *Regs);
void Error_Backtrace(Uint eip, Uint ebp);
+void StartupPrint(char *Str);
// === GLOBALS ===
const char *csaERROR_NAMES[] = {
};
// === CODE ===
+/**
+ * \brief Keeps GCC happy
+ */
void __stack_chk_fail(void)
{
Panic("FATAL ERROR: Stack Check Failed\n");
/**
* \fn void ErrorHandler(tRegs *Regs)
* \brief General Error Handler
+ * \param Regs Register state at error
*/
void ErrorHandler(tRegs *Regs)
{
/**
* \fn void Error_Backtrace(Uint eip, Uint ebp)
* \brief Unrolls the stack to trace execution
+ * \param eip Current Instruction Pointer
+ * \param ebp Current Base Pointer (Stack Frame)
*/
void Error_Backtrace(Uint eip, Uint ebp)
{
/**
* \fn void StartupPrint(char *Str)
+ * \brief Str String to print
+ * \note WHY IS THIS HERE?!?!
*/
void StartupPrint(char *Str)
{
Str ++;
}
- while(i < 80) buf[line*80 + i++] = 0x0720;
+ // Clear the rest of the line
+ while(i < 80)
+ buf[line*80 + i++] = 0x0720;
line ++;
if(line == 25)
// === CONSTANTS ===
#define SWITCH_MAGIC 0xFFFACE55 // There is no code in this area
// Base is 1193182
-#define TIMER_BASE 1193182
-#define TIMER_DIVISOR 11931 //~100Hz
+#define TIMER_BASE 1193182
+#define TIMER_DIVISOR 11931 //~100Hz
// === TYPES ===
#if USE_MP
#define KERNEL_BASE 0xFFFFFFFF##80000000
#define BITS 64
+//#define INT_MAX 0x7FFFFFFF
+//#define UINT_MAX 0xFFFFFFFF
+
// === Core Types ===
typedef signed char Sint8;
typedef unsigned char Uint8;
* START ADDRESS END ADDRESS BITS SIZE NAME
* 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 - 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
- * C000 00000000 - D000 00000000 44 16 TiB Hardware Mappings
+ * 0xFFFF8000 00000000 - 0xFFFFFFFF FFFFFFFF 47 128 TiB Kernel Range
+ * 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
+ * ---- GAP ----
+ * A000 00000000 - B000 00000000 44 16 TiB Kernel Stacks
+ * C000 00000000 - D000 00000000 44 16 TiB Hardware Mappings
* D000 00000000 - D080 00000000 39 512 GiB Per-Process Data
* D080 00000000 - D100 00000000 39 512 GiB Kernel Supplied User Code
+ * ---- GAP ----
* E000 00000000 - E400 00000000 42 4 TiB Physical Page Reference Counts (2**40 = 2**52 bytes)
* E400 00000000 - E480 00000000 39 512 GiB Physical Page Bitmap (1 page per bit)
* E480 00000000 - E500 00000000 39 512 GiB Physical Page DblAlloc Bitmap (1 page per bit)
* E500 00000000 - E500 80000000 31 2 GiB Physical Page Super Bitmap (64 pages per bit)
- * FD00 00000000 - FD80 00000000 39 512 GiB Local APIC
- * FE00 00000000 - FE80 00000000 39 512 GiB Fractal Mapping (PML4 508)
- * 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
+ * ---- GAP ----
+ * FE00 00000000 - FE80 00000000 39 512 GiB Fractal Mapping (PML4 508)
+ * FE80 00000000 - FF00 00000000 39 512 GiB Temp Fractal Mapping
+ * FF00 00000000 - FF80 00000000 39 512 GiB -- UNUSED --
+ * FD00 00000000 - FD00 80000000 39 2 GiB Local APIC
+ * FFFF 80000000 - FFFF 7FFFFFFF 31 2 GiB Identity Map
*/
#define MM_USER_MIN 0x00000000##00010000
#define MM_PAGE_DBLBMP (MM_KERNEL_RANGE|(0xE480##00000000))
#define MM_PAGE_SUPBMP (MM_KERNEL_RANGE|(0xE500##00000000))
-#define MM_LOCALAPIC (MM_KERNEL_RANGE|(0xFD00##00000000))
#define MM_FRACTAL_BASE (MM_KERNEL_RANGE|(0xFE00##00000000))
#define MM_TMPFRAC_BASE (MM_KERNEL_RANGE|(0xFE80##00000000))
+#define MM_LOCALAPIC (MM_KERNEL_RANGE|(0xFF80##00000000))
// === FUNCTIONS ===
.rodata ALIGN(0x1000): AT(ADDR(.rodata) - _kernel_base) {
*(.initpd)
*(.rodata)
+ *(.rodata.*)
*(.rdata)
. = ALIGN(0x10);
};
// === IMPORTS ===
-extern void gKernelBase;
-extern void gKernelEnd;
+extern char gKernelBase[];
+extern char gKernelEnd[];
// === PROTOTYPES ===
void MM_InitPhys_Multiboot(tMBoot_Info *MBoot);
// === IMPORTS ===
extern tGDT gGDT[];
-extern void APStartup(void); // 16-bit AP startup code
+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 char gInitialKernelStack[];
extern tSpinlock glThreadListLock;
extern int giNumCPUs;
extern int giNextTID;
// === IMPORTS ===
void Threads_Dump(void);
+void Heap_Stats(void);
// === PROTOTYPES ===
int KB_Install(char **Arguments);
{
switch(ch)
{
- case 'q': *((int*)1) = 0; break;
- case 'd': __asm__ __volatile__ ("xchg %bx, %bx"); break;
- case 'p': Threads_Dump(); break;
+ // Kernel Panic (Page Fault)
+ case 'q': *((int*)1) = 0; return;
+ // Bochs Magic Breakpoint
+ case 'd': __asm__ __volatile__ ("xchg %bx, %bx"); return;
+ // Thread List Dump
+ case 'p': Threads_Dump(); return;
+ // Heap Statistics
+ case 'h': Heap_Stats(); return;
}
}
#endif
void *malloc(size_t Bytes);
void free(void *Ptr);
void Heap_Dump(void);
+void Heap_Stats(void);
// === GLOBALS ===
tSpinlock glHeap;
}
#endif
+#if 1
+void Heap_Stats(void)
+{
+ tHeapHead *head;
+ int nBlocks = 0;
+ int nFree = 0;
+ int totalBytes = 0;
+ int freeBytes = 0;
+ int maxAlloc=0, minAlloc=-1;
+ int avgAlloc, frag, overhead;
+
+ for(head = gHeapStart;
+ (Uint)head < (Uint)gHeapEnd;
+ head = (void*)( (Uint)head + head->Size )
+ )
+ {
+ nBlocks ++;
+ totalBytes += head->Size;
+ if( head->Magic == MAGIC_FREE )
+ {
+ nFree ++;
+ freeBytes += head->Size;
+ }
+ else {
+ if(maxAlloc < head->Size) maxAlloc = head->Size;
+ if(minAlloc == -1 || minAlloc > head->Size)
+ minAlloc = head->Size;
+ }
+ }
+
+ Log_Log("Heap", "%i blocks (0x%x bytes)", nBlocks, totalBytes);
+ Log_Log("Heap", "%i free blocks (0x%x bytes)", nFree, freeBytes);
+ frag = (nFree-1)*10000/nBlocks;
+ Log_Log("Heap", "%i.%02i%% Heap Fragmentation", frag/100, frag%100);
+ avgAlloc = (totalBytes-freeBytes)/(nBlocks-nFree);
+ overhead = (sizeof(tHeapFoot)+sizeof(tHeapHead))*10000/avgAlloc;
+ Log_Log("Heap", "Average allocation: %i bytes, Average Overhead: %i.%02i%%",
+ avgAlloc, overhead/100, overhead%100
+ );
+ Log_Log("Heap", "Smallest Block: %i bytes, Largest: %i bytes",
+ minAlloc, maxAlloc);
+
+ // Scan and get distribution
+ #if 1
+ {
+ struct {
+ Uint Size;
+ Uint Count;
+ } sizeCounts[nBlocks];
+ int i;
+
+ memset(sizeCounts, 0, nBlocks*sizeof(sizeCounts[0]));
+
+ for(head = gHeapStart;
+ (Uint)head < (Uint)gHeapEnd;
+ head = (void*)( (Uint)head + head->Size )
+ )
+ {
+ for( i = 0; i < nBlocks; i ++ ) {
+ if( sizeCounts[i].Size == 0 )
+ break;
+ if( sizeCounts[i].Size == head->Size )
+ break;
+ }
+ // Should never reach this part (in a non-concurrent case)
+ if( i == nBlocks ) continue;
+ sizeCounts[i].Size = head->Size;
+ sizeCounts[i].Count ++;
+ #if 1
+ //Log("Heap_Stats: %i %p - 0x%x bytes (%s) (%i)", nBlocks, head,
+ // head->Size, (head->Magic==MAGIC_FREE?"FREE":"used"), i
+ // );
+ //Log("Heap_Stats: sizeCounts[%i] = {Size:0x%x, Count: %i}", i,
+ // sizeCounts[i].Size, sizeCounts[i].Count);
+ #endif
+ }
+
+ for( i = 0; i < nBlocks && sizeCounts[i].Count; i ++ )
+ {
+ Log("Heap_Stats: 0x%x - %i blocks",
+ sizeCounts[i].Size, sizeCounts[i].Count
+ );
+ }
+ }
+ #endif
+}
+#endif
+
// === EXPORTS ===
EXPORT(malloc);
EXPORT(realloc);
#define _COMMON_H
#define NULL ((void*)0)
-#define PACKED __attribute__ ((packed))
+#define PACKED __attribute__((packed))
+#define UNUSED(x) UNUSED_##x __attribute__((unused))
#define offsetof(st, m) ((Uint)((char *)&((st *)(0))->m - (char *)0 ))
//#include <stdint.h>
pad = ' ';
// - Minimum length
- if(c == '*') {
+ if(c == '*') { // Dynamic length
minSize = val;
val = va_arg(args, Uint);
c = *__format++;
// String - Null Terminated Array
case 's':
- p = (char*)(Uint)val;
+ p = (char*)(tVAddr)val;
printString:
if(!p) p = "(null)";
len = strlen(p);
break;
case 'C': // Non-Null Terminated Character Array
- p = (char*)(Uint)val;
+ p = (char*)(tVAddr)val;
if(!p) goto printString;
while(minSize--) PUTCH(*p++);
break;
#include <acess.h>
#define PRINT_ON_APPEND 1
+#define USE_RING_BUFFER 1
+#define RING_BUFFER_SIZE 4096
// === CONSTANTS ===
enum eLogLevels
// === GLOBALS ===
tSpinlock glLog;
tSpinlock glLogOutput;
+#if USE_RING_BUFFER
+Uint8 gaLog_RingBufferData[sizeof(tRingBuffer)+RING_BUFFER_SIZE];
+tRingBuffer *gpLog_RingBuffer = (void*)gaLog_RingBufferData;
+#else
tLogList gLog;
tLogList gLog_Levels[NUM_LOG_LEVELS];
+#endif
// === CODE ===
/**
//Log("len = %i", len);
+ #if USE_RING_BUFFER
+ {
+ char buf[sizeof(tLogEntry)+len+1];
+ ent = (void*)buf;
+ #else
ent = malloc(sizeof(tLogEntry)+len+1);
+ #endif
ent->Time = now();
strncpy(ent->Ident, Ident, 8);
ent->Level = Level;
ent->Length = len;
- vsnprintf( ent->Data, 256, Format, Args );
-
- //Log("ent->Ident = '%s'", ent->Ident);
- //Log("ent->Data = '%s'", ent->Data);
+ vsnprintf( ent->Data, len+1, Format, Args );
+ #if USE_RING_BUFFER
+ {
+ #define LOG_HDR_LEN (14+1+2+8+2)
+ char newData[ LOG_HDR_LEN + len + 2 + 1 ];
+ sprintf( newData, "%014lli%s [%+8s] ",
+ ent->Time, csaLevelCodes[Level], Ident);
+ strcpy( newData + LOG_HDR_LEN, ent->Data );
+ strcpy( newData + LOG_HDR_LEN + len, "\r\n" );
+ gpLog_RingBuffer->Space = RING_BUFFER_SIZE; // Needed to init the buffer
+ RingBuffer_Write( gpLog_RingBuffer, newData, LOG_HDR_LEN + len + 2 );
+ }
+ #else
LOCK( &glLog );
ent->Next = gLog.Tail;
gLog_Levels[Level].Tail = gLog_Levels[Level].Head = ent;
RELEASE( &glLog );
+ #endif
#if PRINT_ON_APPEND
Log_Int_PrintMessage( ent );
#endif
+ #if USE_RING_BUFFER
+ }
+ #endif
}
/**
* Acess2
* - Module Loader
*/
-#define DEBUG 0
+#define DEBUG 1
#include <acess.h>
#include <modules.h>
int i;
char *str;
- Log_Log("Config", "Kernel Invocation \"%s\"", ArgString);
+ Log_Log("Config", "Kernel Invocation (%p) \"%s\"", ArgString, ArgString);
+ Log_Log("Config", "Kernel Invocation '0x%x 0x%x'", ArgString[0], ArgString[1]);
// --- Get Arguments ---
str = ArgString;
LD = x86_64-none-elf-ld
DISASM = x86_64-none-elf-objdump -d -M x86-64
-KERNEL_CFLAGS := -mcmodel=kernel -nostdlib -mno-red-zone
+KERNEL_CFLAGS := -mcmodel=kernel -nostdlib -mno-red-zone -Wall -Werror
DYNMOD_CFLAGS := -mcmodel=small -fPIC -mno-red-zone
ARCHDIR = x86_64
);\r
\r
// Sanity Check\r
+ if( Offset > (Uint64)(heightInChars*widthInChars) ) {\r
+ LEAVE('i', 0);\r
+ return 0;\r
+ }\r
if(y >= heightInChars) {\r
LEAVE('i', 0);\r
return 0;\r
}\r
\r
- if( Offset + Length > heightInChars*widthInChars ) {\r
+ \r
+ if( (int)Offset + (int)Length > heightInChars*widthInChars ) {\r
Log_Debug("VESA", "%i + %i > %i*%i (%i)",\r
(int)Offset, (int)Length, heightInChars, widthInChars, heightInChars*widthInChars);\r
Length = heightInChars*widthInChars - Offset;\r
\r
LOG("dest = %p", dest);\r
\r
- for( i = 0; i < Length; i++ )\r
+ for( i = 0; i < (int)Length; i++ )\r
{\r
VT_Font_Render(\r
chars->Ch,\r
\r
// Sanity 1\r
if(giVesaCursorX < 0 || giVesaCursorY < 0\r
- || y*pitch + x + giVT_CharHeight*pitch > gpVesaCurMode->fbSize/4) {\r
+ || y*pitch + x + giVT_CharHeight*pitch > (int)gpVesaCurMode->fbSize/4) {\r
Debug("Cursor OOB (%i,%i)", x, y);\r
giVesaCursorTimer = -1;\r
return;\r
tExt2_Inode inode;
tExt2_DirEnt dirent;
Uint64 Base; // Block's Base Address
- int block = 0, ofs = 0;
+ int block = 0;
+ Uint ofs = 0;
int entNum = 0;
tExt2_Disk *disk = Node->ImplPtr;
Uint size;
tExt2_Inode inode;
tExt2_DirEnt dirent;
Uint64 Base; // Block's Base Address
- int block = 0, ofs = 0;
+ int block = 0;
+ Uint ofs = 0;
int entNum = 0;
Uint size;
int filenameLen = strlen(Filename);
#define INT_MAX (((long long int)1<<(sizeof(int)*8))-1)\r
\r
// Powers of 3\r
- for( i = 3; i < ngrp && i < INT_MAX; i *= 3 )\r
+ for( i = 3; i < ngrp && i < INT_MAX/3; i *= 3 )\r
VFS_WriteAt(Disk->FD, i*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock);\r
\r
// Powers of 5\r
tVFS_Node RootNode;
tExt2_SuperBlock SuperBlock;
- int BlockSize;
+ Uint BlockSize;
int GroupCount;
tExt2_Group Groups[];
}
// Fast Check
- if( bitmap[j/32] == -1 ) {
+ if( bitmap[j/32] == 0xFFFFFFFF ) {
j = (j + 31) & ~31;
continue;
}
if(Cluster) *Cluster = cluster;\r
cluster = FAT_int_GetFatValue(disk, cluster);\r
// Check for end of cluster chain\r
- if(cluster == -1) { LEAVE('i', 1); return 1;}\r
+ if(cluster == 0xFFFFFFFF) { LEAVE('i', 1); return 1;}\r
}\r
if(Cluster) *Cluster = cluster;\r
}\r
cluster = Node->Inode & 0xFFFFFFFF;\r
\r
// Clamp Size\r
- if(Offset + Length > Node->Size) {\r
+ if(Offset >= Node->Size || Offset + Length > Node->Size) {\r
LOG("Reading past EOF (%lli + %lli > %lli), clamped to %lli",\r
Offset, Length, Node->Size, Node->Size - Offset);\r
Length = Node->Size - Offset;\r
}\r
\r
// Reading from within the first cluster only?\r
- if(Offset + Length < bpc)\r
+ if((int)Offset + (int)Length < bpc)\r
{\r
LOG("First cluster only");\r
FAT_int_ReadCluster(disk, cluster, bpc, tmpBuf);\r
pos = bpc - Offset%bpc;\r
\r
// Read 1st Cluster (performs alignment for us)\r
- if( pos == bpc && Length >= bpc ) {\r
+ if( pos == bpc && (int)Length >= bpc ) {\r
FAT_int_ReadCluster(disk, cluster, bpc, Buffer);\r
}\r
else {\r
memcpy(\r
Buffer,\r
(void*)( tmpBuf + (bpc-pos) ),\r
- (pos < Length ? pos : Length)\r
+ (pos < (int)Length ? (Uint)pos : Length)\r
);\r
}\r
\r
}\r
\r
// Read final cluster\r
- if( Length - pos == bpc )\r
+ if( (int)Length - pos == bpc )\r
{\r
FAT_int_ReadCluster( disk, cluster, bpc, (void*)(Buffer+pos) );\r
}\r
*/\r
tVFS_Node *FAT_int_CreateNode(tVFS_Node *Parent, fat_filetable *Entry, int Pos)\r
{\r
- tVFS_Node node = {0};\r
+ tVFS_Node node;\r
tVFS_Node *ret;\r
tFAT_VolInfo *disk = Parent->ImplPtr;\r
\r
ENTER("pParent pFT", Parent, Entry);\r
\r
+ memset(&node, 0, sizeof(tVFS_Node));\r
+ \r
// Set Other Data\r
// 0-31: Cluster, 32-63: Parent Cluster\r
node.Inode = Entry->cluster | (Entry->clusterHi<<16) | (Parent->Inode << 32);\r
tInterface *iface;
// Sanity Check Packet
- if( Length < sizeof(tArpRequest4) ) {
+ if( Length < (int)sizeof(tArpRequest4) ) {
Log_Log("ARP", "Recieved undersized packet");
return ;
}
}
break;
case 6:
- if( Length < sizeof(tArpRequest6) ) {
+ if( Length < (int)sizeof(tArpRequest6) ) {
Log_Log("ARP", "Recieved undersized packet (IPv6)");
return ;
}
ARP_UpdateCache4( req4->SourceIP, From );
break;
case 6:
- if( Length < sizeof(tArpRequest6) ) {
+ if( Length < (int)sizeof(tArpRequest6) ) {
Log_Debug("ARP", "Recieved undersized packet (IPv6)");
return ;
}
ret = VFS_Read(Adapter->DeviceFD, MAX_PACKET_SIZE, buf);
if(ret == -1) break;
- if(ret <= sizeof(tEthernetHeader)) {
+ if(ret <= (int)sizeof(tEthernetHeader)) {
Log_Log("NET", "Recieved an undersized packet");
continue;
}
for( iface = gIP_Interfaces; iface; iface = iface->Next )
{
- if( iface->Node.ImplInt == num )
+ if( (int)iface->Node.ImplInt == num )
{
LEAVE('p', &iface->Node);
return &iface->Node;
{0x10EC, 0x8029}, // Realtek 8029
{0x10EC, 0x8129} // Realtek 8129
};
-#define NUM_COMPAT_DEVICES (sizeof(csaCOMPAT_DEVICES)/sizeof(csaCOMPAT_DEVICES[0]))
+#define NUM_COMPAT_DEVICES ((int)(sizeof(csaCOMPAT_DEVICES)/sizeof(csaCOMPAT_DEVICES[0])))
enum eNe2k_Page0Read {
CMD = 0, //!< the master command register
* - main.c
*/
#define DEBUG 1
+#define VERSION 0x0032
#include <acess.h>
#include <modules.h>
#include <vfs.h>
void ATA_int_BusMasterWriteDWord(int Ofs, Uint32 Value);
// === GLOBALS ===
-MODULE_DEFINE(0, 0x0032, i386ATA, ATA_Install, NULL, "PCI", NULL);
+MODULE_DEFINE(0, VERSION, i386ATA, ATA_Install, NULL, "PCI", NULL);
tDevFS_Driver gATA_DriverInfo = {
NULL, "ata",
{
tATA_Disk gATA_Disks[MAX_ATA_DISKS];
int giATA_NumNodes;
tVFS_Node **gATA_Nodes;
-Uint16 gATA_BusMasterBase = 0;
+Uint32 gATA_BusMasterBase = 0;
Uint8 *gATA_BusMasterBasePtr = 0;
int gATA_IRQPri = 14;
int gATA_IRQSec = 15;
void ATA_ParseGPT(int Disk)
{
///\todo Support GPT Disks
- Warning("GPT Disks are currently unsupported");
+ Warning("GPT Disks are currently unsupported (Disk %i)", Disk);
}
/**
/**
* \fn char *ATA_ReadDir(tVFS_Node *Node, int Pos)
*/
-char *ATA_ReadDir(tVFS_Node *Node, int Pos)
+char *ATA_ReadDir(tVFS_Node *UNUSED(Node), int Pos)
{
if(Pos >= giATA_NumNodes || Pos < 0) return NULL;
return strdup( gATA_Nodes[Pos]->ImplPtr );
/**
* \fn tVFS_Node *ATA_FindDir(tVFS_Node *Node, char *Name)
*/
-tVFS_Node *ATA_FindDir(tVFS_Node *Node, char *Name)
+tVFS_Node *ATA_FindDir(tVFS_Node *UNUSED(Node), char *Name)
{
int part;
tATA_Disk *disk;
return DrvUtil_WriteBlock(Offset, Length, Buffer, ATA_ReadRaw, ATA_WriteRaw, SECTOR_SIZE, disk);
}
+const char *csaATA_IOCtls[] = {DRV_IOCTLNAMES, DRV_DISK_IOCTLNAMES, NULL};
/**
* \fn int ATA_IOCtl(tVFS_Node *Node, int Id, void *Data)
* \brief IO Control Funtion
*/
-int ATA_IOCtl(tVFS_Node *Node, int Id, void *Data)
+int ATA_IOCtl(tVFS_Node *UNUSED(Node), int Id, void *Data)
{
switch(Id)
{
- case DRV_IOCTL_TYPE: return DRV_TYPE_DISK;
+ BASE_IOCTLS(DRV_TYPE_DISK, "i386ATA", VERSION, csaATA_IOCtls);
+
+ case DISK_IOCTL_GETBLOCKSIZE:
+ return 512;
+
+ default:
+ return 0;
}
return 0;
}
gaATA_IRQs[cont] = 0;
// Set up transfer
- outb(base+0x01, 0x00);
if( Address > 0x0FFFFFFF ) // Use LBA48
{
outb(base+0x6, 0x40 | (disk << 4));
outb(base+0x06, 0xE0 | (disk << 4) | ((Address >> 24) & 0x0F)); // Magic, Disk, High addr
}
+ outb(base+0x01, 0x01); //?
outb(base+0x02, (Uint8) Count); // Sector Count
outb(base+0x03, (Uint8) Address); // Low Addr
outb(base+0x04, (Uint8) (Address >> 8)); // Middle Addr
outb(base+0x05, (Uint8) (Address >> 16)); // High Addr
LOG("Starting Transfer");
+ LOG("gATA_PRDTs[%i].Bytes = %i", cont, gATA_PRDTs[cont].Bytes);
if( Address > 0x0FFFFFFF )
outb(base+0x07, HDD_DMA_R48); // Read Command (LBA48)
else
outb(base+0x07, HDD_DMA_R28); // Read Command (LBA28)
+
// Start transfer
ATA_int_BusMasterWriteByte( cont << 3, 9 ); // Read and start
val = inb(base+0x7);
LOG("Status byte = 0x%02x", val);
+ LOG("gATA_PRDTs[%i].Bytes = %i", cont, gATA_PRDTs[cont].Bytes);
LOG("Transfer Completed & Acknowledged");
// Copy to destination buffer
/**
* \fn void ATA_IRQHandlerPri(int unused)
*/
-void ATA_IRQHandlerPri(int unused)
+void ATA_IRQHandlerPri(int UNUSED(IRQ))
{
Uint8 val;
/**
* \fn void ATA_IRQHandlerSec(int unused)
*/
-void ATA_IRQHandlerSec(int unused)
+void ATA_IRQHandlerSec(int UNUSED(IRQ))
{
Uint8 val;
// IRQ bit set for Secondary Controller
while(extendedLBA != 0)
{
extendedLBA = ATA_MBR_int_ReadExt(Disk, extendedLBA, &base, &len);
- if( extendedLBA == -1 ) return ;
+ if( extendedLBA == 0xFFFFFFFF ) return ;
gATA_Disks[Disk].NumPartitions ++;
}
LOG("gATA_Disks[Disk].NumPartitions = %i", gATA_Disks[Disk].NumPartitions);
* \fn char *FDD_ReadDir(tVFS_Node *Node, int pos)
* \brief Read Directory
*/
-char *FDD_ReadDir(tVFS_Node *Node, int Pos)
+char *FDD_ReadDir(tVFS_Node *UNUSED(Node), int Pos)
{
char name[2] = "0\0";
* \fn tVFS_Node *FDD_FindDir(tVFS_Node *Node, char *filename);
* \brief Find File Routine (for vfs_node)
*/
-tVFS_Node *FDD_FindDir(tVFS_Node *Node, char *Filename)
+tVFS_Node *FDD_FindDir(tVFS_Node *UNUSED(Node), char *Filename)
{
int i;
* \fn int FDD_IOCtl(tVFS_Node *Node, int id, void *data)
* \brief Stub ioctl function
*/
-int FDD_IOCtl(tVFS_Node *Node, int ID, void *Data)
+int FDD_IOCtl(tVFS_Node *UNUSED(Node), int ID, void *Data)
{
switch(ID)
{
- case DRV_IOCTL_TYPE: return DRV_TYPE_DISK;
- case DRV_IOCTL_IDENT: return ModUtil_SetIdent(Data, "FDD");
- case DRV_IOCTL_VERSION: return FDD_VERSION;
- case DRV_IOCTL_LOOKUP: return ModUtil_LookupString((char**)casIOCTLS, Data);
+ BASE_IOCTLS(DRV_TYPE_DISK, "FDD", FDD_VERSION, casIOCTLS);
case DISK_IOCTL_GETBLOCKSIZE: return 512;