SayoriOS 0.3.3

cards.c
1 #include "common.h"
2 #include "net/cards.h"
3 #include "mem/vmm.h"
4
5 netcard_entry_t** netcards_list = 0;
6 size_t netcards_list_capacity = 0;
7 size_t netcards_count = 0;
8
9 void netcards_list_init() {
10 netcards_list_capacity = 1;
11
12 netcards_list = kcalloc(netcards_list_capacity, sizeof(netcard_entry_t*));
13 }
14
15 void netcard_add(netcard_entry_t *card) {
16 netcards_list_capacity++;
17 netcards_list = krealloc(netcards_list, sizeof(netcard_entry_t*) * netcards_list_capacity);
18
19 netcards_list[netcards_count++] = card;
20 }
21
22 size_t netcards_get_count() {
23 return netcards_count;
24 }
25
26 netcard_entry_t* netcard_get(size_t index) {
27 if(index >= netcards_count)
28 return 0;
29
30 return netcards_list[index];
31 }
common.h
Основные определения ядра
netcard_entry_t
Definition: cards.h:5