Update kernel

This commit is contained in:
Alex
2023-08-06 04:53:14 +03:00
parent 3b65386399
commit 2c51e4432f
181 changed files with 21873 additions and 21475 deletions

View File

@ -273,7 +273,7 @@ namespace AdvancedHostControllerInterface
Ports[i]->Configure();
break;
}
case FetchReason:
case QueryReason:
{
Data->DiskCallback.Fetch.Ports = PortCount;
Data->DiskCallback.Fetch.BytesPerSector = 512;

View File

@ -52,7 +52,7 @@ namespace AdvancedTechnologyAttachment
debug("Driver received configuration data.");
break;
}
case FetchReason:
case QueryReason:
{
break;
}

View File

@ -82,7 +82,7 @@ namespace PCNET
return DEVICE_NOT_SUPPORTED;
break;
}
case FetchReason:
case QueryReason:
{
memcpy(Data->NetworkCallback.Fetch.Name, (void *)"AMD PCNET", 10);
Data->NetworkCallback.Fetch.MAC = MAC.ToHex();

View File

@ -212,7 +212,7 @@ namespace AudioCodec97
}
break;
}
case FetchReason:
case QueryReason:
{
Data->AudioCallback.Fetch.Volume = (unsigned char)((inw(BAR.MixerAddress + NAM_MasterVolume) & 0x3F) * 100 / 0x3F);
Data->AudioCallback.Fetch.Encoding = Encoding; /* FIXME */

View File

@ -20,6 +20,7 @@
#include "AHCI/ahci.hpp"
#include "VMware/mouse.hpp"
#include "PersonalSystem2/mouse.hpp"
#include "PersonalSystem2/keyboard.hpp"
#include "ATA/ata.hpp"
#include "AudioCodec97/ac97.hpp"
#include "Realtek/rtl8139.hpp"
@ -80,6 +81,19 @@ FexExtended PS2MouseExtendedHeader = {
.Vector = {12}, // IRQ12
}}}};
FexExtended PS2KeyboardExtendedHeader = {
.Driver = {
.Name = "PS/2 Keyboard",
.Type = FexDriverType_Input,
.TypeFlags = FexDriverInputTypes_Keyboard,
.Callback = PS2Keyboard::CallbackHandler,
.InterruptCallback = PS2Keyboard::InterruptCallback,
.Bind = {
.Type = BIND_INTERRUPT,
.Interrupt = {
.Vector = {1}, // IRQ1
}}}};
FexExtended ATAExtendedHeader = {
.Driver = {
.Name = "Advanced Technology Attachment",
@ -217,6 +231,18 @@ bool StartPS2Mouse()
return false;
}
bool StartPS2Keyboard()
{
Driver::BuiltInDriverInfo BIDI = {
.EntryPoint = PS2Keyboard::DriverEntry,
.ExtendedHeader = &PS2KeyboardExtendedHeader};
if (DriverManager->DriverLoadBindInterrupt((uintptr_t)&BIDI, 0, true) == Driver::DriverCode::OK)
return true;
return false;
}
bool StartATA()
{
Driver::BuiltInDriverInfo BIDI = {

View File

@ -203,7 +203,9 @@ namespace Gigabit
if (!GetMAC().Valid())
return NOT_AVAILABLE;
else
{
debug("MAC address found.");
}
MAC = GetMAC();
// Start link
@ -244,7 +246,9 @@ namespace Gigabit
if (!GetMAC().Valid())
return NOT_AVAILABLE;
else
{
debug("MAC address found.");
}
MAC = GetMAC();
return NOT_IMPLEMENTED;
@ -273,7 +277,9 @@ namespace Gigabit
if (!GetMAC().Valid())
return NOT_AVAILABLE;
else
{
debug("MAC address found.");
}
MAC = GetMAC();
return NOT_IMPLEMENTED;
@ -296,7 +302,7 @@ namespace Gigabit
}
return ERROR;
}
case FetchReason:
case QueryReason:
{
memcpy(Data->NetworkCallback.Fetch.Name, (void *)"Intel Gigabit Ethernet Controller", 34);
Data->NetworkCallback.Fetch.MAC = MAC.ToHex();

View File

@ -0,0 +1,107 @@
/*
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/>.
*/
#include "keyboard.hpp"
#include <limits.h>
#include <debug.h>
#include <io.h>
#include "../../DAPI.hpp"
#include "../drv.hpp"
#include "../../kernel.h"
namespace PS2Keyboard
{
KernelAPI KAPI;
uint8_t ScanCode = 0;
bool InputReceived = false;
int DriverEntry(void *Data)
{
if (!Data)
return INVALID_KERNEL_API;
KAPI = *(KernelAPI *)Data;
if (KAPI.Version.Major < 0 || KAPI.Version.Minor < 0 || KAPI.Version.Patch < 0)
return KERNEL_API_VERSION_NOT_SUPPORTED;
return OK;
}
int CallbackHandler(KernelCallback *Data)
{
switch (Data->Reason)
{
case AcknowledgeReason:
{
debug("Kernel acknowledged the driver.");
break;
}
case ConfigurationReason:
{
while (inb(0x64) & 0x1)
inb(0x60);
outb(0x64, 0xAE);
outb(0x64, 0x20);
uint8_t ret = (inb(0x60) | 1) & ~0x10;
outb(0x64, 0x60);
outb(0x60, ret);
outb(0x60, 0xF4);
outb(0x21, 0xFD);
outb(0xA1, 0xFF);
trace("PS/2 keyboard configured.");
break;
}
case QueryReason:
{
Data->InputCallback.Keyboard.Key = ScanCode;
break;
}
case PollWaitReason:
{
while (!InputReceived)
TaskManager->Yield();
InputReceived = false;
Data->InputCallback.Keyboard.Key = ScanCode;
break;
}
case StopReason:
{
fixme("Driver stopped.");
break;
}
default:
{
warn("Unknown reason.");
break;
}
}
return OK;
}
int InterruptCallback(CPURegisters *)
{
ScanCode = inb(0x60);
InputReceived = true;
return OK;
}
}

View File

@ -1,3 +1,20 @@
/*
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/>.
*/
#include "mouse.hpp"
#include <debug.h>
@ -5,6 +22,7 @@
#include "../../DAPI.hpp"
#include "../drv.hpp"
#include "../../kernel.h"
namespace PS2Mouse
{
@ -83,7 +101,7 @@ namespace PS2Mouse
trace("PS/2 mouse configured.");
break;
}
case FetchReason:
case QueryReason:
{
Data->InputCallback.Mouse.X = MouseX;
Data->InputCallback.Mouse.Y = MouseY;
@ -93,6 +111,19 @@ namespace PS2Mouse
Data->InputCallback.Mouse.Buttons.Middle = MouseMiddle;
break;
}
case PollWaitReason:
{
while (!PacketReady)
TaskManager->Yield();
Data->InputCallback.Mouse.X = MouseX;
Data->InputCallback.Mouse.Y = MouseY;
Data->InputCallback.Mouse.Z = MouseZ;
Data->InputCallback.Mouse.Buttons.Left = MouseLeft;
Data->InputCallback.Mouse.Buttons.Right = MouseRight;
Data->InputCallback.Mouse.Buttons.Middle = MouseMiddle;
break;
}
case StopReason:
{
outb(COMMAND, 0xA8);

View File

@ -0,0 +1,237 @@
/*
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_KERNEL_PS2_KEYBOARD_H__
#define __FENNIX_KERNEL_PS2_KEYBOARD_H__
#include <types.h>
#include "../../DAPI.hpp"
namespace PS2Keyboard
{
enum DownKeys
{
KEY_D_ESCAPE = 0x1,
KEY_D_1 = 0x2,
KEY_D_2 = 0x3,
KEY_D_3 = 0x4,
KEY_D_4 = 0x5,
KEY_D_5 = 0x6,
KEY_D_6 = 0x7,
KEY_D_7 = 0x8,
KEY_D_8 = 0x9,
KEY_D_9 = 0xa,
KEY_D_0 = 0xb,
KEY_D_MINUS = 0xc,
KEY_D_EQUALS = 0xd,
KEY_D_BACKSPACE = 0xe,
KEY_D_TAB = 0xf,
KEY_D_Q = 0x10,
KEY_D_W = 0x11,
KEY_D_E = 0x12,
KEY_D_R = 0x13,
KEY_D_T = 0x14,
KEY_D_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
KEY_U_SLASH = 0xb5,
KEY_U_RSHIFT = 0xb6,
KEY_U_KP_MULTIPLY = 0xb7,
KEY_U_LALT = 0xb8,
KEY_U_SPACE = 0xb9,
KEY_U_CAPSLOCK = 0xba,
KEY_U_F1 = 0xbb,
KEY_U_F2 = 0xbc,
KEY_U_F3 = 0xbd,
KEY_U_F4 = 0xbe,
KEY_U_F5 = 0xbf,
KEY_U_F6 = 0xc0,
KEY_U_F7 = 0xc1,
KEY_U_F8 = 0xc2,
KEY_U_F9 = 0xc3,
KEY_U_F10 = 0xc4,
KEY_U_NUMLOCK = 0xc5,
KEY_U_SCROLLLOCK = 0xc6,
KEY_U_KP_7 = 0xc7,
KEY_U_KP_8 = 0xc8,
KEY_U_KP_9 = 0xc9,
KEY_U_KP_MINUS = 0xca,
KEY_U_KP_4 = 0xcb,
KEY_U_KP_5 = 0xcc,
KEY_U_KP_6 = 0xcd,
KEY_U_KP_PLUS = 0xce,
KEY_U_KP_1 = 0xcf,
KEY_U_KP_2 = 0xd0,
KEY_U_KP_3 = 0xd1,
KEY_U_KP_0 = 0xd2,
KEY_U_KP_PERIOD = 0xd3,
KEY_U_F11 = 0xd7,
KEY_U_F12 = 0xd8,
};
int DriverEntry(void *);
int CallbackHandler(KernelCallback *);
int InterruptCallback(CPURegisters *);
}
#endif // !__FENNIX_KERNEL_PS2_KEYBOARD_H__

View File

@ -141,7 +141,7 @@ namespace RTL8139
return DEVICE_NOT_SUPPORTED;
break;
}
case FetchReason:
case QueryReason:
{
memcpy(Data->NetworkCallback.Fetch.Name, (void *)"RTL-8139", 9);
Data->NetworkCallback.Fetch.MAC = MAC.ToHex();

View File

@ -5,6 +5,7 @@
#include "../../DAPI.hpp"
#include "../drv.hpp"
#include "../../kernel.h"
/* https://wiki.osdev.org/VMware_tools */
@ -129,6 +130,8 @@ namespace VMwareMouse
int MouseX = 0, MouseY = 0, MouseZ = 0;
int MouseButton = 0;
bool InputReceived = false;
int CallbackHandler(KernelCallback *Data)
{
switch (Data->Reason)
@ -156,7 +159,7 @@ namespace VMwareMouse
trace("VMware mouse configured.");
break;
}
case FetchReason:
case QueryReason:
{
Data->InputCallback.Mouse.X = (MouseX * KAPI.Display.GetWidth()) / 0xFFFF;
Data->InputCallback.Mouse.Y = (MouseY * KAPI.Display.GetHeight()) / 0xFFFF;
@ -166,6 +169,20 @@ namespace VMwareMouse
Data->InputCallback.Mouse.Buttons.Middle = MouseButton & 0x08;
break;
}
case PollWaitReason:
{
while (!InputReceived)
TaskManager->Yield();
InputReceived = false;
Data->InputCallback.Mouse.X = (MouseX * KAPI.Display.GetWidth()) / 0xFFFF;
Data->InputCallback.Mouse.Y = (MouseY * KAPI.Display.GetHeight()) / 0xFFFF;
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();
@ -220,6 +237,7 @@ namespace VMwareMouse
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. */
InputReceived = true;
return OK;
}
}

View File

@ -23,6 +23,7 @@
bool StartAHCI();
bool StartVMwareMouse();
bool StartPS2Mouse();
bool StartPS2Keyboard();
bool StartATA();
bool StartAC97();
bool StartRTL8139();