14
14
extern "C" {
15
15
#endif
16
16
17
+ /* IoBlock flags */
17
18
#define O_RDONLY (0x0001)
18
19
#define O_WRONLY (0x0002)
19
20
#define O_RDWR (0x0003)
@@ -26,6 +27,7 @@ extern "C" {
26
27
27
28
#define FSCAN 0x1000
28
29
30
+ /* "whence" for seek functions */
29
31
#ifndef SEEK_SET
30
32
#define SEEK_SET 0
31
33
#endif
@@ -37,13 +39,15 @@ extern "C" {
37
39
#endif
38
40
39
41
/* device types */
42
+ /* for DeviceDriver.type */
40
43
#define DEV_TYPE_CHAR (1 << 0) /* character device */
41
44
#define DEV_TYPE_TTY (1 << 1) /* TTY/console */
42
45
#define DEV_TYPE_BLOCK (1 << 2) /* block device */
43
46
#define DEV_TYPE_RAW (1 << 3) /* raw device that uses fs switch */
44
47
#define DEV_TYPE_FS (1 << 4)
45
48
46
49
/* device FIFO flags */
50
+ /* for device_fifo.flags */
47
51
#define DEV_FIFO_RAW (1 << 0) /* don't interpret special chars */
48
52
#define DEV_FIFO_STOPPED (1 << 1) /* stop output */
49
53
#define DEV_FIFO_BREAK (1 << 2) /* cntl-c raise console interrpt */
@@ -56,50 +60,51 @@ typedef struct st_device_fifo {
56
60
char buf [256 ]; // 0x0C - FIFO buffer.
57
61
} device_fifo ;
58
62
59
- #define M_FIFO_FLUSH (__fifo ) ((__fifo)->rd_ptr = (__fifo)->wr_ptr = (__fifo)->buf)
63
+ #define M_FIFO_PURGE (__fifo ) ((__fifo)->rd_ptr = (__fifo)->wr_ptr = (__fifo)->buf)
60
64
#define M_IS_FIFO_EMPTY (__fifo ) ((__fifo)->rd_ptr == (__fifo)->wr_ptr)
61
65
#define M_IS_FIFO_STOPPED (__fifo ) ((__fifo)->flags & DEV_FIFO_STOPPED)
62
66
#define stdin (0)
63
67
#define stdout (1)
64
68
65
69
/* sizeof() == 0x2C(44) */
66
70
typedef struct st_PS1_IoBlock {
67
- int flags ; // 0x00
68
- int dev_no ; // 0x04
69
- char * buf ; // 0x08 - address of the I/O buffer.
70
- uint32_t ccount ; // 0x0C - character count
71
- uint32_t cur_pos ; // 0x10 - current position in file.
72
- int fstype ; // 0x14 - type of file system.
73
- int errno ; // 0x18 - last "errno"
74
- struct st_FileSystemDriver * fsd ; // 0x1C - pointer to fsd
75
- uint32_t size ; // 0x20
76
- uint32_t head ; // 0x24
77
- uint32_t fd ; // 0x28 file descriptor
71
+ int flags ; // 0x00 - see IoBlock flags(TODO: fixme?)
72
+ int dev_no ; // 0x04 - ?
73
+ char * buf ; // 0x08 - address of the I/O buffer.
74
+ uint32_t ccount ; // 0x0C - character count
75
+ uint32_t cur_pos ; // 0x10 - current position in file.
76
+ int fstype ; // 0x14 - type of file system.
77
+ int errno ; // 0x18 - last "errno"
78
+ struct st_DeviceDriver * dd ; // 0x1C - pointer to fsd
79
+ uint32_t size ; // 0x20 - file size?
80
+ uint32_t head ; // 0x24 - ?
81
+ uint32_t fd ; // 0x28 file descriptor
78
82
} IoBlock ;
79
83
84
+ #warning "FIXME: add argument names to prototypes in DeviceDriver struct in fileio.h"
80
85
/* sizeof() == 0x50(80) */
81
- typedef struct st_FileSystemDriver {
82
- const char * name ; // 0x00 - pointer to unique name identifying file system .
83
- uint32_t modes ; // 0x04 -
86
+ typedef struct st_DeviceDriver {
87
+ const char * name ; // 0x00 - pointer to unique name identifying device .
88
+ uint32_t type ; // 0x04 - bitmask. see Device Types.
84
89
uint32_t block_size ; // 0x08 - size, in bytes, of a block.
85
- const char * desc ; // 0x0C - pointer to ASCII-Z description of file system .
86
- int (* init )(); // 0x10 - pointer to "init" function. Called by AddDevice()
87
- int (* open )(); // 0x14 - pointer to "open" function.
88
- int (* strategy )(); // 0x18 - pointer to "strategy" function.
89
- int (* close )(); // 0x1C - pointer to "close" function.
90
- int (* ioctl )(); // 0x20 - pointer to "ioctl" function.
91
- int (* read )(); // 0x24 - pointer to "read" function.
92
- int (* write )(); // 0x28 - pointer to "write" function.
93
- int (* delete )(); // 0x2C - pointer to "delete" function.
94
- int (* undelete )(); // 0x30 - pointer to "undelete" function.
90
+ const char * desc ; // 0x0C - pointer to ASCII-Z description of device .
91
+ int (* init )(IoBlock * iob ); // 0x10 - pointer to "init" function. Called by AddDevice()
92
+ int (* open )(IoBlock * iob , const char * fname , int mode ); // 0x14 - pointer to "open" function.
93
+ int (* strategy )(IoBlock * iob , int cmd ); // 0x18 - pointer to "strategy" function.
94
+ int (* close )(IoBlock * iob ); // 0x1C - pointer to "close" function.
95
+ int (* ioctl )(IoBlock * iob , int cmd , int param ); // 0x20 - pointer to "ioctl" function.
96
+ int (* read )(IoBlock * iob , void * p , int size ); // 0x24 - pointer to "read" function.
97
+ int (* write )(IoBlock * iob , const void * p , int size ); // 0x28 - pointer to "write" function.
98
+ int (* delete )(IoBlock * iob , const char * name ); // 0x2C - pointer to "delete" function.
99
+ int (* undelete )(IoBlock * iob , const char * name ); // 0x30 - pointer to "undelete" function.
95
100
int (* firstfile )(); // 0x34 - pointer to "firstfile" function.
96
101
int (* nextfile )(); // 0x38 - pointer to "nextfile" function.
97
102
int (* format )(); // 0x3C - pointer to "format" function.
98
- int (* chdir )(); // 0x40 - pointer to "cd" function.
99
- int (* rename )(); // 0x44 - pointer to "rename" function.
100
- int (* deinit )(); // 0x48 - pointer to "deinit" function. Called by RemDevice()
101
- int (* call15 )(); // 0x4C - pointer to "lseek" function.
102
- } FileSystemDriver ;
103
+ int (* chdir )(const char * path ); // 0x40 - pointer to "cd" function.
104
+ int (* rename )(const char * oldname , const char * newname ); // 0x44 - pointer to "rename" function.
105
+ int (* deinit )(IoBlock * iob ); // 0x48 - pointer to "deinit" function. Called by RemDevice()
106
+ int (* lseek )( IoBlock * iob , int pos , int whence ); // 0x4C - pointer to "lseek" function.
107
+ } DeviceDriver ;
103
108
104
109
typedef struct st_DirEntry {
105
110
char name [20 ]; // 0x00 - ASCII file name.
@@ -110,24 +115,13 @@ typedef struct st_DirEntry {
110
115
uint8_t system [4 ]; // 0x24 - ??? unused?
111
116
} DirEntry ;
112
117
113
- int AddDevice (const FileSystemDriver * fsd );
114
- int DelDevice (const char * fs_name );
118
+ int AddDevice (const DeviceDriver * dd );
119
+ int DelDevice (const char * dev_name );
115
120
116
- int open (const char * , uint32_t );
117
- int close (int );
118
- int lseek (int , int , int );
119
- int read (int , void * , int );
120
- int write (int , const void * , int );
121
- int ioctl (int , int , int );
121
+ #warning "FIXME: add argument names to prototypes in fileio.h"
122
122
DirEntry * firstfile (const char * , DirEntry * );
123
123
DirEntry * nextfile (DirEntry * );
124
124
125
- int erase (const char * );
126
- int undelete (const char * );
127
- int format (const char * );
128
- int rename (const char * , const char * );
129
- int chdir (const char * );
130
-
131
125
#ifdef __cplusplus
132
126
}
133
127
#endif
0 commit comments