summaryrefslogtreecommitdiffstats
path: root/sw/z80/kernel/include/sio.h
blob: 2efd7061b3ea607b59df34d83e28287d3db916c7 (plain)
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
#ifndef SIO_H
#define SIO_H

#include "types.h"

#define SIO_PORT_0 0x0
#define SIO_PORT_1 0x1
#define SIO_PORT_2 0x2
#define SIO_PORT_3 0x3
#define SIO_PORT_4 0x4
#define SIO_PORT_5 0x5
#define SIO_PORT_6 0x6
#define SIO_PORT_7 0x7

/* current port in use */
extern uint8_t      sio_port;

/* current seek in the device */
extern devsize_t    sio_seek;

struct dev_buffer
{
   // TODO, bytes needed to the device buffer interface
};

/* points to the buffers mapped in the I/O space */
/* to be defined precisely in assemly */
extern volatile struct dev_buffer sio_buffers[8];

/* initialize serial interface */
void sio_init();

/* syscall: read one byte from the current device */
uint8_t sio_recv();
/* syscall: write one byte into the current device */
void sio_send(uint8_t value);

/* read n bytes from the current port */
size_t sio_read(void *buffer, size_t n);
/* write n bytes into the current port */
int8_t sio_write(const void *buffer, size_t n);

#endif