mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-25 16:52:29 +00:00
feat(drivers): Implement Bochs VBE display adapter, VirtIO-Blk, VirtIO-Net, VirtIO-RNG, and HWMON CoreTemp sensors + 'sensors' CLI utility
This commit is contained in:
1 parent
cfc122dda6
commit
7c620e86e7
14 files changed
+466
-1
No files matched your search
@@ -0,0 +1,41 @@
|
||||
#ifndef _DRIVERS_BOCHS_H
|
||||
#define _DRIVERS_BOCHS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define VBE_DISPI_IOPORT_INDEX 0x01CE
|
||||
#define VBE_DISPI_IOPORT_DATA 0x01CF
|
||||
|
||||
#define VBE_DISPI_INDEX_ID 0x0
|
||||
#define VBE_DISPI_INDEX_XRES 0x1
|
||||
#define VBE_DISPI_INDEX_YRES 0x2
|
||||
#define VBE_DISPI_INDEX_BPP 0x3
|
||||
#define VBE_DISPI_INDEX_ENABLE 0x4
|
||||
#define VBE_DISPI_INDEX_BANK 0x5
|
||||
#define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
|
||||
#define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
|
||||
#define VBE_DISPI_INDEX_X_OFFSET 0x8
|
||||
#define VBE_DISPI_INDEX_Y_OFFSET 0x9
|
||||
|
||||
#define VBE_DISPI_DISABLED 0x00
|
||||
#define VBE_DISPI_ENABLED 0x01
|
||||
#define VBE_DISPI_LFB_ENABLED 0x40
|
||||
#define VBE_DISPI_NOCLEARMEM 0x80
|
||||
|
||||
typedef struct {
|
||||
uint32_t current_width;
|
||||
uint32_t current_height;
|
||||
uint32_t current_bpp;
|
||||
uint64_t lfb_phys_addr;
|
||||
uint16_t vbe_version;
|
||||
bool available;
|
||||
} bochs_vbe_info_t;
|
||||
|
||||
bool bochs_vbe_init(void);
|
||||
bool bochs_vbe_is_available(void);
|
||||
int bochs_vbe_set_mode(uint32_t width, uint32_t height, uint32_t bpp);
|
||||
const bochs_vbe_info_t* bochs_vbe_get_info(void);
|
||||
|
||||
#endif // _DRIVERS_BOCHS_H
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef _DRIVERS_HWMON_H
|
||||
#define _DRIVERS_HWMON_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct {
|
||||
char chip_name[32];
|
||||
int32_t cpu_temp_celsius;
|
||||
int32_t ambient_temp_celsius;
|
||||
uint32_t fan_rpm;
|
||||
uint32_t vcore_millivolts;
|
||||
uint32_t v12_millivolts;
|
||||
uint32_t v5_millivolts;
|
||||
bool initialized;
|
||||
} hwmon_data_t;
|
||||
|
||||
void hwmon_init(void);
|
||||
void hwmon_refresh(void);
|
||||
const hwmon_data_t* hwmon_get_data(void);
|
||||
|
||||
#endif // _DRIVERS_HWMON_H
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef _DRIVERS_VIRTIO_BLK_H
|
||||
#define _DRIVERS_VIRTIO_BLK_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define VIRTIO_BLK_T_IN 0
|
||||
#define VIRTIO_BLK_T_OUT 1
|
||||
#define VIRTIO_BLK_T_FLUSH 4
|
||||
#define VIRTIO_BLK_T_GET_ID 8
|
||||
|
||||
typedef struct {
|
||||
uint32_t type;
|
||||
uint32_t reserved;
|
||||
uint64_t sector;
|
||||
} __attribute__((packed)) virtio_blk_req_header_t;
|
||||
|
||||
typedef struct {
|
||||
char serial[20];
|
||||
uint64_t capacity_sectors;
|
||||
uint32_t blk_size;
|
||||
uint16_t queue_size;
|
||||
bool initialized;
|
||||
} virtio_blk_info_t;
|
||||
|
||||
bool virtio_blk_init(void);
|
||||
bool virtio_blk_is_detected(void);
|
||||
const virtio_blk_info_t* virtio_blk_get_info(void);
|
||||
int virtio_blk_read(uint64_t sector, uint32_t count, void* buffer);
|
||||
int virtio_blk_write(uint64_t sector, uint32_t count, const void* buffer);
|
||||
|
||||
#endif // _DRIVERS_VIRTIO_BLK_H
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef _DRIVERS_VIRTIO_NET_H
|
||||
#define _DRIVERS_VIRTIO_NET_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct {
|
||||
uint8_t flags;
|
||||
uint8_t gso_type;
|
||||
uint16_t hdr_len;
|
||||
uint16_t gso_size;
|
||||
uint16_t csum_start;
|
||||
uint16_t csum_offset;
|
||||
} __attribute__((packed)) virtio_net_hdr_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t mac[6];
|
||||
uint16_t status;
|
||||
uint16_t max_virtqueue_pairs;
|
||||
uint16_t mtu;
|
||||
bool initialized;
|
||||
} virtio_net_info_t;
|
||||
|
||||
bool virtio_net_init(void);
|
||||
bool virtio_net_is_detected(void);
|
||||
void virtio_net_get_mac(uint8_t* mac_out);
|
||||
int virtio_net_send_packet(const uint8_t* packet, uint16_t length);
|
||||
|
||||
#endif // _DRIVERS_VIRTIO_NET_H
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef _DRIVERS_VIRTIO_RNG_H
|
||||
#define _DRIVERS_VIRTIO_RNG_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
bool virtio_rng_init(void);
|
||||
bool virtio_rng_is_detected(void);
|
||||
int virtio_rng_get_random_bytes(void* buf, size_t len);
|
||||
|
||||
#endif // _DRIVERS_VIRTIO_RNG_H
|
||||
Reference in new issue
Block a user