Karg
v0.2.0
The kernel of CargOS
dev.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
driver.h
>
4
#include <
utils/compiler.h
>
5
6
typedef
struct
{
7
const
driver_t
*
driver
;
8
u32
num
;
9
}
dev_t
;
10
11
#define make_dev(driver, num) ((dev_t){&(driver), num})
12
13
isize
dev_read
(
dev_t
dev,
u8
*buf,
usize
size);
14
isize
dev_write
(
dev_t
dev,
const
u8
*buf,
usize
size);
15
16
typedef
struct
{
17
const
char
*
name
;
18
usize
addr
;
19
u32
irq
;
20
u8
reg_size
;
21
}
dev_node_t
;
22
23
extern
const
dev_node_t
DEV_TABLE
[];
24
25
typedef
struct
{
26
const
char
*
name
;
27
const
char
*
compat
;
28
i32
(*init)(
const
dev_node_t
*node);
29
}
dev_init_t
;
30
31
#define dev_init(compat, func) \
32
section(.init.dev) \
33
used static const dev_init_t _DEV_INIT = {_MODULE_NAME, compat, func}
compiler.h
dev_write
isize dev_write(dev_t dev, const u8 *buf, usize size)
Definition:
dev.c:19
dev_read
isize dev_read(dev_t dev, u8 *buf, usize size)
Definition:
dev.c:13
DEV_TABLE
const dev_node_t DEV_TABLE[]
Definition:
virt.c:3
driver.h
dev_init_t
Definition:
dev.h:25
dev_init_t::compat
const char * compat
Definition:
dev.h:27
dev_init_t::name
const char * name
Definition:
dev.h:26
dev_node_t
Definition:
dev.h:16
dev_node_t::name
const char * name
Definition:
dev.h:17
dev_node_t::irq
u32 irq
Definition:
dev.h:19
dev_node_t::reg_size
u8 reg_size
Definition:
dev.h:20
dev_node_t::addr
usize addr
Definition:
dev.h:18
dev_t
Definition:
dev.h:6
dev_t::num
u32 num
Definition:
dev.h:8
dev_t::driver
const driver_t * driver
Definition:
dev.h:7
driver_t
Definition:
driver.h:5
isize
__INTPTR_TYPE__ isize
Definition:
types.h:29
i32
__INT32_TYPE__ i32
Definition:
types.h:15
usize
__UINTPTR_TYPE__ usize
Definition:
types.h:28
u8
__UINT8_TYPE__ u8
Definition:
types.h:3
u32
__UINT32_TYPE__ u32
Definition:
types.h:5
include
dev.h
Generated by
1.9.1