mirror of
https://github.com/Fennix-Project/Drivers.git
synced 2025-05-28 15:34:29 +00:00
Update drivers
This commit is contained in:
parent
0091fe5965
commit
4d4c2aeba6
@ -29,6 +29,8 @@ __attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
|||||||
|
|
||||||
KernelAPI *KAPI;
|
KernelAPI *KAPI;
|
||||||
|
|
||||||
|
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#define ATA_DEV_BUSY 0x80
|
#define ATA_DEV_BUSY 0x80
|
||||||
@ -190,9 +192,11 @@ typedef enum
|
|||||||
_URC_CONTINUE_UNWIND = 8
|
_URC_CONTINUE_UNWIND = 8
|
||||||
} _Unwind_Reason_Code;
|
} _Unwind_Reason_Code;
|
||||||
|
|
||||||
|
struct _Unwind_Context;
|
||||||
typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__)));
|
typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__)));
|
||||||
typedef unsigned _Unwind_Word __attribute__((__mode__(__unwind_word__)));
|
typedef unsigned _Unwind_Word __attribute__((__mode__(__unwind_word__)));
|
||||||
typedef void (*_Unwind_Exception_Cleanup_Fn)(_Unwind_Reason_Code, struct _Unwind_Exception *);
|
typedef void (*_Unwind_Exception_Cleanup_Fn)(_Unwind_Reason_Code, struct _Unwind_Exception *);
|
||||||
|
typedef int _Unwind_Action;
|
||||||
|
|
||||||
struct _Unwind_Exception
|
struct _Unwind_Exception
|
||||||
{
|
{
|
||||||
@ -206,7 +210,13 @@ struct _Unwind_Exception
|
|||||||
#endif
|
#endif
|
||||||
} __attribute__((__aligned__));
|
} __attribute__((__aligned__));
|
||||||
|
|
||||||
extern "C" void _Unwind_Resume(_Unwind_Exception *) { KAPI->Util.DebugPrint(((char *)"_Unwind_Resume" + KAPI->Info.Offset), KAPI->Info.DriverUID); }
|
extern "C" _Unwind_Reason_Code __gxx_personality_v0(int, _Unwind_Action, _Unwind_Exception_Class, _Unwind_Exception *, _Unwind_Context *)
|
||||||
|
{
|
||||||
|
print("__gxx_personality_v0");
|
||||||
|
return _URC_NO_REASON;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void _Unwind_Resume(_Unwind_Exception *) { print("_Unwind_Resume"); }
|
||||||
|
|
||||||
void *operator new(size_t Size) { return KAPI->Memory.RequestPage(Size / KAPI->Memory.PageSize + 1); }
|
void *operator new(size_t Size) { return KAPI->Memory.RequestPage(Size / KAPI->Memory.PageSize + 1); }
|
||||||
void operator delete(void *Ptr) { KAPI->Memory.FreePage(Ptr, 1); } // Potential memory leak
|
void operator delete(void *Ptr) { KAPI->Memory.FreePage(Ptr, 1); } // Potential memory leak
|
||||||
@ -284,7 +294,7 @@ public:
|
|||||||
if (this->PortNumber == PortType::SATAPI && Write)
|
if (this->PortNumber == PortType::SATAPI && Write)
|
||||||
{
|
{
|
||||||
// err("SATAPI port does not support write.");
|
// err("SATAPI port does not support write.");
|
||||||
KAPI->Util.DebugPrint(((char *)"SATAPI port does not support write." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("SATAPI port does not support write.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +346,7 @@ public:
|
|||||||
if (Spin == 1000000)
|
if (Spin == 1000000)
|
||||||
{
|
{
|
||||||
// err("Port not responding.");
|
// err("Port not responding.");
|
||||||
KAPI->Util.DebugPrint(((char *)"Port not responding." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Port not responding.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,7 +360,7 @@ public:
|
|||||||
if (Spin > 100000000)
|
if (Spin > 100000000)
|
||||||
{
|
{
|
||||||
// err("Port %d not responding. (%d)", this->PortNumber, TryCount);
|
// err("Port %d not responding. (%d)", this->PortNumber, TryCount);
|
||||||
KAPI->Util.DebugPrint(((char *)"Port not responding." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Port not responding.");
|
||||||
Spin = 0;
|
Spin = 0;
|
||||||
TryCount++;
|
TryCount++;
|
||||||
if (TryCount > 10)
|
if (TryCount > 10)
|
||||||
@ -362,7 +372,7 @@ public:
|
|||||||
if (HBAPortPtr->InterruptStatus & HBA_PxIS_TFES)
|
if (HBAPortPtr->InterruptStatus & HBA_PxIS_TFES)
|
||||||
{
|
{
|
||||||
// err("Error reading/writing (%d).", Write);
|
// err("Error reading/writing (%d).", Write);
|
||||||
KAPI->Util.DebugPrint(((char *)"Error reading/writing." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Error reading/writing.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -425,12 +435,12 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
{
|
{
|
||||||
case AcknowledgeReason:
|
case AcknowledgeReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Kernel acknowledged the driver.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ConfigurationReason:
|
case ConfigurationReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Kernel received configuration data." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Kernel received configuration data.");
|
||||||
PCIBaseAddress = reinterpret_cast<PCIDeviceHeader *>(Data->RawPtr);
|
PCIBaseAddress = reinterpret_cast<PCIDeviceHeader *>(Data->RawPtr);
|
||||||
ABAR = reinterpret_cast<HBAMemory *>(((PCIHeader0 *)PCIBaseAddress)->BAR5);
|
ABAR = reinterpret_cast<HBAMemory *>(((PCIHeader0 *)PCIBaseAddress)->BAR5);
|
||||||
KAPI->Memory.Map((void *)ABAR, (void *)ABAR, (1 << 1));
|
KAPI->Memory.Map((void *)ABAR, (void *)ABAR, (1 << 1));
|
||||||
@ -444,14 +454,14 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
if (portType == PortType::SATA || portType == PortType::SATAPI)
|
if (portType == PortType::SATA || portType == PortType::SATAPI)
|
||||||
{
|
{
|
||||||
// trace("%s drive found at port %d", PortTypeName[portType], i);
|
// trace("%s drive found at port %d", PortTypeName[portType], i);
|
||||||
KAPI->Util.DebugPrint(((char *)"SATA drive found." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("SATA drive found.");
|
||||||
Ports[PortCount] = new Port(portType, &ABAR->Ports[i], PortCount);
|
Ports[PortCount] = new Port(portType, &ABAR->Ports[i], PortCount);
|
||||||
PortCount++;
|
PortCount++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (portType != PortType::None)
|
if (portType != PortType::None)
|
||||||
KAPI->Util.DebugPrint(((char *)"Unsupported port type found." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Unsupported port type found.");
|
||||||
// warn("Unsupported drive type %s found at port %d", PortTypeName[portType], i);
|
// warn("Unsupported drive type %s found at port %d", PortTypeName[portType], i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -467,6 +477,12 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
Data->DiskCallback.Fetch.BytesPerSector = 512;
|
Data->DiskCallback.Fetch.BytesPerSector = 512;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case StopReason:
|
||||||
|
{
|
||||||
|
// TODO: Stop the driver.
|
||||||
|
print("Driver stopped.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
case SendReason:
|
case SendReason:
|
||||||
case ReceiveReason:
|
case ReceiveReason:
|
||||||
{
|
{
|
||||||
@ -478,7 +494,7 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Unknown reason.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,12 @@ HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
|||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
||||||
INCLUDE_DIR = ../../include
|
INCLUDE_DIR = ../../include
|
||||||
|
|
||||||
LDFLAGS := \
|
LDFLAGS := \
|
||||||
-fPIC -fno-pie \
|
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||||
-nostdlib -nodefaultlibs -nolibc \
|
-nostdlib -nodefaultlibs -nolibc \
|
||||||
-zmax-page-size=0x1000 \
|
-zmax-page-size=0x1000 \
|
||||||
-Wl,-Map file.map -shared
|
-Wl,-Map file.map -static -Tlinker.ld
|
||||||
|
|
||||||
WARNCFLAG = -Wall -Wextra
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
@ -45,23 +45,20 @@ CFLAGS := \
|
|||||||
|
|
||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 \
|
-mno-red-zone -mno-sse -mno-sse2 \
|
||||||
-march=x86-64 -pipe -ffunction-sections \
|
-march=x86-64 -pipe -ffunction-sections \
|
||||||
-mcmodel=kernel -msoft-float -fno-builtin
|
-msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/amd64/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), i686)
|
else ifeq ($(OSARCH), i686)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
||||||
-march=i686 -pipe -msoft-float -fno-builtin
|
-march=i686 -pipe -msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/i686/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
|
||||||
CFLAGS += -pipe -fno-builtin -fPIC
|
CFLAGS += -pipe -fno-builtin -fPIC
|
||||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@ __attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
|||||||
|
|
||||||
KernelAPI *KAPI;
|
KernelAPI *KAPI;
|
||||||
|
|
||||||
|
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int DriverEntry(void *Data)
|
int DriverEntry(void *Data)
|
||||||
@ -43,12 +45,12 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
{
|
{
|
||||||
case AcknowledgeReason:
|
case AcknowledgeReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Kernel acknowledged the driver.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ConfigurationReason:
|
case ConfigurationReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Kernel received configuration data." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Kernel received configuration data.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FetchReason:
|
case FetchReason:
|
||||||
@ -59,11 +61,11 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
{
|
{
|
||||||
if (Data->InterruptInfo.Vector == 0xE)
|
if (Data->InterruptInfo.Vector == 0xE)
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"IRQ14" + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("IRQ14");
|
||||||
}
|
}
|
||||||
else if (Data->InterruptInfo.Vector == 0xF)
|
else if (Data->InterruptInfo.Vector == 0xF)
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"IRQ15" + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("IRQ15");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -72,9 +74,15 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case StopReason:
|
||||||
|
{
|
||||||
|
// TODO: Stop the driver.
|
||||||
|
print("Driver stopped.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Unknown reason.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,12 @@ HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
|||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
||||||
INCLUDE_DIR = ../../include
|
INCLUDE_DIR = ../../include
|
||||||
|
|
||||||
LDFLAGS := \
|
LDFLAGS := \
|
||||||
-fPIC -fno-pie \
|
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||||
-nostdlib -nodefaultlibs -nolibc \
|
-nostdlib -nodefaultlibs -nolibc \
|
||||||
-zmax-page-size=0x1000 \
|
-zmax-page-size=0x1000 \
|
||||||
-Wl,-Map file.map -shared
|
-Wl,-Map file.map -static -Tlinker.ld
|
||||||
|
|
||||||
WARNCFLAG = -Wall -Wextra
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
@ -45,23 +45,20 @@ CFLAGS := \
|
|||||||
|
|
||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 \
|
-mno-red-zone -mno-sse -mno-sse2 \
|
||||||
-march=x86-64 -pipe -ffunction-sections \
|
-march=x86-64 -pipe -ffunction-sections \
|
||||||
-mcmodel=kernel -msoft-float -fno-builtin
|
-msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/amd64/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), i686)
|
else ifeq ($(OSARCH), i686)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
||||||
-march=i686 -pipe -msoft-float -fno-builtin
|
-march=i686 -pipe -msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/i686/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
|
||||||
CFLAGS += -pipe -fno-builtin -fPIC
|
CFLAGS += -pipe -fno-builtin -fPIC
|
||||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
/* EXPERIMENTAL */
|
|
||||||
|
|
||||||
OUTPUT_FORMAT(binary)
|
OUTPUT_FORMAT(binary)
|
||||||
OUTPUT_ARCH(i386:x86-64)
|
OUTPUT_ARCH(i386:x86-64)
|
||||||
|
|
@ -27,6 +27,9 @@ __attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
|||||||
// Global variable that holds the kernel API
|
// Global variable that holds the kernel API
|
||||||
KernelAPI *KAPI;
|
KernelAPI *KAPI;
|
||||||
|
|
||||||
|
// Macro that prints a message to UART
|
||||||
|
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
// Driver entry point. This is called at initialization. "Data" argument points to the kernel API structure.
|
// Driver entry point. This is called at initialization. "Data" argument points to the kernel API structure.
|
||||||
@ -44,7 +47,7 @@ int DriverEntry(void *Data)
|
|||||||
return KERNEL_API_VERSION_NOT_SUPPORTED;
|
return KERNEL_API_VERSION_NOT_SUPPORTED;
|
||||||
|
|
||||||
// We print "Hello World!" to UART.
|
// We print "Hello World!" to UART.
|
||||||
KAPI->Util.DebugPrint(((char *)"Hello World!" + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Hello World!");
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,17 +58,22 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
{
|
{
|
||||||
case AcknowledgeReason:
|
case AcknowledgeReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Kernel acknowledged the driver.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InterruptReason:
|
case InterruptReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Interrupt received." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Interrupt received.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case StopReason:
|
||||||
|
{
|
||||||
|
print("Driver stopped.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Unknown reason.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,12 @@ HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
|||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
||||||
INCLUDE_DIR = ../../include
|
INCLUDE_DIR = ../../include
|
||||||
|
|
||||||
LDFLAGS := \
|
LDFLAGS := \
|
||||||
-fPIC -fno-pie \
|
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||||
-nostdlib -nodefaultlibs -nolibc \
|
-nostdlib -nodefaultlibs -nolibc \
|
||||||
-zmax-page-size=0x1000 \
|
-zmax-page-size=0x1000 \
|
||||||
-Wl,-Map file.map -shared
|
-Wl,-Map file.map -static -Tlinker.ld
|
||||||
|
|
||||||
WARNCFLAG = -Wall -Wextra
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
@ -45,23 +45,20 @@ CFLAGS := \
|
|||||||
|
|
||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 \
|
-mno-red-zone -mno-sse -mno-sse2 \
|
||||||
-march=x86-64 -pipe -ffunction-sections \
|
-march=x86-64 -pipe -ffunction-sections \
|
||||||
-mcmodel=kernel -msoft-float -fno-builtin
|
-msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/amd64/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), i686)
|
else ifeq ($(OSARCH), i686)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
||||||
-march=i686 -pipe -msoft-float -fno-builtin
|
-march=i686 -pipe -msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/i686/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
|
||||||
CFLAGS += -pipe -fno-builtin -fPIC
|
CFLAGS += -pipe -fno-builtin -fPIC
|
||||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -88,13 +85,7 @@ $(FILENAME): $(OBJ)
|
|||||||
|
|
||||||
%.o: %.S
|
%.o: %.S
|
||||||
$(info Compiling $<)
|
$(info Compiling $<)
|
||||||
ifeq ($(OSARCH), amd64)
|
|
||||||
$(AS) -o $@ $<
|
$(AS) -o $@ $<
|
||||||
else ifeq ($(OSARCH), i686)
|
|
||||||
$(AS) -o $@ $<
|
|
||||||
else ifeq ($(OSARCH), aarch64)
|
|
||||||
$(AS) -o $@ $<
|
|
||||||
endif
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o file.map file_dump.map $(OBJ)
|
rm -f *.o file.map file_dump.map $(OBJ)
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
/* EXPERIMENTAL */
|
|
||||||
|
|
||||||
OUTPUT_FORMAT(binary)
|
OUTPUT_FORMAT(binary)
|
||||||
OUTPUT_ARCH(i386:x86-64)
|
OUTPUT_ARCH(i386:x86-64)
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
# Config file
|
# Config file
|
||||||
include ../../../Makefile.conf
|
include ../../../Makefile.conf
|
||||||
|
|
||||||
FILENAME = VMwareGuestDriver.fex
|
FILENAME = VMwareMouseDriver.fex
|
||||||
|
|
||||||
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
||||||
CPP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
CPP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
||||||
@ -29,12 +29,12 @@ HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
|||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
||||||
INCLUDE_DIR = ../../include
|
INCLUDE_DIR = ../../include
|
||||||
|
|
||||||
LDFLAGS := \
|
LDFLAGS := \
|
||||||
-fPIC -fno-pie \
|
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||||
-nostdlib -nodefaultlibs -nolibc \
|
-nostdlib -nodefaultlibs -nolibc \
|
||||||
-zmax-page-size=0x1000 \
|
-zmax-page-size=0x1000 \
|
||||||
-Wl,-Map file.map -shared
|
-Wl,-Map file.map -static -Tlinker.ld
|
||||||
|
|
||||||
WARNCFLAG = -Wall -Wextra
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
@ -45,23 +45,20 @@ CFLAGS := \
|
|||||||
|
|
||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 \
|
-mno-red-zone -mno-sse -mno-sse2 \
|
||||||
-march=x86-64 -pipe -ffunction-sections \
|
-march=x86-64 -pipe -ffunction-sections \
|
||||||
-mcmodel=kernel -msoft-float -fno-builtin
|
-msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/amd64/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), i686)
|
else ifeq ($(OSARCH), i686)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
||||||
-march=i686 -pipe -msoft-float -fno-builtin
|
-march=i686 -pipe -msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/i686/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
|
||||||
CFLAGS += -pipe -fno-builtin -fPIC
|
CFLAGS += -pipe -fno-builtin -fPIC
|
||||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
/* EXPERIMENTAL */
|
|
||||||
|
|
||||||
OUTPUT_FORMAT(binary)
|
OUTPUT_FORMAT(binary)
|
||||||
OUTPUT_ARCH(i386:x86-64)
|
OUTPUT_ARCH(i386:x86-64)
|
||||||
|
|
@ -24,6 +24,8 @@ __attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
|||||||
|
|
||||||
KernelAPI *KAPI;
|
KernelAPI *KAPI;
|
||||||
|
|
||||||
|
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* https://wiki.osdev.org/VMware_tools */
|
/* https://wiki.osdev.org/VMware_tools */
|
||||||
@ -189,7 +191,7 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
{
|
{
|
||||||
case AcknowledgeReason:
|
case AcknowledgeReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Kernel acknowledged the driver.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ConfigurationReason:
|
case ConfigurationReason:
|
||||||
@ -207,7 +209,33 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
Write(DATA, 0xF4);
|
Write(DATA, 0xF4);
|
||||||
Read();
|
Read();
|
||||||
Absolute();
|
Absolute();
|
||||||
KAPI->Util.DebugPrint(((char *)"VMware mouse configured." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("VMware mouse configured.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FetchReason:
|
||||||
|
{
|
||||||
|
Data->InputCallback.Mouse.X = MouseX;
|
||||||
|
Data->InputCallback.Mouse.Y = MouseY;
|
||||||
|
Data->InputCallback.Mouse.Z = MouseZ;
|
||||||
|
Data->InputCallback.Mouse.Buttons.Left = MouseButton & 0x20;
|
||||||
|
Data->InputCallback.Mouse.Buttons.Right = MouseButton & 0x10;
|
||||||
|
Data->InputCallback.Mouse.Buttons.Middle = MouseButton & 0x08;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case StopReason:
|
||||||
|
{
|
||||||
|
Relative();
|
||||||
|
// TODO: UNTESTED!!!
|
||||||
|
outb(COMMAND, 0xA8);
|
||||||
|
Write(COMMAND, READ_CONFIG);
|
||||||
|
uint8_t Status = Read();
|
||||||
|
Status &= ~0b10;
|
||||||
|
Write(COMMAND, WRITE_CONFIG);
|
||||||
|
Write(DATA, Status);
|
||||||
|
Write(COMMAND, 0xD4);
|
||||||
|
Write(DATA, 0xF5);
|
||||||
|
Read();
|
||||||
|
print("Driver stopped.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InterruptReason:
|
case InterruptReason:
|
||||||
@ -221,7 +249,7 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
|
|
||||||
if (cmd.ax == 0xFFFF0000)
|
if (cmd.ax == 0xFFFF0000)
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"VMware mouse is not connected?" + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("VMware mouse is not connected?");
|
||||||
Relative();
|
Relative();
|
||||||
Absolute();
|
Absolute();
|
||||||
return ERROR;
|
return ERROR;
|
||||||
@ -235,25 +263,16 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
|
|
||||||
int flags = (cmd.ax & 0xFFFF0000) >> 16; /* Not important */
|
int flags = (cmd.ax & 0xFFFF0000) >> 16; /* Not important */
|
||||||
(void)flags;
|
(void)flags;
|
||||||
MouseButton = (cmd.ax & 0xFFFF); /* 0x10 = Right, 0x20 = Left, 0x08 = Middle */
|
MouseButton = (cmd.ax & 0xFFFF); /* 0x10 = Right, 0x20 = Left, 0x08 = Middle */
|
||||||
MouseX = cmd.bx; /* Both X and Y are scaled from 0 to 0xFFFF */
|
MouseX = cmd.bx; /* Both X and Y are scaled from 0 to 0xFFFF */
|
||||||
MouseY = cmd.cx; /* You should map these somewhere to the actual resolution. */
|
MouseY = cmd.cx; /* You should map these somewhere to the actual resolution. */
|
||||||
MouseZ = (int8_t)cmd.dx; /* Z is a single signed byte indicating scroll direction. */
|
MouseZ = (int8_t)cmd.dx; /* Z is a single signed byte indicating scroll direction. */
|
||||||
break;
|
|
||||||
}
|
|
||||||
case FetchReason:
|
|
||||||
{
|
|
||||||
Data->InputCallback.Mouse.X = MouseX;
|
|
||||||
Data->InputCallback.Mouse.Y = MouseY;
|
|
||||||
Data->InputCallback.Mouse.Z = MouseZ;
|
|
||||||
Data->InputCallback.Mouse.Buttons.Left = MouseButton & 0x20;
|
|
||||||
Data->InputCallback.Mouse.Buttons.Right = MouseButton & 0x10;
|
|
||||||
Data->InputCallback.Mouse.Buttons.Middle = MouseButton & 0x08;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Unknown reason.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Config file
|
# Config file
|
||||||
include ../../../Makefile.conf
|
include ../../../Makefile.conf
|
||||||
|
|
||||||
FILENAME = amd_pcnet.fex
|
FILENAME = AMD-PCNET.fex
|
||||||
|
|
||||||
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
||||||
CPP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
CPP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
||||||
@ -29,12 +29,12 @@ HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
|||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
||||||
INCLUDE_DIR = ../../include
|
INCLUDE_DIR = ../../include
|
||||||
|
|
||||||
LDFLAGS := \
|
LDFLAGS := \
|
||||||
-fPIC -fno-pie \
|
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||||
-nostdlib -nodefaultlibs -nolibc \
|
-nostdlib -nodefaultlibs -nolibc \
|
||||||
-zmax-page-size=0x1000 \
|
-zmax-page-size=0x1000 \
|
||||||
-Wl,-Map file.map -shared
|
-Wl,-Map file.map -static -Tlinker.ld
|
||||||
|
|
||||||
WARNCFLAG = -Wall -Wextra
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
@ -45,23 +45,20 @@ CFLAGS := \
|
|||||||
|
|
||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 \
|
-mno-red-zone -mno-sse -mno-sse2 \
|
||||||
-march=x86-64 -pipe -ffunction-sections \
|
-march=x86-64 -pipe -ffunction-sections \
|
||||||
-mcmodel=kernel -msoft-float -fno-builtin
|
-msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/amd64/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), i686)
|
else ifeq ($(OSARCH), i686)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
||||||
-march=i686 -pipe -msoft-float -fno-builtin
|
-march=i686 -pipe -msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/i686/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
|
||||||
CFLAGS += -pipe -fno-builtin -fPIC
|
CFLAGS += -pipe -fno-builtin -fPIC
|
||||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
/* EXPERIMENTAL */
|
|
||||||
|
|
||||||
OUTPUT_FORMAT(binary)
|
OUTPUT_FORMAT(binary)
|
||||||
OUTPUT_ARCH(i386:x86-64)
|
OUTPUT_ARCH(i386:x86-64)
|
||||||
|
|
@ -29,6 +29,8 @@ __attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
|||||||
|
|
||||||
KernelAPI *KAPI;
|
KernelAPI *KAPI;
|
||||||
|
|
||||||
|
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
struct BARData
|
struct BARData
|
||||||
@ -87,16 +89,16 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
{
|
{
|
||||||
case AcknowledgeReason:
|
case AcknowledgeReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Kernel acknowledged the driver.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ConfigurationReason:
|
case ConfigurationReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Kernel received configuration data." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Kernel received configuration data.");
|
||||||
PCIBaseAddress = reinterpret_cast<PCIDeviceHeader *>(Data->RawPtr);
|
PCIBaseAddress = reinterpret_cast<PCIDeviceHeader *>(Data->RawPtr);
|
||||||
if (PCIBaseAddress->VendorID == 0x1022 && PCIBaseAddress->DeviceID == 0x2000)
|
if (PCIBaseAddress->VendorID == 0x1022 && PCIBaseAddress->DeviceID == 0x2000)
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Found AMD PCNET." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Found AMD PCNET.");
|
||||||
uint32_t PCIBAR = ((PCIHeader0 *)PCIBaseAddress)->BAR0;
|
uint32_t PCIBAR = ((PCIHeader0 *)PCIBaseAddress)->BAR0;
|
||||||
BAR.Type = PCIBAR & 1;
|
BAR.Type = PCIBAR & 1;
|
||||||
BAR.IOBase = PCIBAR & (~3);
|
BAR.IOBase = PCIBAR & (~3);
|
||||||
@ -112,10 +114,17 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
}
|
}
|
||||||
case SendReason:
|
case SendReason:
|
||||||
{
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case StopReason:
|
||||||
|
{
|
||||||
|
// TODO: Stop the driver.
|
||||||
|
print("Driver stopped.");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Unknown reason.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Config file
|
# Config file
|
||||||
include ../../../Makefile.conf
|
include ../../../Makefile.conf
|
||||||
|
|
||||||
FILENAME = e1000.fex
|
FILENAME = E1000.fex
|
||||||
|
|
||||||
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
||||||
CPP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
CPP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
||||||
@ -29,12 +29,12 @@ HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
|||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
||||||
INCLUDE_DIR = ../../include
|
INCLUDE_DIR = ../../include
|
||||||
|
|
||||||
LDFLAGS := \
|
LDFLAGS := \
|
||||||
-fPIC -fno-pie \
|
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||||
-nostdlib -nodefaultlibs -nolibc \
|
-nostdlib -nodefaultlibs -nolibc \
|
||||||
-zmax-page-size=0x1000 \
|
-zmax-page-size=0x1000 \
|
||||||
-Wl,-Map file.map -shared
|
-Wl,-Map file.map -static -Tlinker.ld
|
||||||
|
|
||||||
WARNCFLAG = -Wall -Wextra
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
@ -45,23 +45,20 @@ CFLAGS := \
|
|||||||
|
|
||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 \
|
-mno-red-zone -mno-sse -mno-sse2 \
|
||||||
-march=x86-64 -pipe -ffunction-sections \
|
-march=x86-64 -pipe -ffunction-sections \
|
||||||
-mcmodel=kernel -msoft-float -fno-builtin
|
-msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/amd64/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), i686)
|
else ifeq ($(OSARCH), i686)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
||||||
-march=i686 -pipe -msoft-float -fno-builtin
|
-march=i686 -pipe -msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/i686/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
|
||||||
CFLAGS += -pipe -fno-builtin -fPIC
|
CFLAGS += -pipe -fno-builtin -fPIC
|
||||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
/* EXPERIMENTAL */
|
|
||||||
|
|
||||||
OUTPUT_FORMAT(binary)
|
|
||||||
OUTPUT_ARCH(i386:x86-64)
|
|
||||||
|
|
||||||
ENTRY(DriverEntry)
|
|
||||||
|
|
||||||
SECTIONS
|
|
||||||
{
|
|
||||||
.header :
|
|
||||||
{
|
|
||||||
*(.header .header.*)
|
|
||||||
*(.extended .extended.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.text :
|
|
||||||
{
|
|
||||||
*(.text .text.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.data :
|
|
||||||
{
|
|
||||||
*(.data .data.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.rodata :
|
|
||||||
{
|
|
||||||
*(.rodata .rodata.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.bss :
|
|
||||||
{
|
|
||||||
*(COMMON)
|
|
||||||
*(.bss .bss.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
/DISCARD/ :
|
|
||||||
{
|
|
||||||
*(.eh_frame)
|
|
||||||
*(.note .note.*)
|
|
||||||
}
|
|
||||||
}
|
|
@ -29,6 +29,8 @@ __attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
|||||||
|
|
||||||
KernelAPI *KAPI;
|
KernelAPI *KAPI;
|
||||||
|
|
||||||
|
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
enum REG
|
enum REG
|
||||||
@ -242,7 +244,7 @@ MediaAccessControl GetMAC()
|
|||||||
mac.Address[i] = BaseMac8[i];
|
mac.Address[i] = BaseMac8[i];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"No MAC address found." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("No MAC address found.");
|
||||||
return MediaAccessControl();
|
return MediaAccessControl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,6 +253,7 @@ MediaAccessControl GetMAC()
|
|||||||
|
|
||||||
void InitializeRX()
|
void InitializeRX()
|
||||||
{
|
{
|
||||||
|
print("Initializing RX...");
|
||||||
uint8_t *Ptr = (uint8_t *)KAPI->Memory.RequestPage((((sizeof(RXDescriptor) * E1000_NUM_RX_DESC + 16)) / KAPI->Memory.PageSize) + 1);
|
uint8_t *Ptr = (uint8_t *)KAPI->Memory.RequestPage((((sizeof(RXDescriptor) * E1000_NUM_RX_DESC + 16)) / KAPI->Memory.PageSize) + 1);
|
||||||
RXDescriptor *Descriptor = (RXDescriptor *)Ptr;
|
RXDescriptor *Descriptor = (RXDescriptor *)Ptr;
|
||||||
|
|
||||||
@ -277,6 +280,7 @@ void InitializeRX()
|
|||||||
|
|
||||||
void InitializeTX()
|
void InitializeTX()
|
||||||
{
|
{
|
||||||
|
print("Initializing TX...");
|
||||||
uint8_t *Ptr = (uint8_t *)KAPI->Memory.RequestPage(((sizeof(TXDescriptor) * E1000_NUM_RX_DESC + 16) / KAPI->Memory.PageSize) + 1);
|
uint8_t *Ptr = (uint8_t *)KAPI->Memory.RequestPage(((sizeof(TXDescriptor) * E1000_NUM_RX_DESC + 16) / KAPI->Memory.PageSize) + 1);
|
||||||
TXDescriptor *Descriptor = (TXDescriptor *)Ptr;
|
TXDescriptor *Descriptor = (TXDescriptor *)Ptr;
|
||||||
|
|
||||||
@ -318,16 +322,16 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
{
|
{
|
||||||
case AcknowledgeReason:
|
case AcknowledgeReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Kernel acknowledged the driver.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ConfigurationReason:
|
case ConfigurationReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Kernel received configuration data." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Kernel received configuration data.");
|
||||||
PCIBaseAddress = reinterpret_cast<PCIDeviceHeader *>(Data->RawPtr);
|
PCIBaseAddress = reinterpret_cast<PCIDeviceHeader *>(Data->RawPtr);
|
||||||
if (PCIBaseAddress->VendorID == 0x8086 && PCIBaseAddress->DeviceID == 0x100E)
|
if (PCIBaseAddress->VendorID == 0x8086 && PCIBaseAddress->DeviceID == 0x100E)
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Found Intel 82540EM Gigabit Ethernet Controller." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Found Intel 82540EM Gigabit Ethernet Controller.");
|
||||||
|
|
||||||
PCIBaseAddress->Command |= PCI_COMMAND_MASTER | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
|
PCIBaseAddress->Command |= PCI_COMMAND_MASTER | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
|
||||||
uint32_t PCIBAR0 = ((PCIHeader0 *)PCIBaseAddress)->BAR0;
|
uint32_t PCIBAR0 = ((PCIHeader0 *)PCIBaseAddress)->BAR0;
|
||||||
@ -349,7 +353,7 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
if (!GetMAC().Valid())
|
if (!GetMAC().Valid())
|
||||||
return NOT_AVAILABLE;
|
return NOT_AVAILABLE;
|
||||||
else
|
else
|
||||||
KAPI->Util.DebugPrint(((char *)"MAC address found." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("MAC address found.");
|
||||||
MAC = GetMAC();
|
MAC = GetMAC();
|
||||||
|
|
||||||
// Start link
|
// Start link
|
||||||
@ -368,12 +372,12 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
}
|
}
|
||||||
else if (PCIBaseAddress->VendorID == 0x8086 && PCIBaseAddress->DeviceID == 0x153A)
|
else if (PCIBaseAddress->VendorID == 0x8086 && PCIBaseAddress->DeviceID == 0x153A)
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Found Intel I217 Gigabit Ethernet Controller." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Found Intel I217 Gigabit Ethernet Controller.");
|
||||||
return NOT_IMPLEMENTED;
|
return NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
else if (PCIBaseAddress->VendorID == 0x8086 && PCIBaseAddress->DeviceID == 0x10EA)
|
else if (PCIBaseAddress->VendorID == 0x8086 && PCIBaseAddress->DeviceID == 0x10EA)
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Found Intel 82577LM Gigabit Ethernet Controller." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Found Intel 82577LM Gigabit Ethernet Controller.");
|
||||||
return NOT_IMPLEMENTED;
|
return NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -411,9 +415,17 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
;
|
;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case StopReason:
|
||||||
|
{
|
||||||
|
// TODO: UNTESTED!!!
|
||||||
|
uint64_t cmdret = InCMD(REG::CTRL);
|
||||||
|
OutCMD(REG::CTRL, cmdret & ~ECTRL::SLU);
|
||||||
|
print("Driver stopped.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Unknown reason.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
40
Network/E1000/linker.ld
Normal file
40
Network/E1000/linker.ld
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
OUTPUT_FORMAT(binary)
|
||||||
|
OUTPUT_ARCH(i386:x86-64)
|
||||||
|
|
||||||
|
ENTRY(DriverEntry)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.header :
|
||||||
|
{
|
||||||
|
*(.header .header.*)
|
||||||
|
*(.extended .extended.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
*(.text .text.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.data :
|
||||||
|
{
|
||||||
|
*(.data .data.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.rodata :
|
||||||
|
{
|
||||||
|
*(.rodata .rodata.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.bss :
|
||||||
|
{
|
||||||
|
*(COMMON)
|
||||||
|
*(.bss .bss.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
/DISCARD/ :
|
||||||
|
{
|
||||||
|
*(.eh_frame)
|
||||||
|
*(.note .note.*)
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
# Config file
|
# Config file
|
||||||
include ../../../Makefile.conf
|
include ../../../Makefile.conf
|
||||||
|
|
||||||
FILENAME = rtl8139.fex
|
FILENAME = Realtek-8139.fex
|
||||||
|
|
||||||
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
||||||
CPP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
CPP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
||||||
@ -29,12 +29,12 @@ HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
|||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
||||||
INCLUDE_DIR = ../../include
|
INCLUDE_DIR = ../../include
|
||||||
|
|
||||||
LDFLAGS := \
|
LDFLAGS := \
|
||||||
-fPIC -fno-pie \
|
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||||
-nostdlib -nodefaultlibs -nolibc \
|
-nostdlib -nodefaultlibs -nolibc \
|
||||||
-zmax-page-size=0x1000 \
|
-zmax-page-size=0x1000 \
|
||||||
-Wl,-Map file.map -shared
|
-Wl,-Map file.map -static -Tlinker.ld
|
||||||
|
|
||||||
WARNCFLAG = -Wall -Wextra
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
@ -45,23 +45,20 @@ CFLAGS := \
|
|||||||
|
|
||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 \
|
-mno-red-zone -mno-sse -mno-sse2 \
|
||||||
-march=x86-64 -pipe -ffunction-sections \
|
-march=x86-64 -pipe -ffunction-sections \
|
||||||
-mcmodel=kernel -msoft-float -fno-builtin
|
-msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/amd64/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), i686)
|
else ifeq ($(OSARCH), i686)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
||||||
-march=i686 -pipe -msoft-float -fno-builtin
|
-march=i686 -pipe -msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/i686/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
|
||||||
CFLAGS += -pipe -fno-builtin -fPIC
|
CFLAGS += -pipe -fno-builtin -fPIC
|
||||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
/* EXPERIMENTAL */
|
|
||||||
|
|
||||||
OUTPUT_FORMAT(binary)
|
|
||||||
OUTPUT_ARCH(i386:x86-64)
|
|
||||||
|
|
||||||
ENTRY(DriverEntry)
|
|
||||||
|
|
||||||
SECTIONS
|
|
||||||
{
|
|
||||||
.header :
|
|
||||||
{
|
|
||||||
*(.header .header.*)
|
|
||||||
*(.extended .extended.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.text :
|
|
||||||
{
|
|
||||||
*(.text .text.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.data :
|
|
||||||
{
|
|
||||||
*(.data .data.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.rodata :
|
|
||||||
{
|
|
||||||
*(.rodata .rodata.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.bss :
|
|
||||||
{
|
|
||||||
*(COMMON)
|
|
||||||
*(.bss .bss.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
/DISCARD/ :
|
|
||||||
{
|
|
||||||
*(.eh_frame)
|
|
||||||
*(.note .note.*)
|
|
||||||
}
|
|
||||||
}
|
|
40
Network/RTL8139/linker.ld
Normal file
40
Network/RTL8139/linker.ld
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
OUTPUT_FORMAT(binary)
|
||||||
|
OUTPUT_ARCH(i386:x86-64)
|
||||||
|
|
||||||
|
ENTRY(DriverEntry)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.header :
|
||||||
|
{
|
||||||
|
*(.header .header.*)
|
||||||
|
*(.extended .extended.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
*(.text .text.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.data :
|
||||||
|
{
|
||||||
|
*(.data .data.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.rodata :
|
||||||
|
{
|
||||||
|
*(.rodata .rodata.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.bss :
|
||||||
|
{
|
||||||
|
*(COMMON)
|
||||||
|
*(.bss .bss.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
/DISCARD/ :
|
||||||
|
{
|
||||||
|
*(.eh_frame)
|
||||||
|
*(.note .note.*)
|
||||||
|
}
|
||||||
|
}
|
@ -29,6 +29,8 @@ __attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
|||||||
|
|
||||||
KernelAPI *KAPI;
|
KernelAPI *KAPI;
|
||||||
|
|
||||||
|
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
struct BARData
|
struct BARData
|
||||||
@ -129,16 +131,16 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
{
|
{
|
||||||
case AcknowledgeReason:
|
case AcknowledgeReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Kernel acknowledged the driver.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ConfigurationReason:
|
case ConfigurationReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Kernel received configuration data." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Kernel received configuration data.");
|
||||||
PCIBaseAddress = reinterpret_cast<PCIDeviceHeader *>(Data->RawPtr);
|
PCIBaseAddress = reinterpret_cast<PCIDeviceHeader *>(Data->RawPtr);
|
||||||
if (PCIBaseAddress->VendorID == 0x10EC && PCIBaseAddress->DeviceID == 0x8139)
|
if (PCIBaseAddress->VendorID == 0x10EC && PCIBaseAddress->DeviceID == 0x8139)
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Found RTL-8139." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Found RTL-8139.");
|
||||||
|
|
||||||
PCIBaseAddress->Command |= PCI_COMMAND_MASTER | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
|
PCIBaseAddress->Command |= PCI_COMMAND_MASTER | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
|
||||||
uint32_t PCIBAR0 = ((PCIHeader0 *)PCIBaseAddress)->BAR0;
|
uint32_t PCIBAR0 = ((PCIHeader0 *)PCIBaseAddress)->BAR0;
|
||||||
@ -190,9 +192,15 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
TXCurrent = 0;
|
TXCurrent = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case StopReason:
|
||||||
|
{
|
||||||
|
// TODO: Stop the driver.
|
||||||
|
print("Driver stopped.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Unknown reason.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Config file
|
# Config file
|
||||||
include ../../../Makefile.conf
|
include ../../../Makefile.conf
|
||||||
|
|
||||||
FILENAME = rtl8169.fex
|
FILENAME = Realtek-8169.fex
|
||||||
|
|
||||||
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
||||||
CPP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
CPP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
||||||
@ -29,12 +29,12 @@ HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
|||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
||||||
INCLUDE_DIR = ../../include
|
INCLUDE_DIR = ../../include
|
||||||
|
|
||||||
LDFLAGS := \
|
LDFLAGS := \
|
||||||
-fPIC -fno-pie \
|
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||||
-nostdlib -nodefaultlibs -nolibc \
|
-nostdlib -nodefaultlibs -nolibc \
|
||||||
-zmax-page-size=0x1000 \
|
-zmax-page-size=0x1000 \
|
||||||
-Wl,-Map file.map -shared
|
-Wl,-Map file.map -static -Tlinker.ld
|
||||||
|
|
||||||
WARNCFLAG = -Wall -Wextra
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
@ -45,23 +45,20 @@ CFLAGS := \
|
|||||||
|
|
||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 \
|
-mno-red-zone -mno-sse -mno-sse2 \
|
||||||
-march=x86-64 -pipe -ffunction-sections \
|
-march=x86-64 -pipe -ffunction-sections \
|
||||||
-mcmodel=kernel -msoft-float -fno-builtin
|
-msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/amd64/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), i686)
|
else ifeq ($(OSARCH), i686)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
||||||
-march=i686 -pipe -msoft-float -fno-builtin
|
-march=i686 -pipe -msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/i686/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
|
||||||
CFLAGS += -pipe -fno-builtin -fPIC
|
CFLAGS += -pipe -fno-builtin -fPIC
|
||||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
/* EXPERIMENTAL */
|
|
||||||
|
|
||||||
OUTPUT_FORMAT(binary)
|
|
||||||
OUTPUT_ARCH(i386:x86-64)
|
|
||||||
|
|
||||||
ENTRY(DriverEntry)
|
|
||||||
|
|
||||||
SECTIONS
|
|
||||||
{
|
|
||||||
.header :
|
|
||||||
{
|
|
||||||
*(.header .header.*)
|
|
||||||
*(.extended .extended.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.text :
|
|
||||||
{
|
|
||||||
*(.text .text.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.data :
|
|
||||||
{
|
|
||||||
*(.data .data.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.rodata :
|
|
||||||
{
|
|
||||||
*(.rodata .rodata.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.bss :
|
|
||||||
{
|
|
||||||
*(COMMON)
|
|
||||||
*(.bss .bss.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
/DISCARD/ :
|
|
||||||
{
|
|
||||||
*(.eh_frame)
|
|
||||||
*(.note .note.*)
|
|
||||||
}
|
|
||||||
}
|
|
40
Network/RTL8169/linker.ld
Normal file
40
Network/RTL8169/linker.ld
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
OUTPUT_FORMAT(binary)
|
||||||
|
OUTPUT_ARCH(i386:x86-64)
|
||||||
|
|
||||||
|
ENTRY(DriverEntry)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.header :
|
||||||
|
{
|
||||||
|
*(.header .header.*)
|
||||||
|
*(.extended .extended.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
*(.text .text.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.data :
|
||||||
|
{
|
||||||
|
*(.data .data.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.rodata :
|
||||||
|
{
|
||||||
|
*(.rodata .rodata.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.bss :
|
||||||
|
{
|
||||||
|
*(COMMON)
|
||||||
|
*(.bss .bss.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
/DISCARD/ :
|
||||||
|
{
|
||||||
|
*(.eh_frame)
|
||||||
|
*(.note .note.*)
|
||||||
|
}
|
||||||
|
}
|
@ -29,6 +29,8 @@ __attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
|||||||
|
|
||||||
KernelAPI *KAPI;
|
KernelAPI *KAPI;
|
||||||
|
|
||||||
|
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
struct BARData
|
struct BARData
|
||||||
@ -60,16 +62,16 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
{
|
{
|
||||||
case AcknowledgeReason:
|
case AcknowledgeReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Kernel acknowledged the driver.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ConfigurationReason:
|
case ConfigurationReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Kernel received configuration data." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Kernel received configuration data.");
|
||||||
PCIBaseAddress = reinterpret_cast<PCIDeviceHeader *>(Data->RawPtr);
|
PCIBaseAddress = reinterpret_cast<PCIDeviceHeader *>(Data->RawPtr);
|
||||||
if (PCIBaseAddress->VendorID == 0x10EC && PCIBaseAddress->DeviceID == 0x8169)
|
if (PCIBaseAddress->VendorID == 0x10EC && PCIBaseAddress->DeviceID == 0x8169)
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Found RTL-8169." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Found RTL-8169.");
|
||||||
return NOT_IMPLEMENTED;
|
return NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -84,9 +86,15 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case StopReason:
|
||||||
|
{
|
||||||
|
// TODO: Stop the driver.
|
||||||
|
print("Driver stopped.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Unknown reason.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Config file
|
# Config file
|
||||||
include ../../../Makefile.conf
|
include ../../../Makefile.conf
|
||||||
|
|
||||||
FILENAME = virtio_net.fex
|
FILENAME = VirtioNetworkDriver.fex
|
||||||
|
|
||||||
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
||||||
CPP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
CPP = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
||||||
@ -29,12 +29,12 @@ HEADERS = $(sort $(dir $(wildcard ../../include/*)))
|
|||||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
||||||
INCLUDE_DIR = ../../include
|
INCLUDE_DIR = ../../include
|
||||||
|
|
||||||
LDFLAGS := \
|
LDFLAGS := \
|
||||||
-fPIC -fno-pie \
|
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||||
-nostdlib -nodefaultlibs -nolibc \
|
-nostdlib -nodefaultlibs -nolibc \
|
||||||
-zmax-page-size=0x1000 \
|
-zmax-page-size=0x1000 \
|
||||||
-Wl,-Map file.map -shared
|
-Wl,-Map file.map -static -Tlinker.ld
|
||||||
|
|
||||||
WARNCFLAG = -Wall -Wextra
|
WARNCFLAG = -Wall -Wextra
|
||||||
|
|
||||||
@ -45,23 +45,20 @@ CFLAGS := \
|
|||||||
|
|
||||||
ifeq ($(OSARCH), amd64)
|
ifeq ($(OSARCH), amd64)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 \
|
-mno-red-zone -mno-sse -mno-sse2 \
|
||||||
-march=x86-64 -pipe -ffunction-sections \
|
-march=x86-64 -pipe -ffunction-sections \
|
||||||
-mcmodel=kernel -msoft-float -fno-builtin
|
-msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/amd64/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), i686)
|
else ifeq ($(OSARCH), i686)
|
||||||
|
|
||||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||||
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
||||||
-march=i686 -pipe -msoft-float -fno-builtin
|
-march=i686 -pipe -msoft-float -fno-builtin
|
||||||
LDFLAGS += -Tarch/i686/linker.ld
|
|
||||||
|
|
||||||
else ifeq ($(OSARCH), aarch64)
|
else ifeq ($(OSARCH), aarch64)
|
||||||
|
|
||||||
CFLAGS += -pipe -fno-builtin -fPIC
|
CFLAGS += -pipe -fno-builtin -fPIC
|
||||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ __attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
|||||||
|
|
||||||
KernelAPI *KAPI;
|
KernelAPI *KAPI;
|
||||||
|
|
||||||
|
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
struct BARData
|
struct BARData
|
||||||
@ -60,16 +62,16 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
{
|
{
|
||||||
case AcknowledgeReason:
|
case AcknowledgeReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Kernel acknowledged the driver.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ConfigurationReason:
|
case ConfigurationReason:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Kernel received configuration data." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Kernel received configuration data.");
|
||||||
PCIBaseAddress = reinterpret_cast<PCIDeviceHeader *>(Data->RawPtr);
|
PCIBaseAddress = reinterpret_cast<PCIDeviceHeader *>(Data->RawPtr);
|
||||||
if (PCIBaseAddress->VendorID == 0x1AF4 && PCIBaseAddress->DeviceID == 0x1000)
|
if (PCIBaseAddress->VendorID == 0x1AF4 && PCIBaseAddress->DeviceID == 0x1000)
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Found Virtio Network." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Found Virtio Network.");
|
||||||
return NOT_IMPLEMENTED;
|
return NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -84,9 +86,15 @@ int CallbackHandler(KernelCallback *Data)
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case StopReason:
|
||||||
|
{
|
||||||
|
// TODO: Stop the driver.
|
||||||
|
print("Driver stopped.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
print("Unknown reason.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
/* EXPERIMENTAL */
|
|
||||||
|
|
||||||
OUTPUT_FORMAT(binary)
|
|
||||||
OUTPUT_ARCH(i386:x86-64)
|
|
||||||
|
|
||||||
ENTRY(DriverEntry)
|
|
||||||
|
|
||||||
SECTIONS
|
|
||||||
{
|
|
||||||
.header :
|
|
||||||
{
|
|
||||||
*(.header .header.*)
|
|
||||||
*(.extended .extended.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.text :
|
|
||||||
{
|
|
||||||
*(.text .text.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.data :
|
|
||||||
{
|
|
||||||
*(.data .data.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.rodata :
|
|
||||||
{
|
|
||||||
*(.rodata .rodata.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
.bss :
|
|
||||||
{
|
|
||||||
*(COMMON)
|
|
||||||
*(.bss .bss.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
/DISCARD/ :
|
|
||||||
{
|
|
||||||
*(.eh_frame)
|
|
||||||
*(.note .note.*)
|
|
||||||
}
|
|
||||||
}
|
|
40
Network/Virtio/linker.ld
Normal file
40
Network/Virtio/linker.ld
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
OUTPUT_FORMAT(binary)
|
||||||
|
OUTPUT_ARCH(i386:x86-64)
|
||||||
|
|
||||||
|
ENTRY(DriverEntry)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.header :
|
||||||
|
{
|
||||||
|
*(.header .header.*)
|
||||||
|
*(.extended .extended.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
*(.text .text.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.data :
|
||||||
|
{
|
||||||
|
*(.data .data.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.rodata :
|
||||||
|
{
|
||||||
|
*(.rodata .rodata.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.bss :
|
||||||
|
{
|
||||||
|
*(COMMON)
|
||||||
|
*(.bss .bss.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
/DISCARD/ :
|
||||||
|
{
|
||||||
|
*(.eh_frame)
|
||||||
|
*(.note .note.*)
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user