summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/aarch64/aarch64/acpi_machdep.c37
-rw-r--r--sys/arch/aarch64/aarch64/machdep.c83
-rw-r--r--sys/arch/aarch64/aarch64/mp.c39
-rw-r--r--sys/arch/aarch64/aarch64/pmap.c68
-rw-r--r--sys/arch/aarch64/aarch64/proc_machdep.c70
-rw-r--r--sys/arch/aarch64/aarch64/reboot.c38
-rw-r--r--sys/arch/aarch64/conf/GENERIC5
-rw-r--r--sys/arch/aarch64/conf/link.ld75
-rw-r--r--sys/arch/aarch64/pci/pci_machdep.c79
-rw-r--r--sys/arch/amd64/conf/GENERIC4
-rw-r--r--sys/arch/amd64/isa/i8042.c48
11 files changed, 522 insertions, 24 deletions
diff --git a/sys/arch/aarch64/aarch64/acpi_machdep.c b/sys/arch/aarch64/aarch64/acpi_machdep.c
new file mode 100644
index 0000000..f077de3
--- /dev/null
+++ b/sys/arch/aarch64/aarch64/acpi_machdep.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <dev/acpi/acpi.h>
+#include <dev/acpi/acpivar.h>
+
+int
+acpi_init_madt(void)
+{
+ return 0;
+}
diff --git a/sys/arch/aarch64/aarch64/machdep.c b/sys/arch/aarch64/aarch64/machdep.c
new file mode 100644
index 0000000..a29ad7e
--- /dev/null
+++ b/sys/arch/aarch64/aarch64/machdep.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/syslog.h>
+#include <sys/panic.h>
+#include <machine/cpu.h>
+#include <machine/sync.h>
+
+struct cpu_info g_bsp_ci = {0};
+
+void
+cpu_startup(struct cpu_info *ci)
+{
+ /* TODO: STUB */
+ return;
+}
+
+void
+serial_init(void)
+{
+ /* TODO: STUB */
+ return;
+}
+
+void
+md_backtrace(void)
+{
+ /* TODO: STUB */
+ return;
+}
+
+void
+serial_putc(char c)
+{
+ /* TODO: STUB */
+ return;
+}
+
+int
+md_sync_all(void)
+{
+ /* TODO: STUB */
+ return 0;
+}
+
+/*
+ * Get the descriptor for the currently
+ * running processor.
+ */
+struct cpu_info *
+this_cpu(void)
+{
+ struct cpu_info *ci;
+
+ __ASMV("mrs %0, tpidr_el0" : "=r" (ci));
+ return ci;
+}
diff --git a/sys/arch/aarch64/aarch64/mp.c b/sys/arch/aarch64/aarch64/mp.c
new file mode 100644
index 0000000..4e07566
--- /dev/null
+++ b/sys/arch/aarch64/aarch64/mp.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <machine/cpu.h>
+
+#define pr_trace(fmt, ...) kprintf("cpu_mp: " fmt, ##__VA_ARGS__)
+
+void
+mp_bootstrap_aps(struct cpu_info *ci)
+{
+ for (;;);
+}
diff --git a/sys/arch/aarch64/aarch64/pmap.c b/sys/arch/aarch64/aarch64/pmap.c
new file mode 100644
index 0000000..b5ebda9
--- /dev/null
+++ b/sys/arch/aarch64/aarch64/pmap.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <machine/vas.h>
+#include <vm/pmap.h>
+
+struct vas
+pmap_read_vas(void)
+{
+ /* TODO: STUB */
+ struct vas vas = {0};
+ return vas;
+}
+
+void
+pmap_switch_vas(struct vas vas)
+{
+ /* TODO: STUB */
+ return;
+}
+
+int
+pmap_map(struct vas vas, vaddr_t va, paddr_t pa, vm_prot_t prot)
+{
+ /* TODO: STUB */
+ return 0;
+}
+
+int
+pmap_unmap(struct vas vas, vaddr_t va)
+{
+ /* TODO: STUB */
+ return 0;
+}
+
+void
+pmap_destroy_vas(struct vas vas)
+{
+ /* TODO: STUB */
+ return;
+}
diff --git a/sys/arch/aarch64/aarch64/proc_machdep.c b/sys/arch/aarch64/aarch64/proc_machdep.c
new file mode 100644
index 0000000..97902e5
--- /dev/null
+++ b/sys/arch/aarch64/aarch64/proc_machdep.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/proc.h>
+
+/*
+ * MD thread init code
+ *
+ * @p: New process.
+ * @parent: Parent of new process.
+ * @ip: Instruction pointer.
+ */
+int
+md_fork(struct proc *p, struct proc *parent, uintptr_t ip)
+{
+ /* TODO: STUB */
+ return 0;
+}
+
+void
+md_td_stackinit(struct proc *td, void *stack_top, struct exec_prog *prog)
+{
+ /* TODO: STUB */
+ return;
+}
+
+void
+setregs(struct proc *td, struct exec_prog *prog, uintptr_t stack)
+{
+ /* TODO: STUB */
+ return;
+}
+
+/*
+ * Startup a user thread.
+ *
+ * @td: Thread to start up.
+ */
+void
+md_td_kick(struct proc *td)
+{
+ /* TODO: STUB */
+ for (;;);
+}
diff --git a/sys/arch/aarch64/aarch64/reboot.c b/sys/arch/aarch64/aarch64/reboot.c
new file mode 100644
index 0000000..6d82133
--- /dev/null
+++ b/sys/arch/aarch64/aarch64/reboot.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/reboot.h>
+#include <sys/param.h>
+
+void
+cpu_reboot(int method)
+{
+ /* TODO: STUB */
+ for (;;);
+}
diff --git a/sys/arch/aarch64/conf/GENERIC b/sys/arch/aarch64/conf/GENERIC
new file mode 100644
index 0000000..5691685
--- /dev/null
+++ b/sys/arch/aarch64/conf/GENERIC
@@ -0,0 +1,5 @@
+// Kernel options
+option SERIAL_DEBUG yes
+
+// Kernel constants
+setval SCHED_NQUEUE 4
diff --git a/sys/arch/aarch64/conf/link.ld b/sys/arch/aarch64/conf/link.ld
new file mode 100644
index 0000000..c64cec3
--- /dev/null
+++ b/sys/arch/aarch64/conf/link.ld
@@ -0,0 +1,75 @@
+/* Tell the linker that we want an aarch64 ELF64 output file */
+OUTPUT_FORMAT(elf64-littleaarch64)
+OUTPUT_ARCH(aarch64)
+
+/* We want the symbol main to be our entry point */
+ENTRY(main)
+
+/* Define the program headers we want so the bootloader gives us the right */
+/* MMU permissions */
+PHDRS
+{
+ text PT_LOAD FLAGS((1 << 0) | (1 << 2)) ; /* Execute + Read */
+ rodata PT_LOAD FLAGS((1 << 2)) ; /* Read only */
+ data PT_LOAD FLAGS((1 << 1) | (1 << 2)) ; /* Write + Read */
+ dynamic PT_DYNAMIC FLAGS((1 << 1) | (1 << 2)) ; /* Dynamic PHDR for relocations */
+}
+
+SECTIONS
+{
+ /* We wanna be placed in the topmost 2GiB of the address space, for optimisations */
+ /* and because that is what the Limine spec mandates. */
+ /* Any address in this region will do, but often 0xffffffff80000000 is chosen as */
+ /* that is the beginning of the region. */
+ . = 0xffffffff80000000;
+
+ .text : {
+ *(.text .text.*)
+ } :text
+
+ /* Move to the next memory page for .rodata */
+ . += CONSTANT(MAXPAGESIZE);
+
+ .rodata : {
+ *(.rodata .rodata.*)
+ } :rodata
+
+ .drivers : {
+ __drivers_init_start = .;
+ *(.drivers .drivers)
+ __drivers_init_end = .;
+ } :rodata
+
+ /* Move to the next memory page for .data */
+ . += CONSTANT(MAXPAGESIZE);
+
+ .data : {
+ *(.data .data.*)
+ } :data
+
+ /* Dynamic section for relocations, both in its own PHDR and inside data PHDR */
+ .dynamic : {
+ *(.dynamic)
+ } :data :dynamic
+
+ /* NOTE: .bss needs to be the last thing mapped to :data, otherwise lots of */
+ /* unnecessary zeros will be written to the binary. */
+ /* If you need, for example, .init_array and .fini_array, those should be placed */
+ /* above this. */
+ .bss : {
+ *(.bss .bss.*)
+ *(COMMON)
+ } :data
+
+ /* -- Cache line alignment -- */
+ . = ALIGN(64);
+ .data.cacheline_aligned : {
+ *(.data.cacheline_aligned)
+ }
+
+ /* Discard .note.* and .eh_frame since they may cause issues on some hosts. */
+ /DISCARD/ : {
+ *(.eh_frame)
+ *(.note .note.*)
+ }
+}
diff --git a/sys/arch/aarch64/pci/pci_machdep.c b/sys/arch/aarch64/pci/pci_machdep.c
new file mode 100644
index 0000000..fa92165
--- /dev/null
+++ b/sys/arch/aarch64/pci/pci_machdep.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <dev/pci/pci.h>
+
+pcireg_t
+pci_readl(struct pci_device *dev, uint32_t offset)
+{
+ /* TODO: STUB */
+ return 0;
+}
+
+void
+pci_writel(struct pci_device *dev, uint32_t offset, pcireg_t val)
+{
+ /* TODO: STUB */
+ return;
+}
+
+/*
+ * Map a BAR into kernel memory.
+ *
+ * @dev: Device of BAR to map.
+ * @barno: BAR number to map.
+ * @vap: Resulting virtual address.
+ */
+int
+pci_map_bar(struct pci_device *dev, uint8_t barno, void **vap)
+{
+ /* TODO: STUB */
+ return 0;
+}
+
+void
+pci_msix_eoi(void)
+{
+ return;
+}
+
+/*
+ * Enable MSI-X for a device and allocate an
+ * interrupt vector.
+ *
+ * @dev: Device to enable MSI-X for.
+ * @intr: MSI-X interrupt descriptor.
+ */
+int
+pci_enable_msix(struct pci_device *dev, const struct msi_intr *intr)
+{
+ /* TODO: STUB */
+ return 0;
+}
diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC
index 19c9a62..d3a4368 100644
--- a/sys/arch/amd64/conf/GENERIC
+++ b/sys/arch/amd64/conf/GENERIC
@@ -4,3 +4,7 @@ option SERIAL_DEBUG yes
// Kernel constants
setval SCHED_NQUEUE 4
+
+// Console attributes
+setval CONSOLE_BG 0x000000
+setval CONSOLE_FG 0XB57614
diff --git a/sys/arch/amd64/isa/i8042.c b/sys/arch/amd64/isa/i8042.c
index ea4fc65..2582d8f 100644
--- a/sys/arch/amd64/isa/i8042.c
+++ b/sys/arch/amd64/isa/i8042.c
@@ -57,15 +57,6 @@
#define pr_error(...) pr_trace(__VA_ARGS__)
#define IO_NOP() inb(0x80)
-#define OBUF_WAIT() do { \
- i8042_statpoll(I8042_OBUFF, false, NULL); \
- IO_NOP(); \
- } while (0);
-
-#define IBUF_WAIT() do { \
- i8042_statpoll(I8042_IBUFF, false, NULL); \
- IO_NOP(); \
- } while (0);
static struct spinlock data_lock;
static struct spinlock isr_lock;
@@ -117,11 +108,9 @@ kbd_set_leds(uint8_t mask)
*
* @bits: Status bits.
* @pollset: True to poll if set
- * @io: Routine to invoke per iter (NULL if none)
- * @flush: True to flush i8042 data per iter
*/
static int
-i8042_statpoll(uint8_t bits, bool pollset, bool flush)
+i8042_statpoll(uint8_t bits, bool pollset)
{
size_t usec_start, usec;
size_t elapsed_msec;
@@ -158,7 +147,9 @@ static void
i8042_drain(void)
{
spinlock_acquire(&data_lock);
- i8042_statpoll(I8042_OBUFF, false, true);
+ while (ISSET(inb(I8042_STATUS), I8042_OBUFF)) {
+ inb(I8042_DATA);
+ }
spinlock_release(&data_lock);
}
@@ -171,7 +162,7 @@ i8042_drain(void)
static void
i8042_write(uint16_t port, uint8_t val)
{
- IBUF_WAIT();
+ i8042_statpoll(I8042_IBUFF, false);
outb(port, val);
}
@@ -183,7 +174,7 @@ i8042_read_conf(void)
{
i8042_drain();
i8042_write(I8042_CMD, I8042_GET_CONFB);
- OBUF_WAIT();
+ i8042_statpoll(I8042_OBUFF, true);
return inb(I8042_DATA);
}
@@ -194,10 +185,11 @@ static void
i8042_write_conf(uint8_t value)
{
i8042_drain();
- IBUF_WAIT();
+ i8042_statpoll(I8042_IBUFF, false);
i8042_write(I8042_CMD, I8042_SET_CONFB);
- IBUF_WAIT();
+ i8042_statpoll(I8042_IBUFF, false);
i8042_write(I8042_DATA, value);
+ i8042_drain();
}
/*
@@ -213,9 +205,9 @@ dev_send(bool aux, uint8_t data)
i8042_write(I8042_CMD, I8042_PORT1_SEND);
}
- IBUF_WAIT();
+ i8042_statpoll(I8042_IBUFF, false);
i8042_write(I8042_DATA, data);
- OBUF_WAIT();
+ i8042_statpoll(I8042_OBUFF, true);
return inb(I8042_DATA);
}
@@ -223,6 +215,7 @@ void
i8042_kb_event(void)
{
struct cpu_info *ci;
+ struct cons_input input;
uint8_t data;
char c;
@@ -235,8 +228,9 @@ i8042_kb_event(void)
/* No data useful */
goto done;
}
- cons_putch(&g_root_scr, c);
- /* TODO */
+ input.scancode = data;
+ input.chr = c;
+ cons_ibuf_push(&g_root_scr, input);
done:
ci->irq_mask &= CPU_IRQ(1);
spinlock_release(&isr_lock);
@@ -360,6 +354,10 @@ i8042_kb_getc(uint8_t sc, char *chr)
static void
i8042_sync_loop(void)
{
+ /* Wake up the bus */
+ outb(I8042_DATA, 0x00);
+ i8042_drain();
+
for (;;) {
i8042_sync();
md_pause();
@@ -375,6 +373,7 @@ void
i8042_sync(void)
{
static struct spinlock lock;
+ struct cons_input input;
uint8_t data;
char c;
@@ -383,16 +382,17 @@ i8042_sync(void)
}
if (ISSET(quirks, I8042_HOSTILE) && is_init) {
- if (i8042_statpoll(I8042_OBUFF, true, NULL) < 0) {
+ if (i8042_statpoll(I8042_OBUFF, true) < 0) {
/* No data ready */
goto done;
}
data = inb(I8042_DATA);
if (i8042_kb_getc(data, &c) == 0) {
- cons_putch(&g_root_scr, c);
+ input.scancode = data;
+ input.chr = c;
+ cons_ibuf_push(&g_root_scr, input);
}
- md_pause();
}
done:
spinlock_release(&lock);