mirror of
https://github.com/Fennix-Project/Drivers.git
synced 2025-05-25 22:14:31 +00:00
Update drivers
This commit is contained in:
parent
0091fe5965
commit
4d4c2aeba6
@ -29,6 +29,8 @@ __attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
||||
|
||||
KernelAPI *KAPI;
|
||||
|
||||
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------------------- */
|
||||
|
||||
#define ATA_DEV_BUSY 0x80
|
||||
@ -190,9 +192,11 @@ typedef enum
|
||||
_URC_CONTINUE_UNWIND = 8
|
||||
} _Unwind_Reason_Code;
|
||||
|
||||
struct _Unwind_Context;
|
||||
typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__)));
|
||||
typedef unsigned _Unwind_Word __attribute__((__mode__(__unwind_word__)));
|
||||
typedef void (*_Unwind_Exception_Cleanup_Fn)(_Unwind_Reason_Code, struct _Unwind_Exception *);
|
||||
typedef int _Unwind_Action;
|
||||
|
||||
struct _Unwind_Exception
|
||||
{
|
||||
@ -206,7 +210,13 @@ struct _Unwind_Exception
|
||||
#endif
|
||||
} __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 delete(void *Ptr) { KAPI->Memory.FreePage(Ptr, 1); } // Potential memory leak
|
||||
@ -284,7 +294,7 @@ public:
|
||||
if (this->PortNumber == PortType::SATAPI && 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;
|
||||
}
|
||||
|
||||
@ -336,7 +346,7 @@ public:
|
||||
if (Spin == 1000000)
|
||||
{
|
||||
// err("Port not responding.");
|
||||
KAPI->Util.DebugPrint(((char *)"Port not responding." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Port not responding.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -350,7 +360,7 @@ public:
|
||||
if (Spin > 100000000)
|
||||
{
|
||||
// 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;
|
||||
TryCount++;
|
||||
if (TryCount > 10)
|
||||
@ -362,7 +372,7 @@ public:
|
||||
if (HBAPortPtr->InterruptStatus & HBA_PxIS_TFES)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
@ -425,12 +435,12 @@ int CallbackHandler(KernelCallback *Data)
|
||||
{
|
||||
case AcknowledgeReason:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Kernel acknowledged the driver.");
|
||||
break;
|
||||
}
|
||||
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);
|
||||
ABAR = reinterpret_cast<HBAMemory *>(((PCIHeader0 *)PCIBaseAddress)->BAR5);
|
||||
KAPI->Memory.Map((void *)ABAR, (void *)ABAR, (1 << 1));
|
||||
@ -444,14 +454,14 @@ int CallbackHandler(KernelCallback *Data)
|
||||
if (portType == PortType::SATA || portType == PortType::SATAPI)
|
||||
{
|
||||
// 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);
|
||||
PortCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -467,6 +477,12 @@ int CallbackHandler(KernelCallback *Data)
|
||||
Data->DiskCallback.Fetch.BytesPerSector = 512;
|
||||
break;
|
||||
}
|
||||
case StopReason:
|
||||
{
|
||||
// TODO: Stop the driver.
|
||||
print("Driver stopped.");
|
||||
break;
|
||||
}
|
||||
case SendReason:
|
||||
case ReceiveReason:
|
||||
{
|
||||
@ -478,7 +494,7 @@ int CallbackHandler(KernelCallback *Data)
|
||||
}
|
||||
default:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Unknown reason.");
|
||||
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)
|
||||
INCLUDE_DIR = ../../include
|
||||
|
||||
LDFLAGS := \
|
||||
-fPIC -fno-pie \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -shared
|
||||
LDFLAGS := \
|
||||
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -static -Tlinker.ld
|
||||
|
||||
WARNCFLAG = -Wall -Wextra
|
||||
|
||||
@ -45,23 +45,20 @@ CFLAGS := \
|
||||
|
||||
ifeq ($(OSARCH), amd64)
|
||||
|
||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-mcmodel=kernel -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/amd64/linker.ld
|
||||
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-msoft-float -fno-builtin
|
||||
|
||||
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 \
|
||||
-march=i686 -pipe -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/i686/linker.ld
|
||||
|
||||
else ifeq ($(OSARCH), aarch64)
|
||||
|
||||
CFLAGS += -pipe -fno-builtin -fPIC
|
||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
||||
|
||||
endif
|
||||
|
||||
|
@ -25,6 +25,8 @@ __attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
||||
|
||||
KernelAPI *KAPI;
|
||||
|
||||
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------------------- */
|
||||
|
||||
int DriverEntry(void *Data)
|
||||
@ -43,12 +45,12 @@ int CallbackHandler(KernelCallback *Data)
|
||||
{
|
||||
case AcknowledgeReason:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Kernel acknowledged the driver.");
|
||||
break;
|
||||
}
|
||||
case ConfigurationReason:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Kernel received configuration data." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Kernel received configuration data.");
|
||||
break;
|
||||
}
|
||||
case FetchReason:
|
||||
@ -59,11 +61,11 @@ int CallbackHandler(KernelCallback *Data)
|
||||
{
|
||||
if (Data->InterruptInfo.Vector == 0xE)
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"IRQ14" + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("IRQ14");
|
||||
}
|
||||
else if (Data->InterruptInfo.Vector == 0xF)
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"IRQ15" + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("IRQ15");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -72,9 +74,15 @@ int CallbackHandler(KernelCallback *Data)
|
||||
{
|
||||
break;
|
||||
}
|
||||
case StopReason:
|
||||
{
|
||||
// TODO: Stop the driver.
|
||||
print("Driver stopped.");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Unknown reason.");
|
||||
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)
|
||||
INCLUDE_DIR = ../../include
|
||||
|
||||
LDFLAGS := \
|
||||
-fPIC -fno-pie \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -shared
|
||||
LDFLAGS := \
|
||||
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -static -Tlinker.ld
|
||||
|
||||
WARNCFLAG = -Wall -Wextra
|
||||
|
||||
@ -45,23 +45,20 @@ CFLAGS := \
|
||||
|
||||
ifeq ($(OSARCH), amd64)
|
||||
|
||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-mcmodel=kernel -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/amd64/linker.ld
|
||||
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-msoft-float -fno-builtin
|
||||
|
||||
else ifeq ($(OSARCH), i686)
|
||||
|
||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
||||
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 -ffunction-sections \
|
||||
-march=i686 -pipe -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/i686/linker.ld
|
||||
|
||||
else ifeq ($(OSARCH), aarch64)
|
||||
|
||||
CFLAGS += -pipe -fno-builtin -fPIC
|
||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
||||
|
||||
endif
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* EXPERIMENTAL */
|
||||
|
||||
OUTPUT_FORMAT(binary)
|
||||
OUTPUT_ARCH(i386:x86-64)
|
||||
|
@ -27,6 +27,9 @@ __attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
||||
// Global variable that holds the kernel API
|
||||
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.
|
||||
@ -44,7 +47,7 @@ int DriverEntry(void *Data)
|
||||
return KERNEL_API_VERSION_NOT_SUPPORTED;
|
||||
|
||||
// We print "Hello World!" to UART.
|
||||
KAPI->Util.DebugPrint(((char *)"Hello World!" + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Hello World!");
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -55,17 +58,22 @@ int CallbackHandler(KernelCallback *Data)
|
||||
{
|
||||
case AcknowledgeReason:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Kernel acknowledged the driver.");
|
||||
break;
|
||||
}
|
||||
case InterruptReason:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Interrupt received." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Interrupt received.");
|
||||
break;
|
||||
}
|
||||
case StopReason:
|
||||
{
|
||||
print("Driver stopped.");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Unknown reason.");
|
||||
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)
|
||||
INCLUDE_DIR = ../../include
|
||||
|
||||
LDFLAGS := \
|
||||
-fPIC -fno-pie \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -shared
|
||||
LDFLAGS := \
|
||||
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -static -Tlinker.ld
|
||||
|
||||
WARNCFLAG = -Wall -Wextra
|
||||
|
||||
@ -45,23 +45,20 @@ CFLAGS := \
|
||||
|
||||
ifeq ($(OSARCH), amd64)
|
||||
|
||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-mcmodel=kernel -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/amd64/linker.ld
|
||||
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-msoft-float -fno-builtin
|
||||
|
||||
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 \
|
||||
-march=i686 -pipe -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/i686/linker.ld
|
||||
|
||||
else ifeq ($(OSARCH), aarch64)
|
||||
|
||||
CFLAGS += -pipe -fno-builtin -fPIC
|
||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
||||
|
||||
endif
|
||||
|
||||
@ -88,13 +85,7 @@ $(FILENAME): $(OBJ)
|
||||
|
||||
%.o: %.S
|
||||
$(info Compiling $<)
|
||||
ifeq ($(OSARCH), amd64)
|
||||
$(AS) -o $@ $<
|
||||
else ifeq ($(OSARCH), i686)
|
||||
$(AS) -o $@ $<
|
||||
else ifeq ($(OSARCH), aarch64)
|
||||
$(AS) -o $@ $<
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -f *.o file.map file_dump.map $(OBJ)
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* EXPERIMENTAL */
|
||||
|
||||
OUTPUT_FORMAT(binary)
|
||||
OUTPUT_ARCH(i386:x86-64)
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Config file
|
||||
include ../../../Makefile.conf
|
||||
|
||||
FILENAME = VMwareGuestDriver.fex
|
||||
FILENAME = VMwareMouseDriver.fex
|
||||
|
||||
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
||||
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)
|
||||
INCLUDE_DIR = ../../include
|
||||
|
||||
LDFLAGS := \
|
||||
-fPIC -fno-pie \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -shared
|
||||
LDFLAGS := \
|
||||
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -static -Tlinker.ld
|
||||
|
||||
WARNCFLAG = -Wall -Wextra
|
||||
|
||||
@ -45,23 +45,20 @@ CFLAGS := \
|
||||
|
||||
ifeq ($(OSARCH), amd64)
|
||||
|
||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-mcmodel=kernel -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/amd64/linker.ld
|
||||
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-msoft-float -fno-builtin
|
||||
|
||||
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 \
|
||||
-march=i686 -pipe -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/i686/linker.ld
|
||||
|
||||
else ifeq ($(OSARCH), aarch64)
|
||||
|
||||
CFLAGS += -pipe -fno-builtin -fPIC
|
||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
||||
|
||||
endif
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* EXPERIMENTAL */
|
||||
|
||||
OUTPUT_FORMAT(binary)
|
||||
OUTPUT_ARCH(i386:x86-64)
|
||||
|
@ -24,6 +24,8 @@ __attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
||||
|
||||
KernelAPI *KAPI;
|
||||
|
||||
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* https://wiki.osdev.org/VMware_tools */
|
||||
@ -189,7 +191,7 @@ int CallbackHandler(KernelCallback *Data)
|
||||
{
|
||||
case AcknowledgeReason:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Kernel acknowledged the driver.");
|
||||
break;
|
||||
}
|
||||
case ConfigurationReason:
|
||||
@ -207,7 +209,33 @@ int CallbackHandler(KernelCallback *Data)
|
||||
Write(DATA, 0xF4);
|
||||
Read();
|
||||
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;
|
||||
}
|
||||
case InterruptReason:
|
||||
@ -221,7 +249,7 @@ int CallbackHandler(KernelCallback *Data)
|
||||
|
||||
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();
|
||||
Absolute();
|
||||
return ERROR;
|
||||
@ -235,25 +263,16 @@ int CallbackHandler(KernelCallback *Data)
|
||||
|
||||
int flags = (cmd.ax & 0xFFFF0000) >> 16; /* Not important */
|
||||
(void)flags;
|
||||
MouseButton = (cmd.ax & 0xFFFF); /* 0x10 = Right, 0x20 = Left, 0x08 = Middle */
|
||||
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. */
|
||||
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;
|
||||
MouseButton = (cmd.ax & 0xFFFF); /* 0x10 = Right, 0x20 = Left, 0x08 = Middle */
|
||||
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. */
|
||||
MouseZ = (int8_t)cmd.dx; /* Z is a single signed byte indicating scroll direction. */
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Unknown reason.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Config file
|
||||
include ../../../Makefile.conf
|
||||
|
||||
FILENAME = amd_pcnet.fex
|
||||
FILENAME = AMD-PCNET.fex
|
||||
|
||||
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
||||
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)
|
||||
INCLUDE_DIR = ../../include
|
||||
|
||||
LDFLAGS := \
|
||||
-fPIC -fno-pie \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -shared
|
||||
LDFLAGS := \
|
||||
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -static -Tlinker.ld
|
||||
|
||||
WARNCFLAG = -Wall -Wextra
|
||||
|
||||
@ -45,23 +45,20 @@ CFLAGS := \
|
||||
|
||||
ifeq ($(OSARCH), amd64)
|
||||
|
||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-mcmodel=kernel -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/amd64/linker.ld
|
||||
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-msoft-float -fno-builtin
|
||||
|
||||
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 \
|
||||
-march=i686 -pipe -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/i686/linker.ld
|
||||
|
||||
else ifeq ($(OSARCH), aarch64)
|
||||
|
||||
CFLAGS += -pipe -fno-builtin -fPIC
|
||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
||||
|
||||
endif
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* EXPERIMENTAL */
|
||||
|
||||
OUTPUT_FORMAT(binary)
|
||||
OUTPUT_ARCH(i386:x86-64)
|
||||
|
@ -29,6 +29,8 @@ __attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
||||
|
||||
KernelAPI *KAPI;
|
||||
|
||||
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------------------- */
|
||||
|
||||
struct BARData
|
||||
@ -87,16 +89,16 @@ int CallbackHandler(KernelCallback *Data)
|
||||
{
|
||||
case AcknowledgeReason:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Kernel acknowledged the driver.");
|
||||
break;
|
||||
}
|
||||
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);
|
||||
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;
|
||||
BAR.Type = PCIBAR & 1;
|
||||
BAR.IOBase = PCIBAR & (~3);
|
||||
@ -112,10 +114,17 @@ int CallbackHandler(KernelCallback *Data)
|
||||
}
|
||||
case SendReason:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case StopReason:
|
||||
{
|
||||
// TODO: Stop the driver.
|
||||
print("Driver stopped.");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Unknown reason.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Config file
|
||||
include ../../../Makefile.conf
|
||||
|
||||
FILENAME = e1000.fex
|
||||
FILENAME = E1000.fex
|
||||
|
||||
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
||||
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)
|
||||
INCLUDE_DIR = ../../include
|
||||
|
||||
LDFLAGS := \
|
||||
-fPIC -fno-pie \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -shared
|
||||
LDFLAGS := \
|
||||
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -static -Tlinker.ld
|
||||
|
||||
WARNCFLAG = -Wall -Wextra
|
||||
|
||||
@ -45,23 +45,20 @@ CFLAGS := \
|
||||
|
||||
ifeq ($(OSARCH), amd64)
|
||||
|
||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-mcmodel=kernel -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/amd64/linker.ld
|
||||
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-msoft-float -fno-builtin
|
||||
|
||||
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 \
|
||||
-march=i686 -pipe -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/i686/linker.ld
|
||||
|
||||
else ifeq ($(OSARCH), aarch64)
|
||||
|
||||
CFLAGS += -pipe -fno-builtin -fPIC
|
||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
||||
|
||||
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;
|
||||
|
||||
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------------------- */
|
||||
|
||||
enum REG
|
||||
@ -242,7 +244,7 @@ MediaAccessControl GetMAC()
|
||||
mac.Address[i] = BaseMac8[i];
|
||||
else
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"No MAC address found." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("No MAC address found.");
|
||||
return MediaAccessControl();
|
||||
}
|
||||
}
|
||||
@ -251,6 +253,7 @@ MediaAccessControl GetMAC()
|
||||
|
||||
void InitializeRX()
|
||||
{
|
||||
print("Initializing RX...");
|
||||
uint8_t *Ptr = (uint8_t *)KAPI->Memory.RequestPage((((sizeof(RXDescriptor) * E1000_NUM_RX_DESC + 16)) / KAPI->Memory.PageSize) + 1);
|
||||
RXDescriptor *Descriptor = (RXDescriptor *)Ptr;
|
||||
|
||||
@ -277,6 +280,7 @@ void InitializeRX()
|
||||
|
||||
void InitializeTX()
|
||||
{
|
||||
print("Initializing TX...");
|
||||
uint8_t *Ptr = (uint8_t *)KAPI->Memory.RequestPage(((sizeof(TXDescriptor) * E1000_NUM_RX_DESC + 16) / KAPI->Memory.PageSize) + 1);
|
||||
TXDescriptor *Descriptor = (TXDescriptor *)Ptr;
|
||||
|
||||
@ -318,16 +322,16 @@ int CallbackHandler(KernelCallback *Data)
|
||||
{
|
||||
case AcknowledgeReason:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Kernel acknowledged the driver.");
|
||||
break;
|
||||
}
|
||||
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);
|
||||
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;
|
||||
uint32_t PCIBAR0 = ((PCIHeader0 *)PCIBaseAddress)->BAR0;
|
||||
@ -349,7 +353,7 @@ int CallbackHandler(KernelCallback *Data)
|
||||
if (!GetMAC().Valid())
|
||||
return NOT_AVAILABLE;
|
||||
else
|
||||
KAPI->Util.DebugPrint(((char *)"MAC address found." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("MAC address found.");
|
||||
MAC = GetMAC();
|
||||
|
||||
// Start link
|
||||
@ -368,12 +372,12 @@ int CallbackHandler(KernelCallback *Data)
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
else
|
||||
@ -411,9 +415,17 @@ int CallbackHandler(KernelCallback *Data)
|
||||
;
|
||||
break;
|
||||
}
|
||||
case StopReason:
|
||||
{
|
||||
// TODO: UNTESTED!!!
|
||||
uint64_t cmdret = InCMD(REG::CTRL);
|
||||
OutCMD(REG::CTRL, cmdret & ~ECTRL::SLU);
|
||||
print("Driver stopped.");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Unknown reason.");
|
||||
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
|
||||
include ../../../Makefile.conf
|
||||
|
||||
FILENAME = rtl8139.fex
|
||||
FILENAME = Realtek-8139.fex
|
||||
|
||||
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
||||
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)
|
||||
INCLUDE_DIR = ../../include
|
||||
|
||||
LDFLAGS := \
|
||||
-fPIC -fno-pie \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -shared
|
||||
LDFLAGS := \
|
||||
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -static -Tlinker.ld
|
||||
|
||||
WARNCFLAG = -Wall -Wextra
|
||||
|
||||
@ -45,23 +45,20 @@ CFLAGS := \
|
||||
|
||||
ifeq ($(OSARCH), amd64)
|
||||
|
||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-mcmodel=kernel -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/amd64/linker.ld
|
||||
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-msoft-float -fno-builtin
|
||||
|
||||
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 \
|
||||
-march=i686 -pipe -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/i686/linker.ld
|
||||
|
||||
else ifeq ($(OSARCH), aarch64)
|
||||
|
||||
CFLAGS += -pipe -fno-builtin -fPIC
|
||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
||||
|
||||
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;
|
||||
|
||||
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------------------- */
|
||||
|
||||
struct BARData
|
||||
@ -129,16 +131,16 @@ int CallbackHandler(KernelCallback *Data)
|
||||
{
|
||||
case AcknowledgeReason:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Kernel acknowledged the driver.");
|
||||
break;
|
||||
}
|
||||
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);
|
||||
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;
|
||||
uint32_t PCIBAR0 = ((PCIHeader0 *)PCIBaseAddress)->BAR0;
|
||||
@ -190,9 +192,15 @@ int CallbackHandler(KernelCallback *Data)
|
||||
TXCurrent = 0;
|
||||
break;
|
||||
}
|
||||
case StopReason:
|
||||
{
|
||||
// TODO: Stop the driver.
|
||||
print("Driver stopped.");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Unknown reason.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Config file
|
||||
include ../../../Makefile.conf
|
||||
|
||||
FILENAME = rtl8169.fex
|
||||
FILENAME = Realtek-8169.fex
|
||||
|
||||
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
||||
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)
|
||||
INCLUDE_DIR = ../../include
|
||||
|
||||
LDFLAGS := \
|
||||
-fPIC -fno-pie \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -shared
|
||||
LDFLAGS := \
|
||||
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -static -Tlinker.ld
|
||||
|
||||
WARNCFLAG = -Wall -Wextra
|
||||
|
||||
@ -45,23 +45,20 @@ CFLAGS := \
|
||||
|
||||
ifeq ($(OSARCH), amd64)
|
||||
|
||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-mcmodel=kernel -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/amd64/linker.ld
|
||||
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-msoft-float -fno-builtin
|
||||
|
||||
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 \
|
||||
-march=i686 -pipe -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/i686/linker.ld
|
||||
|
||||
else ifeq ($(OSARCH), aarch64)
|
||||
|
||||
CFLAGS += -pipe -fno-builtin -fPIC
|
||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
||||
|
||||
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;
|
||||
|
||||
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------------------- */
|
||||
|
||||
struct BARData
|
||||
@ -60,16 +62,16 @@ int CallbackHandler(KernelCallback *Data)
|
||||
{
|
||||
case AcknowledgeReason:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Kernel acknowledged the driver.");
|
||||
break;
|
||||
}
|
||||
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);
|
||||
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;
|
||||
}
|
||||
else
|
||||
@ -84,9 +86,15 @@ int CallbackHandler(KernelCallback *Data)
|
||||
{
|
||||
break;
|
||||
}
|
||||
case StopReason:
|
||||
{
|
||||
// TODO: Stop the driver.
|
||||
print("Driver stopped.");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Unknown reason.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Config file
|
||||
include ../../../Makefile.conf
|
||||
|
||||
FILENAME = virtio_net.fex
|
||||
FILENAME = VirtioNetworkDriver.fex
|
||||
|
||||
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
||||
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)
|
||||
INCLUDE_DIR = ../../include
|
||||
|
||||
LDFLAGS := \
|
||||
-fPIC -fno-pie \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -shared
|
||||
LDFLAGS := \
|
||||
-fPIC -fPIE -pie -Wl,-eDriverEntry \
|
||||
-Wl,-static,--no-dynamic-linker,-ztext,--no-warn-rwx-segment \
|
||||
-nostdlib -nodefaultlibs -nolibc \
|
||||
-zmax-page-size=0x1000 \
|
||||
-Wl,-Map file.map -static -Tlinker.ld
|
||||
|
||||
WARNCFLAG = -Wall -Wextra
|
||||
|
||||
@ -45,23 +45,20 @@ CFLAGS := \
|
||||
|
||||
ifeq ($(OSARCH), amd64)
|
||||
|
||||
CFLAGS += -fPIC -fno-pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-mcmodel=kernel -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/amd64/linker.ld
|
||||
CFLAGS += -fPIC -fPIE -pie -mno-80387 -mno-mmx -mno-3dnow \
|
||||
-mno-red-zone -mno-sse -mno-sse2 \
|
||||
-march=x86-64 -pipe -ffunction-sections \
|
||||
-msoft-float -fno-builtin
|
||||
|
||||
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 \
|
||||
-march=i686 -pipe -msoft-float -fno-builtin
|
||||
LDFLAGS += -Tarch/i686/linker.ld
|
||||
|
||||
else ifeq ($(OSARCH), aarch64)
|
||||
|
||||
CFLAGS += -pipe -fno-builtin -fPIC
|
||||
LDFLAGS += -Tarch/aarch64/linker.ld
|
||||
|
||||
endif
|
||||
|
||||
|
@ -29,6 +29,8 @@ __attribute__((section(".extended"))) FexExtended ExtendedHeader = {
|
||||
|
||||
KernelAPI *KAPI;
|
||||
|
||||
#define print(msg) KAPI->Util.DebugPrint((char *)(msg), KAPI->Info.DriverUID)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------------------- */
|
||||
|
||||
struct BARData
|
||||
@ -60,16 +62,16 @@ int CallbackHandler(KernelCallback *Data)
|
||||
{
|
||||
case AcknowledgeReason:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Kernel acknowledged the driver." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Kernel acknowledged the driver.");
|
||||
break;
|
||||
}
|
||||
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);
|
||||
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;
|
||||
}
|
||||
else
|
||||
@ -84,9 +86,15 @@ int CallbackHandler(KernelCallback *Data)
|
||||
{
|
||||
break;
|
||||
}
|
||||
case StopReason:
|
||||
{
|
||||
// TODO: Stop the driver.
|
||||
print("Driver stopped.");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
KAPI->Util.DebugPrint(((char *)"Unknown reason." + KAPI->Info.Offset), KAPI->Info.DriverUID);
|
||||
print("Unknown reason.");
|
||||
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