#define NULL ((void*)0)
#define PACKED __attribute__ ((packed))
+#define offsetof(st, m) ((Uint)((char *)&((st *)(0))->m - (char *)0 ))
+
//#include <stdint.h>
#include <arch.h>
* \brief Create a timestamp from a time
*/
extern Sint64 timestamp(int sec, int mins, int hrs, int day, int month, int year);
+/**
+ * \brief Gets the current timestamp (miliseconds since Midnight 1st January 1970)
+ */
extern Sint64 now(void);
-extern int Time_CreateTimer(int Delta, void *Callback, void *Argument);
+/**
+ * \brief Timer callback function
+ */
+typedef void (tTimerCallback)(void *);
+/**
+ * \brief Creates a one-shot timer
+ * \param Delta Period of the timer
+ * \param Callback Function to call each time
+ * \param Argument Argument to pass to the callback
+ */
+extern int Time_CreateTimer(int Delta, tTimerCallback *Callback, void *Argument);
+/**
+ * \brief Removed an active timer
+ */
extern void Time_RemoveTimer(int ID);
extern void Time_Delay(int Delay);
/**
}
/**
- * \fn int Time_CreateTimer(int Delta, void *Callback, void *Argument)
+ * \fn int Time_CreateTimer(int Delta, tTimerCallback *Callback, void *Argument)
*/
-int Time_CreateTimer(int Delta, void *Callback, void *Argument)
+int Time_CreateTimer(int Delta, tTimerCallback *Callback, void *Argument)
{
int ret;
int Vesa_Int_SetMode(int Mode);\r
int Vesa_Int_FindMode(tVideo_IOCtl_Mode *data);\r
int Vesa_Int_ModeInfo(tVideo_IOCtl_Mode *data);\r
+void Vesa_FlipCursor(void *Arg);\r
// --- 2D Acceleration Functions --\r
void Vesa_2D_Fill(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colour);\r
void Vesa_2D_Blit(void *Ent, Uint16 DstX, Uint16 DstY, Uint16 SrcX, Uint16 SrcY, Uint16 W, Uint16 H);\r
};\r
tSpinlock glVesa_Lock;\r
tVM8086 *gpVesa_BiosState;\r
+ int giVesaDriverId = -1;\r
+// --- Video Modes ---\r
int giVesaCurrentMode = 0;\r
int giVesaCurrentFormat = VIDEO_BUFFMT_TEXT;\r
- int giVesaDriverId = -1;\r
-char *gpVesa_Framebuffer = (void*)VESA_DEFAULT_FRAMEBUFFER;\r
tVesa_Mode *gVesa_Modes;\r
int giVesaModeCount = 0;\r
- int giVesaPageCount = 0;\r
+// --- Framebuffer ---\r
+char *gpVesa_Framebuffer = (void*)VESA_DEFAULT_FRAMEBUFFER;\r
+ int giVesaPageCount = 0; //!< Framebuffer size in pages\r
+// --- Cursor Control ---\r
+ int giVesaCursorX = -1;\r
+ int giVesaCursorY = -1;\r
+ int giVesaCursorTimer = -1; // Invalid timer\r
+// --- 2D Video Stream Handlers ---\r
tDrvUtil_Video_2DHandlers gVesa_2DFunctions = {\r
NULL,\r
Vesa_2D_Fill,\r
return ret;\r
\r
case VIDEO_IOCTL_SETCURSOR: // Set cursor position\r
+ giVesaCursorX = ((tVideo_IOCtl_Pos*)Data)->x;\r
+ giVesaCursorY = ((tVideo_IOCtl_Pos*)Data)->y;\r
+ if(\r
+ giVesaCursorX < 0 || giVesaCursorY < 0\r
+ || giVesaCursorX >= gVesa_Modes[giVesaCurrentMode].width\r
+ || giVesaCursorY >= gVesa_Modes[giVesaCurrentMode].height)\r
+ {\r
+ if(giVesaCursorTimer != -1)\r
+ Time_RemoveTimer(giVesaCursorTimer);\r
+ giVesaCursorX = -1;\r
+ giVesaCursorY = -1;\r
+ }\r
+ else {\r
+ if(giVesaCursorTimer == -1)\r
+ giVesaCursorTimer = Time_CreateTimer(500, Vesa_FlipCursor, Node);\r
+ }\r
+ \r
+ Log_Debug("VESA", "Cursor at (%i,%i), timer %i",\r
+ giVesaCursorX, giVesaCursorY, giVesaCursorTimer);\r
return 0;\r
\r
case VIDEO_IOCTL_REQLFB: // Request Linear Framebuffer\r
return 0;\r
}\r
\r
+/**\r
+ * \brief Updates the video mode\r
+ */\r
int Vesa_Int_SetMode(int mode)\r
{\r
Log_Log("VESA", "Setting mode to %i", mode);\r
return 1;\r
}\r
\r
+/**\r
+ * \brief Updates the state of the text cursor\r
+ * \note Just does a bitwise not on the cursor region\r
+ */\r
+void Vesa_FlipCursor(void *Arg)\r
+{\r
+ int pitch = gVesa_Modes[giVesaCurrentMode].pitch;\r
+ int x = giVesaCursorX*giVT_CharWidth;\r
+ int y = giVesaCursorY*giVT_CharHeight;\r
+ int i;\r
+ Uint32 *fb = (void*)gpVesa_Framebuffer;\r
+ \r
+ if(giVesaCursorX < 0 || giVesaCursorY < 0) return;\r
+ \r
+ for( i = 0; i < giVT_CharHeight; i++ )\r
+ fb[(y+i)*pitch+x] = fb[(y+i)*pitch+x];\r
+ \r
+ giVesaCursorTimer = Time_CreateTimer(500, Vesa_FlipCursor, Arg);\r
+}\r
+\r
// ------------------------\r
// --- 2D Accelleration ---\r
// ------------------------\r
/*
+ * Acess2 - NTFS Driver
+ * By John Hodge (thePowersGang)
+ * This file is published under the terms of the Acess licence. See the
+ * file COPYING for details.
+ *
+ * common.h - Common Types and Definitions
*/
#ifndef _COMMON_H_
#define _COMMON_H_
+#include <acess.h>
+#include <vfs.h>
+
// === STRUCTURES ===
/**
* In-memory representation of an NTFS Disk
typedef struct sNTFS_Disk
{
int FD;
- Uint64 MFTOfs;
+
+ int ClusterSize;
+ Uint64 MFTBase;
+
tVFS_Node RootNode;
} tNTFS_Disk;
Uint64 SerialNumber;
- Uint8 Padding[515-offsetof(tNTFS_BootSector, Padding)];
+ Uint8 Padding[512-72];
} tNTFS_BootSector;
*/
#define DEBUG 1
#define VERBOSE 0
+#include <acess.h>
+#include <vfs.h>
#include "common.h"
#include <modules.h>
disk->MFTBase = bs.MFTStart;
Log_Debug("NTFS", "MFT Base = %i", disk->MFTBase);
- disk->RootNode.Inode = 5; // MFT Ent #5 is '.'
+ disk->RootNode.Inode = 5; // MFT Ent #5 is filesystem root
disk->RootNode.ImplPtr = disk;
disk->RootNode.UID = 0;
void FDD_Reset(int id);
void FDD_Recalibrate(int disk);
int FDD_int_SeekTrack(int disk, int head, int track);
-void FDD_int_TimerCallback(int arg);
-void FDD_int_StopMotor(int disk);
-void FDD_int_StartMotor(int disk);
+void FDD_int_TimerCallback(void *Arg);
+void FDD_int_StopMotor(void *Arg);
+void FDD_int_StartMotor(int Disk);
int FDD_int_GetDims(int type, int lba, int *c, int *h, int *s, int *spt);
// === GLOBALS ===
LOCK(&glFDD);
for(i=0;i<4;i++) {
Time_RemoveTimer(gFDD_Devices[i].timer);
- FDD_int_StopMotor(i);
+ FDD_int_StopMotor((void*)i);
}
RELEASE(&glFDD);
//IRQ_Clear(6);
FDD_SensInt(cPORTBASE[disk>>1], NULL, NULL);
LOG("Stopping Motor");
- FDD_int_StopMotor(disk);
+ gFDD_Devices[disk].timer = Time_CreateTimer(MOTOR_OFF_DELAY, FDD_int_StopMotor, (void*)(Uint)disk);
LEAVE('-');
}
* \fn void FDD_int_TimerCallback()
* \brief Called by timer
*/
-void FDD_int_TimerCallback(int arg)
+void FDD_int_TimerCallback(void *Arg)
{
- ENTER("iarg", arg);
- if(gFDD_Devices[arg].motorState == 1)
- gFDD_Devices[arg].motorState = 2;
- Time_RemoveTimer(gFDD_Devices[arg].timer);
- gFDD_Devices[arg].timer = -1;
+ int disk = (int)Arg;
+ ENTER("iarg", disk);
+ if(gFDD_Devices[disk].motorState == 1)
+ gFDD_Devices[disk].motorState = 2;
+ Time_RemoveTimer(gFDD_Devices[disk].timer);
+ gFDD_Devices[disk].timer = -1;
LEAVE('-');
}
state |= 1 << (4+disk);
outb( cPORTBASE[ disk>>1 ] + PORT_DIGOUTPUT, state );
gFDD_Devices[disk].motorState = 1;
- gFDD_Devices[disk].timer = Time_CreateTimer(MOTOR_ON_DELAY, FDD_int_TimerCallback, (void*)(tVAddr)disk);
+ gFDD_Devices[disk].timer = Time_CreateTimer(MOTOR_ON_DELAY, FDD_int_TimerCallback, (void*)(Uint)disk);
}
/**
* \fn void FDD_int_StopMotor(int disk)
* \brief Stops FDD Motor
*/
-void FDD_int_StopMotor(int disk)
+void FDD_int_StopMotor(void *Arg)
{
- Uint8 state;
+ Uint8 state, disk = (int)Arg;
if( IS_LOCKED(&glFDD) ) return ;
ENTER("iDisk", disk);
}
return ret;
#else
- uint64_t P[64], q, n;
+ uint64_t P[2];
+ uint64_t q;
int i;
if(Den == 0) __asm__ __volatile__ ("int $0x0");
if(Den == 2) return Num >> 1;
if(Den == 16) return Num >> 4;
if(Num < Den) return 0;
- if(Num == Den) return 1;
+ if(Num < Den*2) return 1;
if(Num == Den*2) return 2;
- // Non-restoring division, from wikipedia
+ // Restoring division, from wikipedia
// http://en.wikipedia.org/wiki/Division_(digital)
- P[0] = Num;
- for( i = 0; i < 64; i ++ )
+ P[0] = Num; P[1] = 0;
+ for( i = 64; i--; )
{
- if( P[i] >= 0 ) {
+ // P <<= 1;
+ P[1] = (P[1] << 1) | (P[0] >> 63);
+ P[0] = P[0] << 1;
+
+ // P -= Den << 64
+ P[1] -= Den;
+
+ // P >= 0
+ if( !(P[1] & (1ULL<<63)) ) {
q |= (uint64_t)1 << (63-i);
- P[i+1] = 2*P[i] - Den;
}
else {
//q |= 0 << (63-i);
- P[i+1] = 2*P[i] + Den;
+ P[1] += Den;
}
}
- n = ~q;
- n = -n;
- q += n;
-
return q;
#endif
}