redo boot around an explicit system volume and fixed kernel/HAL images, redo volumes and filesystem paths around capabilities instead of drive numbers and kernel CWD state, add a capability/security model with derived and revocable handles and security contexts, add port IPC and rssrv to manage the userspace resource namespace and publish the system volume, move process, dll and path loading to userspace and add process builder syscalls, init now supervises rssrv and the session process, redo the syscall ABI around request structs and four arguments, add a volume manager and proper partition arrival/removal handling so FAT and NTFS mount dynamically, clean up the HAL/DDK boundary so drivers don't depend on HAL internals, save fpu state properly now, the serial driver doesn't hang on a missing port, fix AHCI startup races, fix timeout accounting, fix shared mmap writeback, more smoke tests
This commit is contained in:
1 parent
4add6789ba
commit
f882d339fb
232 files changed
+20934
-8898
No files matched your search
@@ -22,6 +22,7 @@
|
||||
#define SERIAL_REG_LCR 3u
|
||||
#define SERIAL_REG_MCR 4u
|
||||
#define SERIAL_REG_LSR 5u
|
||||
#define SERIAL_REG_SCR 7u
|
||||
|
||||
#define SERIAL_LSR_DATA_READY 0x01u
|
||||
#define SERIAL_LSR_TX_EMPTY 0x20u
|
||||
@@ -37,6 +38,7 @@
|
||||
#define SERIAL_FCR_TRIGGER_14 0xC0u
|
||||
|
||||
#define SERIAL_RX_QUEUE_SIZE 1024u
|
||||
#define SERIAL_RX_DRAIN_LIMIT 256u
|
||||
#define SERIAL_RX_QUEUE_MASK (SERIAL_RX_QUEUE_SIZE - 1u)
|
||||
|
||||
typedef enum SERIAL_ESCAPE_STATE {
|
||||
@@ -65,6 +67,19 @@ static void SerialWrite(uint16_t reg, uint8_t value) {
|
||||
__outbyte((unsigned short)(SERIAL_COM1_BASE + reg), value);
|
||||
}
|
||||
|
||||
// Probes the 16550 scratch register so an absent COM1 device is rejected before any receive loop is entered.
|
||||
static bool SerialProbeCom1(void) {
|
||||
uint8_t original = SerialRead(SERIAL_REG_SCR);
|
||||
|
||||
SerialWrite(SERIAL_REG_SCR, 0x5Au);
|
||||
uint8_t first = SerialRead(SERIAL_REG_SCR);
|
||||
SerialWrite(SERIAL_REG_SCR, 0xA5u);
|
||||
uint8_t second = SerialRead(SERIAL_REG_SCR);
|
||||
SerialWrite(SERIAL_REG_SCR, original);
|
||||
|
||||
return first == 0x5Au && second == 0xA5u;
|
||||
}
|
||||
|
||||
// Submits one input key transition.
|
||||
static void SerialSubmitTransition(INPUT_KEY key, bool pressed) {
|
||||
INPUT_KEY_EVENT event;
|
||||
@@ -301,8 +316,8 @@ static void SerialIsr(void) {
|
||||
}
|
||||
}
|
||||
|
||||
// Initializes COM1 as an 8N1 115200 baud input device.
|
||||
static void SerialInitializeCom1(void) {
|
||||
// Configures COM1 as an 8N1 115200 baud input device while leaving receive interrupts disabled.
|
||||
static KSTATUS SerialConfigureCom1(void) {
|
||||
SerialWrite(SERIAL_REG_IER, 0x00u);
|
||||
SerialWrite(SERIAL_REG_LCR, SERIAL_LCR_DLAB);
|
||||
SerialWrite(SERIAL_REG_DATA, 0x01u);
|
||||
@@ -312,10 +327,16 @@ static void SerialInitializeCom1(void) {
|
||||
SERIAL_FCR_CLEAR_TX | SERIAL_FCR_TRIGGER_14);
|
||||
SerialWrite(SERIAL_REG_MCR, SERIAL_MCR_DTR | SERIAL_MCR_RTS | SERIAL_MCR_OUT2);
|
||||
|
||||
while (SerialRead(SERIAL_REG_LSR) & SERIAL_LSR_DATA_READY)
|
||||
for (uint32_t i = 0; i < SERIAL_RX_DRAIN_LIMIT; i++) {
|
||||
uint8_t lsr = SerialRead(SERIAL_REG_LSR);
|
||||
if (lsr == 0xFFu)
|
||||
return NTLSTATUS_NOT_FOUND;
|
||||
if ((lsr & SERIAL_LSR_DATA_READY) == 0)
|
||||
return NTLSTATUS_SUCCESS;
|
||||
(void)SerialRead(SERIAL_REG_DATA);
|
||||
}
|
||||
|
||||
SerialWrite(SERIAL_REG_IER, SERIAL_IER_RX_READY);
|
||||
return NTLSTATUS_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
// DriverEntry registers COM1 as an input source.
|
||||
@@ -323,8 +344,19 @@ KSTATUS DriverEntry(const NTL_DDK* ddk, NTL_DRIVER_INIT* init) {
|
||||
(void)ddk;
|
||||
(void)init;
|
||||
|
||||
if (!SerialProbeCom1()) {
|
||||
DbgPrint("serial: COM1 not present; input driver disabled\n");
|
||||
return NTLSTATUS_NOT_FOUND;
|
||||
}
|
||||
|
||||
KSTATUS st = SerialConfigureCom1();
|
||||
if (!KSUCCESS(st)) {
|
||||
DbgPrint("serial: COM1 did not become idle during initialization, status=0x%08X\n", st);
|
||||
return st;
|
||||
}
|
||||
|
||||
uint32_t deviceId = 0;
|
||||
KSTATUS st = KeInputRegisterDevice("serial-com1", 0, &deviceId);
|
||||
st = KeInputRegisterDevice("serial-com1", 0, &deviceId);
|
||||
if (!KSUCCESS(st))
|
||||
return st;
|
||||
|
||||
@@ -336,8 +368,8 @@ KSTATUS DriverEntry(const NTL_DDK* ddk, NTL_DRIVER_INIT* init) {
|
||||
gSerialRxTail = 0;
|
||||
gSerialRxDropped = 0;
|
||||
|
||||
SerialInitializeCom1();
|
||||
KeIrqRegister(SERIAL_COM1_IRQ, SerialIsr);
|
||||
SerialWrite(SERIAL_REG_IER, SERIAL_IER_RX_READY);
|
||||
|
||||
DbgPrint("serial: initialized COM1 input device=%u irq=%u\n", deviceId, SERIAL_COM1_IRQ);
|
||||
return NTLSTATUS_SUCCESS;
|
||||
|
||||
Reference in new issue
Block a user