summaryrefslogtreecommitdiff
path: root/sys/include/dev
diff options
context:
space:
mode:
Diffstat (limited to 'sys/include/dev')
-rw-r--r--sys/include/dev/acpi/tables.h61
-rw-r--r--sys/include/dev/cons/ansi.h75
-rw-r--r--sys/include/dev/cons/cons.h21
-rw-r--r--sys/include/dev/dmi/dmi.h40
-rw-r--r--sys/include/dev/ic/ahciregs.h7
-rw-r--r--sys/include/dev/ic/ahcivar.h2
-rw-r--r--sys/include/dev/ic/nvmevar.h84
-rw-r--r--sys/include/dev/pci/pci.h1
-rw-r--r--sys/include/dev/phy/e1000regs.h119
-rw-r--r--sys/include/dev/phy/rtl.h (renamed from sys/include/dev/phy/rt8139.h)3
-rw-r--r--sys/include/dev/random/chacha20.h47
-rw-r--r--sys/include/dev/random/entropy.h40
-rw-r--r--sys/include/dev/random/siphash.h34
-rw-r--r--sys/include/dev/timer.h1
-rw-r--r--sys/include/dev/video/fbdev.h1
15 files changed, 534 insertions, 2 deletions
diff --git a/sys/include/dev/acpi/tables.h b/sys/include/dev/acpi/tables.h
index 5215c86..5340c7f 100644
--- a/sys/include/dev/acpi/tables.h
+++ b/sys/include/dev/acpi/tables.h
@@ -132,4 +132,65 @@ struct __packed acpi_hpet {
uint8_t page_protection;
};
+/*
+ * PCIe / ACPI MCFG base address description
+ * table.
+ *
+ * @base_pa: Enhanced configuration base [physical]
+ * @seg_grpno: PCI segment group number
+ * @bus_start: Host bridge bus start
+ * @bus_end: Host bridge bus end
+ */
+struct __packed acpi_mcfg_base {
+ uint64_t base_pa;
+ uint16_t seg_grpno;
+ uint8_t bus_start;
+ uint8_t bus_end;
+ uint32_t reserved;
+};
+
+/*
+ * PCIe / ACPI MCFG structure
+ *
+ * @hdr: ACPI header
+ * @reserved: Do not use
+ * @base: ECAM MMIO address list
+ */
+struct __packed acpi_mcfg {
+ struct acpi_header hdr;
+ uint32_t reserved[2];
+ struct acpi_mcfg_base base[1];
+};
+
+struct __packed dmi_entry32 {
+ char signature[4]; /* _SM_ */
+ uint8_t checksum; /* Sum of table bytes */
+ uint8_t length; /* Length of entry table */
+ uint8_t major; /* DMI major */
+ uint8_t minor; /* DMI minor */
+ uint16_t max_size; /* Max structure size */
+ uint8_t rev; /* Entry revision */
+ char fmt_area[5]; /* Formatted area */
+ char isignature[5]; /* Intermediate signature */
+ uint8_t ichecksum; /* Intermediate checksum */
+ uint16_t table_len; /* Length of SMBIOS structure table */
+ uint32_t addr; /* 32-bit physical start of SMBIOS structure table */
+ uint16_t nstruct; /* Total number of structures */
+ uint8_t bcd_rev;
+};
+
+struct __packed dmi_entry64 {
+ char signature[5]; /* _SM_ */
+ uint8_t checksum; /* Sum of table bytes */
+ uint8_t length; /* Length of entry table */
+ uint8_t major; /* DMI major */
+ uint8_t minor; /* DMI minor */
+ uint8_t docrev;
+ uint8_t entry_rev;
+ uint8_t reserved;
+ uint16_t max_size; /* Max structure size */
+ uint16_t padding;
+ uint64_t addr; /* 64-bit physical address */
+};
+
#endif /* _ACPI_TABLES_H_ */
diff --git a/sys/include/dev/cons/ansi.h b/sys/include/dev/cons/ansi.h
new file mode 100644
index 0000000..7a336d1
--- /dev/null
+++ b/sys/include/dev/cons/ansi.h
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+#ifndef _CONS_ANSI_H_
+#define _CONS_ANSI_H_
+
+#include <sys/types.h>
+#include <sys/cdefs.h>
+#include <sys/param.h>
+
+/* ANSI colors */
+#define ANSI_BLACK 0x000000
+#define ANSI_RED 0xAA0000
+#define ANSI_GREEN 0x00AA00
+#define ANSI_BLUE 0x00007F
+#define ANSI_YELLOW 0xAA5500
+#define ANSI_MAGENTA 0xAA00AA
+#define ANSI_CYAN 0x00AAAA
+#define ANSI_WHITE 0xAAAAAA
+
+/* ANSI_FEED update codes */
+#define ANSI_UPDATE_COLOR -1
+#define ANSI_UPDATE_CURSOR -2
+
+/*
+ * ANSI parser state machine.
+ *
+ * @prev: Previous char
+ * @csi: Encountered control seq introducer
+ * @reset_color: 1 if color is to be reset
+ * @set_fg: 1 if fg is being set
+ * @set_bg: 1 if bg is being set
+ * @fg: Foreground color
+ * @bg: Background color
+ * @flags: State flags
+ */
+struct ansi_state {
+ char prev;
+ uint8_t csi : 2;
+ uint8_t reset_color : 1;
+ uint8_t set_fg : 1;
+ uint8_t set_bg : 1;
+ uint32_t fg;
+ uint32_t bg;
+};
+
+int ansi_feed(struct ansi_state *statep, char c);
+
+#endif /* !_CONS_ANSI_H_ */
diff --git a/sys/include/dev/cons/cons.h b/sys/include/dev/cons/cons.h
index 3569c52..7c4e41a 100644
--- a/sys/include/dev/cons/cons.h
+++ b/sys/include/dev/cons/cons.h
@@ -32,8 +32,12 @@
#include <sys/types.h>
#include <sys/spinlock.h>
+#include <sys/proc.h>
+#include <sys/mutex.h>
+#include <sys/console.h>
#include <dev/video/fbdev.h>
#include <dev/cons/consvar.h>
+#include <dev/cons/ansi.h>
struct cons_char {
char c;
@@ -45,6 +49,11 @@ struct cons_char {
struct cons_screen {
struct fbdev fbdev;
+ struct ansi_state ansi_s;
+ struct console_feat feat; /* Features */
+ struct console_attr attr; /* Attributes */
+ struct proc *atproc; /* Attached proc */
+ struct mutex *atproc_lock;
uint32_t fg;
uint32_t bg;
@@ -54,17 +63,25 @@ struct cons_screen {
uint32_t ncols;
uint32_t ch_col; /* Current col */
uint32_t ch_row; /* Current row */
- uint32_t curs_col; /* Cursor col */
- uint32_t curs_row; /* Cursor row */
struct cons_buf *ib; /* Input buffer */
struct cons_buf **ob; /* Output buffers */
struct cons_char last_chr;
struct spinlock lock;
};
+#define curs_col attr.cursor_x
+#define curs_row attr.cursor_y
+
void cons_init(void);
void cons_expose(void);
+void cons_update_color(struct cons_screen *scr, uint32_t fg, uint32_t bg);
+void cons_clear_scr(struct cons_screen *scr, uint32_t bg);
+void cons_reset_color(struct cons_screen *scr);
+void cons_reset_cursor(struct cons_screen *scr);
+int cons_attach(void);
+int cons_detach(void);
int cons_putch(struct cons_screen *scr, char c);
+int cons_putstr(struct cons_screen *scr, const char *s, size_t len);
extern struct cons_screen g_root_scr;
diff --git a/sys/include/dev/dmi/dmi.h b/sys/include/dev/dmi/dmi.h
new file mode 100644
index 0000000..d24397a
--- /dev/null
+++ b/sys/include/dev/dmi/dmi.h
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+#ifndef _DMI_DMI_H_
+#define _DMI_DMI_H_
+
+#include <sys/types.h>
+
+const char *dmi_vendor(void);
+const char *dmi_prodver(void);
+const char *dmi_product(void);
+const char *dmi_cpu_manufact(void);
+
+#endif /* !_DMI_DMI_H_ */
diff --git a/sys/include/dev/ic/ahciregs.h b/sys/include/dev/ic/ahciregs.h
index f959a1e..232b41e 100644
--- a/sys/include/dev/ic/ahciregs.h
+++ b/sys/include/dev/ic/ahciregs.h
@@ -88,6 +88,7 @@ struct hba_memspace {
*/
#define AHCI_PXSSTS_DET(SSTS) (SSTS & 0xF)
#define AHCI_PXSSTS_IPM(SSTS) ((SSTS >> 8) & 0xF)
+#define AHCI_PXSSTS_SPD(SSTS) ((SSTS >> 4) & 0xF)
/*
* Port SATA control bits
@@ -100,6 +101,7 @@ struct hba_memspace {
* See section 3.3.7 of the AHCI spec.
*/
#define AHCI_PXCMD_ST BIT(0) /* Start */
+#define AHCI_PXCMD_SUD BIT(1) /* Spin-up device */
#define AHCI_PXCMD_FRE BIT(4) /* FIS Receive Enable */
#define AHCI_PXCMD_FR BIT(14) /* FIS Receive Running */
#define AHCI_PXCMD_CR BIT(15) /* Command List Running */
@@ -137,6 +139,9 @@ struct hba_memspace {
#define AHCI_DET_PRESENT 1 /* Device present (no PHY comm) */
#define AHCI_DET_COMM 3 /* Device present and phy comm established */
#define AHCI_IPM_ACTIVE 1
+#define AHCI_SPD_GEN1 1 /* 1.5 Gb/s */
+#define AHCI_SPD_GEN2 2 /* 3 Gb/s */
+#define AHCI_SPD_GEN3 3 /* 6 Gb/s */
/*
* PxSERR bits
@@ -158,6 +163,8 @@ struct hba_memspace {
#define AHCI_DIAG_T BIT(24) /* Transport state transition error */
#define AHCI_DIAG_F BIT(25) /* Unknown FIS type */
+#define ATAPI_SIG 0xEB140101
+
/*
* Device detection initialization values
* See section 3.3.11 of the AHCI spec.
diff --git a/sys/include/dev/ic/ahcivar.h b/sys/include/dev/ic/ahcivar.h
index a23a654..67f2efe 100644
--- a/sys/include/dev/ic/ahcivar.h
+++ b/sys/include/dev/ic/ahcivar.h
@@ -96,6 +96,7 @@ struct ahci_hba {
* @io: Memory mapped port registers
* @hba: HBA descriptor
* @cmdlist: Command list [p]
+ * @nlba: Max number of addressable blocks
* @fra: FIS receive area [p]
* @dev: Device minor number.
*/
@@ -104,6 +105,7 @@ struct hba_device {
struct ahci_hba *hba;
struct ahci_cmd_hdr *cmdlist;
struct dcdr *dcdr;
+ uint32_t nlba;
void *fra;
dev_t dev;
};
diff --git a/sys/include/dev/ic/nvmevar.h b/sys/include/dev/ic/nvmevar.h
index eab8b52..8dbc7b9 100644
--- a/sys/include/dev/ic/nvmevar.h
+++ b/sys/include/dev/ic/nvmevar.h
@@ -31,9 +31,11 @@
#define _IC_NVMEVAR_H_
#include <sys/types.h>
+#include <sys/cdefs.h>
/* Admin commands */
#define NVME_OP_CREATE_IOSQ 0x01
+#define NVME_OP_GET_LOGPAGE 0x02
#define NVME_OP_CREATE_IOCQ 0x05
#define NVME_OP_IDENTIFY 0x06
@@ -45,6 +47,67 @@
#define NVME_OP_WRITE 0x01
#define NVME_OP_READ 0x02
+/* Log page identifiers */
+#define NVME_LOGPAGE_SMART 0x02
+
+/*
+ * S.M.A.R.T health / information log
+ *
+ * See section 5.16.1.3, figure 207 of the
+ * NVMe base spec (rev 2.0a)
+ *
+ * @cwarn: Critical warning
+ * @temp: Composite tempature (kelvin)
+ * @avail_spare: Available spare (in percentage)
+ * @avail_spare_thr: Available spare threshold
+ * @percent_used: Estimate NVMe life used percentage
+ * @end_cwarn: Endurance group critical warning summary
+ * @data_units_read: Number of 512 byte data units read
+ * @data_units_written: Number of 512 byte data units written
+ * @host_reads: Number of host read commands completed
+ * @host_writes: Number of host write commands completed
+ * @ctrl_busy_time: Controller busy time
+ * @power_cycles: Number of power cycles
+ * @power_on_hours: Number of power on hours
+ * @unsafe_shutdowns: Number of unsafe shutdowns
+ * @media_errors: Media and data integrity errors
+ * @n_errlog_entries: Number of error log info entries
+ * @warning_temp_time: Warning composite tempature time
+ * @critical_comp_time: Critical composite tempature time
+ * @temp_sensor: Tempature sensor <n> data
+ * @temp1_trans_cnt: Tempature 1 transition count
+ * @temp2_trans_cnt: Tempature 2 transition count
+ * @temp1_total_time: Total time for tempature 1
+ * @temp2_total_time: Total time for tempature 2
+ */
+struct __packed nvme_smart_data {
+ uint8_t cwarn;
+ uint16_t temp;
+ uint8_t avail_spare;
+ uint8_t avail_spare_thr;
+ uint8_t percent_used;
+ uint8_t end_cwarn;
+ uint8_t reserved[25];
+ uint8_t data_units_read[16];
+ uint8_t data_units_written[16];
+ uint8_t host_reads[16];
+ uint8_t host_writes[16];
+ uint8_t ctrl_busy_time[16];
+ uint8_t power_cycles[16];
+ uint8_t power_on_hours[16];
+ uint8_t unsafe_shutdowns[16];
+ uint8_t media_errors[16];
+ uint8_t n_errlog_entries[16];
+ uint32_t warning_temp_time;
+ uint32_t critical_comp_time;
+ uint16_t temp_sensor[8];
+ uint32_t temp1_trans_cnt;
+ uint32_t temp2_trans_cnt;
+ uint32_t temp1_total_time;
+ uint32_t temp2_total_time;
+ uint8_t reserved1[280];
+};
+
struct nvme_identify_cmd {
uint8_t opcode;
uint8_t flags;
@@ -98,6 +161,26 @@ struct nvme_create_iosq_cmd {
uint64_t unused3[2];
};
+/* Get log page */
+struct nvme_get_logpage_cmd {
+ uint8_t opcode;
+ uint8_t flags;
+ uint16_t cid;
+ uint32_t nsid;
+ uint64_t unused[2];
+ uint64_t prp1;
+ uint64_t prp2;
+ uint8_t lid;
+ uint8_t lsp;
+ uint16_t numdl;
+ uint16_t numdu;
+ uint16_t lsi;
+ uint64_t lpo;
+ uint8_t unused1[3];
+ uint8_t csi;
+ uint32_t unused2;
+};
+
/* Read/write */
struct nvme_rw_cmd {
uint8_t opcode;
@@ -123,6 +206,7 @@ struct nvme_cmd {
struct nvme_identify_cmd identify;
struct nvme_create_iocq_cmd create_iocq;
struct nvme_create_iosq_cmd create_iosq;
+ struct nvme_get_logpage_cmd get_logpage;
struct nvme_rw_cmd rw;
};
};
diff --git a/sys/include/dev/pci/pci.h b/sys/include/dev/pci/pci.h
index a4de162..144b500 100644
--- a/sys/include/dev/pci/pci.h
+++ b/sys/include/dev/pci/pci.h
@@ -62,6 +62,7 @@ struct pci_device {
uint8_t pci_subclass;
uint8_t prog_if;
uint8_t hdr_type;
+ uint8_t pci_express : 1;
uint8_t pri_bus;
uint8_t sec_bus;
diff --git a/sys/include/dev/phy/e1000regs.h b/sys/include/dev/phy/e1000regs.h
new file mode 100644
index 0000000..7caceee
--- /dev/null
+++ b/sys/include/dev/phy/e1000regs.h
@@ -0,0 +1,119 @@
+/*
+ * 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.
+ */
+
+#ifndef _PHY_E1000_REGS_H_
+#define _PHY_E1000_REGS_H_
+
+#include <sys/types.h>
+#include <sys/param.h>
+
+/*
+ * E1000 register offsets
+ *
+ * XXX: Notes about reserve fields:
+ *
+ * - The `EERD' register is reserved and should NOT be touched
+ * for the 82544GC/EI card.
+ *
+ * - The `FLA' register is only usable for the 82541xx and
+ * 82547GI/EI cards, this is reserved and should NOT be
+ * touched on any other cards.
+ *
+ * - The `TXCW' and `RXCW' registers are reserved and should NOT
+ * be touched for the 82540EP/EM, 82541xx and 82547GI/EI cards.
+ *
+ * - The `LEDCTL' register is reserved and should NOT be touched
+ * for the 82544GC/EI card.
+ */
+#define E1000_CTL 0x00000 /* Control register */
+#define E1000_STATUS 0x00008 /* Status register */
+#define E1000_EECD 0x00010 /* EEPROM/flash control and data register */
+#define E1000_EERD 0x00014 /* EEPROM/flash read register */
+#define E1000_FLA 0x0001C /* EEPROM/flash read register */
+#define E1000_CTRL_EXT 0x00018 /* Extended device control register */
+#define E1000_MDIC 0x00020 /* PHY management data interface control register */
+#define E1000_FCAL 0x00028 /* Flow control low register */
+#define E1000_FCAH 0x0002C /* Flow control high register */
+#define E1000_FCT 0x00030 /* Flow control type register */
+#define E1000_VET 0x00038 /* VLAN ethertype register */
+#define E1000_FCTTV 0x00170 /* Flow control transmit timer value register */
+#define E1000_TXCW 0x00178 /* Transmit config word register */
+#define E1000_RXCW 0x00180 /* Receive config word register */
+#define E1000_LEDCTL 0x00E00 /* LED control register */
+
+/*
+ * Device control register (`ctl') bits
+ *
+ * See section 13.4.1 of the PCI/PCI-X Intel Gigabit
+ * Ethernet Controllers spec
+ *
+ * XXX: Notes about reserved bits:
+ *
+ * - The CTL.LRST bit is reserved and should NOT be touched
+ * for the 82540EP/EM, 82541xx, or 82547GI/EI cards.
+ */
+#define E1000_CTL_FD BIT(0) /* Full-duplex */
+#define E1000_CTL_LRST BIT(3) /* Link-reset */
+#define E1000_CTL_RST BIT(26) /* Device reset */
+
+/*
+ * EEPROM/flash control and data register (`eecd')
+ * bits
+ *
+ * See section 13.4.3 of the PCI/PCI-X Intel Gigabit
+ * Ethernet controller spec
+ */
+#define E1000_EECD_SK BIT(0) /* EEPROM clock input */
+#define E1000_EECD_CS BIT(1) /* EEPROM chip select */
+#define E1000_EECD_DI BIT(2) /* EEPROM data input */
+#define E1000_EECD_DO BIT(3) /* EEPROM data output */
+#define E1000_EECD_FWE BIT(4) /* EEPROM flash write enable ctl (4:5) */
+#define E1000_EECD_REQ BIT(6) /* Request EEPROM access */
+#define E1000_EECD_GNT BIT(7) /* Grant EEPROM access */
+#define E1000_EECD_PRES BIT(8) /* EEPROM present */
+#define E1000_EECD_SIZE BIT(9) /* EEPROM size (1024-bit [0], 4096-bit [1]) */
+#define E1000_EECD_TYPE BIT(13) /* EEPROM type (microwire [0], SPI [1]) */
+
+/*
+ * EEPROM read (`eerd') register bits
+ *
+ * See section 13.4.4 of the PCI/PCI-X Intel Gigabit
+ * Ethernet controller spec
+ */
+#define E1000_EERD_START BIT(0) /* Start read */
+#define E1000_EERD_DONE BIT(4) /* EEPROM read finished */
+
+/*
+ * EEPROM word addresses
+ */
+#define E1000_HWADDR0 0x00 /* Word 0 */
+#define E1000_HWADDR1 0x01 /* Word 1 */
+#define E1000_HWADDR2 0x02 /* Word 2 */
+
+#endif /* !_PHY_E1000_REGS_H_ */
diff --git a/sys/include/dev/phy/rt8139.h b/sys/include/dev/phy/rtl.h
index 21c7d54..f3178d0 100644
--- a/sys/include/dev/phy/rt8139.h
+++ b/sys/include/dev/phy/rtl.h
@@ -71,6 +71,9 @@
#define RT_AS_LPAR 0x68 /* Auto-negotiation link partner reg (16 bits) */
#define RT_AS_EXPANSION 0x6A /* Auto-negotiation expansion reg (16 bits) */
+#define RT_TXAD_N(N) (RT_TXADDR0 + (N))
+#define RT_TXSTATUS_N(N) (RT_TXSTATUS0 + ((N)))
+
/* Command register bits */
#define RT_BUFEN BIT(0) /* Buffer empty */
#define RT_TE BIT(2) /* Transmitter enable */
diff --git a/sys/include/dev/random/chacha20.h b/sys/include/dev/random/chacha20.h
new file mode 100644
index 0000000..d35702a
--- /dev/null
+++ b/sys/include/dev/random/chacha20.h
@@ -0,0 +1,47 @@
+/*
+ * 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 <stdint.h>
+#include <stddef.h>
+#include <string.h>
+
+#define ROTL(a,b) (((a) << (b)) | ((a) >> (32 - (b))))
+
+#define QR(a,b,c,d) \
+ a += b; d ^= a; d = ROTL(d, 16); \
+ c += d; b ^= c; b = ROTL(b, 12); \
+ a += b; d ^= a; d = ROTL(d, 8); \
+ c += d; b ^= c; b = ROTL(b, 7);
+
+void chacha20_init(uint32_t state[16], const uint8_t key[32],
+ const uint8_t nonce[12], uint32_t counter);
+
+void chacha20_block(uint32_t state[16], uint8_t out[64]);
+void chacha20_encrypt(uint32_t state[16], uint8_t *in, uint8_t *out, size_t len);
+
diff --git a/sys/include/dev/random/entropy.h b/sys/include/dev/random/entropy.h
new file mode 100644
index 0000000..34d86df
--- /dev/null
+++ b/sys/include/dev/random/entropy.h
@@ -0,0 +1,40 @@
+/*
+ * 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 <stdint.h>
+
+#define ENTROPY_POOL_SIZE 32
+
+struct entropy_pool {
+ uint8_t pool[ENTROPY_POOL_SIZE];
+ uint32_t entropy_bits;
+};
+
+void mix_entropy(struct entropy_pool *ep, const uint8_t *input,
+ size_t input_len, uint32_t input_entropy_bits);
diff --git a/sys/include/dev/random/siphash.h b/sys/include/dev/random/siphash.h
new file mode 100644
index 0000000..ecabb4a
--- /dev/null
+++ b/sys/include/dev/random/siphash.h
@@ -0,0 +1,34 @@
+/* <MIT License>
+ Copyright (c) 2013 Marek Majkowski <marek@popcount.org>
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ </MIT License>
+
+ Original location:
+ https://github.com/majek/csiphash/
+
+ Solution inspired by code from:
+ Samuel Neves (supercop/crypto_auth/siphash24/little)
+ djb (supercop/crypto_auth/siphash24/little2)
+ Jean-Philippe Aumasson (https://131002.net/siphash/siphash24.c)
+*/
+
+#include <stdint.h>
+
+uint64_t siphash24(const void *src, unsigned long src_sz, const char k[16]);
diff --git a/sys/include/dev/timer.h b/sys/include/dev/timer.h
index e54adcc..fe91323 100644
--- a/sys/include/dev/timer.h
+++ b/sys/include/dev/timer.h
@@ -69,6 +69,7 @@ struct timer {
const char *name; /* e.g "HPET" */
size_t(*calibrate)(void); /* Returns frequency, 0 for unspecified */
size_t(*get_time_usec)(void); /* Time since init (microseconds) */
+ size_t(*get_time_nsec)(void); /* Time since init (nanoseconds) */
size_t(*get_time_sec)(void); /* Time since init (seconds) */
int(*msleep)(size_t ms);
int(*usleep)(size_t us);
diff --git a/sys/include/dev/video/fbdev.h b/sys/include/dev/video/fbdev.h
index c80fd92..c9fec94 100644
--- a/sys/include/dev/video/fbdev.h
+++ b/sys/include/dev/video/fbdev.h
@@ -52,5 +52,6 @@ fbdev_get_index(const struct fbdev *fbdev, uint32_t x, uint32_t y)
}
struct fbdev fbdev_get(void);
+void fbdev_init_dev(void);
#endif /* !_DEV_FBDEV_H_ */