23 typedef unsigned char BYTE;
25 #define POKE(a,d) *(BYTE*)(a) = (d)
26 #define PEEK(a) (*(BYTE*)(a))
28 #define HOSTFSR0 0xD0FEU
29 #define HOSTFSR1 0xD0FFU
33 #define HOSTFS_OVERWRITE 1
34 #define HOSTFS_WRITE 2
42 static BYTE hostfs_open (
BYTE channel,
const char *filename,
BYTE mode )
64 static BYTE hostfs_close (
BYTE channel )
71 static int hostfs_read (
BYTE channel,
void *buffer_spec,
int num )
74 BYTE *buffer = buffer_spec;
76 while (numread < num) {
91 static int hostfs_write (
BYTE channel,
void *buffer_spec,
int num )
94 BYTE *buffer = buffer_spec;
96 while (numwrite < num) {
108 static const char *TEST_FILE_NAME =
"testfile";
110 static BYTE buffer[256];
124 printf(
"Trying to open file: %s\n", TEST_FILE_NAME);
126 printf(
"Could not open hostfs file!\n");
127 printf(
"Continue with test #2\n");
130 printf(
"OK, file is open\n");
131 ret = hostfs_read(2, buffer,
sizeof buffer);
132 printf(
"File read returned with = %d\n", ret);
135 printf(
"Dumping read data ...\n");
138 putchar(buffer[n++]);
142 printf(
"Closing file\n");
148 printf(
"Test#2: dump dir to dirfile\n");
151 printf(
"Cannot open file $\n");
155 printf(
"Cannot create file dirlist\n");
159 int r = hostfs_read(3, buffer,
sizeof buffer);
160 printf(
"Read retval: %d\n",
r);
162 printf(
"I/O error while reading $\n");
169 if (hostfs_write(4, buffer,
r) !=
r) {
170 printf(
"Error writing file dirlist\n");