os4ec /Chapter_07_Threads/00_Start/kernel/devices.h

Language C/C++ Header Lines 51
MD5 Hash 724d551d7a1fdd08d98ec5ef1999b3c5
Repository https://github.com/l30nard0/os4ec.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*! Devices - common interface */

#pragma once

#include <lib/types.h>

/*! syscall wrappers -------------------------------------------------------- */

int sys__device_open ( char *dev_name, void **dev );
int sys__device_close ( void *dev );
int sys__device_send ( void *data, size_t size, int flags, void *dev );
int sys__device_recv ( void *data, size_t size, int flags, void *dev );
int sys__set_default_stdin ( char *dev_name, void **dev );
int sys__set_default_stdout ( char *dev_name, void **dev );

#ifndef _KERNEL_

typedef void kdevice_t;

#else /* _KERNEL_ */

#include <lib/list.h>
#include <devices/devices.h>

/*! Kernel device object */
typedef struct _kdevice_t_
{
	device_t dev;

	int open;

	list_h list; /* all devices are in list */
}
kdevice_t;

/* interface */
int k_devices_init ();
kdevice_t *k_device_add ( device_t *kdev );
int k_device_init ( kdevice_t *kdev, int flags, void *params, void *callback );
int k_device_remove ( kdevice_t *kdev );

kdevice_t *k_device_open ( char *name );
void k_device_close ( kdevice_t *kdev );

int k_device_send ( void *data, size_t size, int flags, kdevice_t *kdev );
int k_device_recv ( void *data, size_t size, int flags, kdevice_t *kdev );

/* include device headers */
#include <arch/devices.h>

#endif /* _KERNEL_ */
Back to Top