kernel: remove some unescessary inits

This commit is contained in:
Matheus
2025-07-23 18:21:10 -03:00
parent 819551330b
commit 98be724c65
5 changed files with 9 additions and 31 deletions
-4
View File
@@ -92,18 +92,14 @@ void kernel_entry() {
tty_init(); tty_init();
pty_init(); pty_init();
netdev_init();
loopback_init(); loopback_init();
arp_init(); arp_init();
ipv4_init(); ipv4_init();
udp_init();
tcp_init(); tcp_init();
block_init();
pseudodevices_init(); pseudodevices_init();
arch_e9_initdev(); arch_e9_initdev();
keyboard_init(); keyboard_init();
mouse_init();
arch_ps2_init(); arch_ps2_init();
fb_init(); fb_init();
nvme_init(); nvme_init();
+4 -7
View File
@@ -52,9 +52,11 @@ typedef struct {
#define MBR_TYPE_FREE 0 #define MBR_TYPE_FREE 0
#define MBR_TYPE_GPT 0xee #define MBR_TYPE_GPT 0xee
static mutex_t tablemutex;
static int currentid = 1; static int currentid = 1;
static hashtable_t blocktable;
static MUTEX_DEFINE(tablemutex);
HASHTABLE_DEFINE_STATIC(blocktable, 10);
static blockdesc_t *getdesc(int id) { static blockdesc_t *getdesc(int id) {
void *ret; void *ret;
@@ -307,8 +309,3 @@ void block_register(blockdesc_t *desc, char *name) {
__assert(registerdesc(permdesc, name) == 0); __assert(registerdesc(permdesc, name) == 0);
} }
void block_init() {
hashtable_init(&blocktable, 100);
MUTEX_INIT(&tablemutex);
}
+2 -8
View File
@@ -44,8 +44,8 @@ void mouse_packet(mouse_t *mouse, mousepacket_t *packet) {
interrupt_loweripl(oldipl); interrupt_loweripl(oldipl);
} }
static hashtable_t mousetable; HASHTABLE_DEFINE_STATIC(mousetable, 10);
static mutex_t tablelock; static MUTEX_DEFINE(tablelock);
static mouse_t* getmouse(int mouse) { static mouse_t* getmouse(int mouse) {
void *mousep = NULL; void *mousep = NULL;
@@ -181,9 +181,3 @@ mouse_t *mouse_new() {
++currentnum; ++currentnum;
return mouse; return mouse;
} }
void mouse_init() {
MUTEX_INIT(&tablelock);
__assert(hashtable_init(&mousetable, 20) == 0);
}
+2 -7
View File
@@ -5,8 +5,8 @@
#include <string.h> #include <string.h>
#include <logging.h> #include <logging.h>
static hashtable_t nametable; HASHTABLE_DEFINE_STATIC(nametable, 10);
static mutex_t tablelock; static MUTEX_DEFINE(tablelock);
static devops_t devops = {0}; static devops_t devops = {0};
@@ -37,8 +37,3 @@ netdev_t *netdev_getdev(char *name) {
MUTEX_RELEASE(&tablelock); MUTEX_RELEASE(&tablelock);
return netdev; return netdev;
} }
void netdev_init() {
__assert(hashtable_init(&nametable, 10) == 0);
MUTEX_INIT(&tablelock);
}
+1 -5
View File
@@ -30,7 +30,7 @@ typedef struct {
#define ALLOC_RANGE_START 50000 #define ALLOC_RANGE_START 50000
#define ALLOC_RANGE_END 60000 #define ALLOC_RANGE_END 60000
static socket_t *ports[65536]; static socket_t *ports[65536];
static spinlock_t portlock; static SPINLOCK_DEFINE(portlock);
int udp_sendpacket(iovec_iterator_t *iovec_iterator, size_t size, uint32_t ip, uint16_t srcport, uint16_t dstport, netdev_t *broadcastnetdev) { int udp_sendpacket(iovec_iterator_t *iovec_iterator, size_t size, uint32_t ip, uint16_t srcport, uint16_t dstport, netdev_t *broadcastnetdev) {
void *newbuff = alloc(size + sizeof(udpframe_t)); void *newbuff = alloc(size + sizeof(udpframe_t));
@@ -56,10 +56,6 @@ int udp_sendpacket(iovec_iterator_t *iovec_iterator, size_t size, uint32_t ip, u
return error; return error;
} }
void udp_init() {
SPINLOCK_INIT(portlock);
}
int udp_allocport(socket_t *socket, uint16_t *port) { int udp_allocport(socket_t *socket, uint16_t *port) {
bool intstate = interrupt_set(false); bool intstate = interrupt_set(false);
spinlock_acquire(&portlock); spinlock_acquire(&portlock);