My Project
Loading...
Searching...
No Matches
block.c
Go to the documentation of this file.
1/*
2 * PROJECT: MatanelOS Kernel
3 * LICENSE: NONE
4 * PURPOSE: Block Device Abstraction Driver Implementation
5 */
6
7#include "block.h"
8#include "../../includes/me.h"
9#include "../../includes/mg.h"
10
11#define MAX_BLK_DEV 32 // AHCI is a maximum of 32, anymore than that and we bugcheck.
12
13static BLOCK_DEVICE* devices[MAX_BLK_DEV];
15static int device_count = 0;
16
18 // print the index we’re about to use and the device pointer
19#ifdef DEBUG
20 gop_printf(0xFFFFFF00, "Registering block #%d at %llx\n", device_count, (unsigned long long)(uintptr_t)dev);
21#endif
22 if (device_count < MAX_BLK_DEV) {
23 devices[device_count++] = dev;
24 }
25 else {
26 // too many!
28 }
29}
30
31
33 if (index < 0 || index >= device_count) { return NULL; }
34 return devices[index];
35}
#define MAX_BLK_DEV
Definition block.c:11
void register_block_device(BLOCK_DEVICE *dev)
Definition block.c:17
BLOCK_DEVICE * get_block_device(int index)
Definition block.c:32
struct _BLOCK_DEVICE BLOCK_DEVICE
NORETURN void MeBugCheck(IN enum _BUGCHECK_CODES BugCheckCode)
Definition bugcheck.c:214
GOP_PARAMS gop_local
Definition gop.c:247
struct _GOP_PARAMS GOP_PARAMS
void gop_printf(uint32_t color, const char *fmt,...)
Definition gop.c:694
@ BLOCK_DEVICE_LIMIT_REACHED
Definition me.h:92