mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-25 22:14:37 +00:00
294 lines
6.6 KiB
C
294 lines
6.6 KiB
C
/*
|
|
This file is part of Fennix Kernel.
|
|
|
|
Fennix Kernel is free software: you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License as
|
|
published by the Free Software Foundation, either version 3 of
|
|
the License, or (at your option) any later version.
|
|
|
|
Fennix Kernel is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef __FENNIX_API_DRIVER_FUNCTIONS_H__
|
|
#define __FENNIX_API_DRIVER_FUNCTIONS_H__
|
|
|
|
#include <types.h>
|
|
|
|
typedef enum
|
|
{
|
|
_drf_Entry,
|
|
_drf_Final,
|
|
_drf_Panic,
|
|
_drf_Probe,
|
|
} __driverRegFunc;
|
|
|
|
typedef union
|
|
{
|
|
struct
|
|
{
|
|
uint8_t LeftButton : 1;
|
|
uint8_t RightButton : 1;
|
|
uint8_t MiddleButton : 1;
|
|
uint8_t Button4 : 1;
|
|
uint8_t Button5 : 1;
|
|
uint8_t Button6 : 1;
|
|
uint8_t Button7 : 1;
|
|
uint8_t Button8 : 1;
|
|
};
|
|
uint8_t Value;
|
|
} __MouseButtons;
|
|
|
|
typedef struct
|
|
{
|
|
/* PCIDevice */ void *Device;
|
|
/* __PCIArray */ void *Next;
|
|
} __PCIArray;
|
|
|
|
/* ========================================== */
|
|
|
|
#define PCI_END 0x0000
|
|
#define KEY_NULL 0x00
|
|
|
|
typedef enum
|
|
{
|
|
KEY_1,
|
|
KEY_2,
|
|
KEY_3,
|
|
KEY_4,
|
|
KEY_5,
|
|
KEY_6,
|
|
KEY_7,
|
|
KEY_8,
|
|
KEY_9,
|
|
KEY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CTL_AUDIO_GET_MUTE = 2,
|
|
IOCTL_AUDIO_SET_MUTE = 3,
|
|
|
|
IOCTL_AUDIO_GET_SAMPLE_RATE = 4,
|
|
IOCTL_AUDIO_SET_SAMPLE_RATE = 5,
|
|
|
|
IOCTL_AUDIO_GET_CHANNELS = 6,
|
|
IOCTL_AUDIO_SET_CHANNELS = 7,
|
|
} AudioIoctl;
|
|
|
|
typedef enum
|
|
{
|
|
IOCTL_NET_GET_MAC = 0,
|
|
} NetIoctl;
|
|
|
|
typedef enum
|
|
{
|
|
MAP_PRESENT = 1 << 0,
|
|
MAP_WRITE = 1 << 1,
|
|
MAP_USER = 1 << 2,
|
|
MAP_WRITE_THROUGH = 1 << 3,
|
|
MAP_CACHE_DISABLE = 1 << 4,
|
|
} PageMapFlags;
|
|
|
|
typedef struct
|
|
{
|
|
struct
|
|
{
|
|
uint8_t Major;
|
|
uint8_t Minor;
|
|
uint8_t Patch;
|
|
} APIVersion;
|
|
|
|
dev_t MajorID;
|
|
uintptr_t Base;
|
|
|
|
/* Internal */
|
|
int (*RegisterFunction)(dev_t MajorID, void *Function, __driverRegFunc Type);
|
|
int (*GetDriverInfo)(dev_t MajorID, const char *Name, const char *Description, const char *Author, const char *Version, const char *License);
|
|
|
|
/* Interrupts */
|
|
int (*RegisterInterruptHandler)(dev_t MajorID, uint8_t IRQ, void *Handler);
|
|
int (*OverrideInterruptHandler)(dev_t MajorID, uint8_t IRQ, void *Handler);
|
|
int (*UnregisterInterruptHandler)(dev_t MajorID, uint8_t IRQ, void *Handler);
|
|
int (*UnregisterAllInterruptHandlers)(dev_t MajorID, void *Handler);
|
|
|
|
/* /dev/... */
|
|
dev_t (*RegisterDevice)(dev_t MajorID, char Prefix[8], void *Open, void *Close, void *Read, void *Write, void *Ioctl);
|
|
int (*UnregisterDevice)(dev_t MajorID, dev_t MinorID);
|
|
|
|
/* Logging */
|
|
void (*KPrint)(dev_t MajorID, const char *Format, va_list args);
|
|
void (*KernelLog)(dev_t MajorID, const char *Format, va_list args);
|
|
|
|
/* Memory */
|
|
void *(*RequestPages)(dev_t MajorID, size_t Pages);
|
|
void (*FreePages)(dev_t MajorID, void *Pointer, size_t Pages);
|
|
|
|
/* Mapping */
|
|
void (*AppendMapFlag)(dev_t MajorID, void *Address, PageMapFlags Flag);
|
|
void (*RemoveMapFlag)(dev_t MajorID, void *Address, PageMapFlags Flag);
|
|
void (*MapPages)(dev_t MajorID, void *PhysicalAddress, void *VirtualAddress, size_t Pages, uint32_t Flags);
|
|
void (*UnmapPages)(dev_t MajorID, void *VirtualAddress, size_t Pages);
|
|
|
|
/* Scheduling */
|
|
pid_t (*CreateKernelProcess)(dev_t MajorID, const char *Name);
|
|
pid_t (*CreateKernelThread)(dev_t MajorID, pid_t pId, const char *Name, void *EntryPoint, void *Argument);
|
|
pid_t (*GetCurrentProcess)(dev_t MajorID);
|
|
int (*KillProcess)(dev_t MajorID, pid_t pId, int ExitCode);
|
|
int (*KillThread)(dev_t MajorID, pid_t tId, pid_t pId, int ExitCode);
|
|
void (*Yield)(dev_t MajorID);
|
|
void (*Sleep)(dev_t MajorID, uint64_t Milliseconds);
|
|
|
|
/* PCI */
|
|
__PCIArray *(*GetPCIDevices)(dev_t MajorID, uint16_t Vendors[], uint16_t Devices[]);
|
|
void (*InitializePCI)(dev_t MajorID, void *Header);
|
|
uint32_t (*GetBAR)(dev_t MajorID, uint8_t Index, void *Header);
|
|
|
|
/* Kernel std API */
|
|
void *(*memcpy)(dev_t MajorID, void *Destination, const void *Source, size_t Length);
|
|
void *(*memset)(dev_t MajorID, void *Destination, int Value, size_t Length);
|
|
void *(*memmove)(dev_t MajorID, void *Destination, const void *Source, size_t Length);
|
|
int (*memcmp)(dev_t MajorID, const void *Left, const void *Right, size_t Length);
|
|
size_t (*strlen)(dev_t MajorID, const char *String);
|
|
char *(*strcpy)(dev_t MajorID, char *Destination, const char *Source);
|
|
char *(*strcat)(dev_t MajorID, char *Destination, const char *Source);
|
|
int (*strcmp)(dev_t MajorID, const char *Left, const char *Right);
|
|
int (*strncmp)(dev_t MajorID, const char *Left, const char *Right, size_t Length);
|
|
char *(*strchr)(dev_t MajorID, const char *String, int Character);
|
|
char *(*strrchr)(dev_t MajorID, const char *String, int Character);
|
|
char *(*strstr)(dev_t MajorID, const char *Haystack, const char *Needle);
|
|
} __driverAPI;
|
|
|
|
#endif // !__FENNIX_API_DRIVER_FUNCTIONS_H__
|