Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
Loading...
Searching...
No Matches
dev.h
Go to the documentation of this file.
1// Copyright (c) 2025 Mohammad Arfan
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19// SOFTWARE.
20
21#ifndef __HAL__BLOCK__BLOCK_H__
22#define __HAL__BLOCK__BLOCK_H__
23
24#include <type.h>
25
26#define DEV_MAJOR_MAX_COUNT 256
27#define DEV_MINOR_BITMAP_COUNT 32
28
29#define DEV_MAJOR_MEM 1 // /dev/mem, /dev/null, /dev/zero
30#define DEV_MAJOR_FD 2 // floppy
31#define DEV_MAJOR_HD 3 // IDE HDD
32#define DEV_MAJOR_TTY 4 // tty devices
33#define DEV_MAJOR_CONSOLE 5 // console
34#define DEV_MAJOR_LP 6 // parallel printer
35#define DEV_MAJOR_VCS 7 // virtual console
36#define DEV_MAJOR_SCSI_DISK 8 // SCSI/SATA disk
37#define DEV_MAJOR_MD 9 // ramdisk/md
38#define DEV_MAJOR_NET 10 // network misc
39
40#define DEV_MAJOR_CDROM 11 // ATAPI CD/DVD
41#define DEV_MAJOR_INPUT 12 // keyboard/mouse/input
42#define DEV_MAJOR_AUDIO 13 // audio devices
43#define DEV_MAJOR_USB 14 // generic USB
44#define DEV_MAJOR_FB 15 // framebuffer/gpu
45#define DEV_MAJOR_PTY 16 // pseudo terminal
46#define DEV_MAJOR_SERIAL 17 // serial/uart
47#define DEV_MAJOR_RTC 18 // rtc/timer
48#define DEV_MAJOR_NVME 19 // NVMe storage
49#define DEV_MAJOR_LOOP 20 // loopback block device
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55typedef char dev_name_t[128];
56
57enum {
59 DEV_OK = 1,
60};
61
62
63typedef struct cdev {
66 void* ops;
67
68 struct cdev* next;
69} __attribute__((aligned(64))) cdev_t;
70typedef cdev_t* cdev_ptr_t;
71
74
75#ifdef __cplusplus
76}
77#endif
78
79#endif // __HAL__BLOCK__BLOCK_H__
@ DEV_OK
Definition dev.h:59
@ ERR_DEV_OPS_NOT_IMPLEMENTED
Definition dev.h:58
cdev_ptr_t create_dev(void *ops, uint32_t major)
uint32_t minor
Definition dev.h:1
char dev_name_t[128]
Definition dev.h:55
uint32_t major
Definition dev.h:0
cdev_ptr_t retrieve_dev(uint32_t major, uint32_t minor)
cdev_t * cdev_ptr_t
Definition dev.h:70
void * ops
Definition dev.h:2
typedef __attribute__
Definition msi.c:47
Definition dev.h:63
void * ops
Definition dev.h:66
struct cdev * next
Definition dev.h:68
uint32_t major
Definition dev.h:64
uint32_t minor
Definition dev.h:65
unsigned int uint32_t
Definition type.h:19