10#define NEWLIB_PORT_AWARE
14#include "iomanx_irx.h"
15#include "filexio_irx.h"
17#include "bdmfs_fatfs_irx.h"
18#include "ramdisk_bd_irx.h"
20extern int kputs(
char *s);
24static void expect(
const char *name,
int ok)
26 printf(
"driver-blockdev: [%s] %s\n", ok ?
"PASS" :
"FAIL", name);
31static int load(
const char *name,
void *buf,
unsigned int size)
36 printf(
"driver-blockdev: %s id=%d ret=%d\n", name,
id, ret);
37 return id > 0 && ret != 1;
40static int mounted(
const char *path)
42 int fd = fileXioDopen(path);
50static int read_file(
const char *path,
char *buf,
int size)
52 int fd = fileXioOpen(path, FIO_O_RDONLY);
57 n = fileXioRead(fd, buf, size - 1);
66 static const char hello[] =
"hello from the ramdisk\n";
67 static const char note[] =
"written by the EE through fileXio\n";
74 load(
"iomanx", iomanx_irx, size_iomanx_irx);
75 load(
"filexio", filexio_irx, size_filexio_irx);
77 load(
"bdm", bdm_irx, size_bdm_irx);
78 load(
"bdmfs_fatfs", bdmfs_fatfs_irx, size_bdmfs_fatfs_irx);
79 expect(
"ramdisk_bd loads and stays resident", load(
"ramdisk_bd", ramdisk_bd_irx, size_ramdisk_bd_irx));
81 for (
int i = 0; i < 50 && !mounted(
"ram0:/"); i++)
83 expect(
"ram0: mounted", mounted(
"ram0:/"));
85 n = read_file(
"ram0:/HELLO.TXT", buf,
sizeof(buf));
86 printf(
"driver-blockdev: HELLO.TXT read=%d\n", n);
87 expect(
"HELLO.TXT holds the seeded text", n == (
int)strlen(hello) && strcmp(buf, hello) == 0);
89 fd = fileXioOpen(
"ram0:/NOTE.TXT", FIO_O_WRONLY | FIO_O_CREAT | FIO_O_TRUNC, 0666);
90 n = fd >= 0 ? fileXioWrite(fd, (
void *)note, strlen(note)) : fd;
93 expect(
"NOTE.TXT written", n == (
int)strlen(note));
95 n = read_file(
"ram0:/NOTE.TXT", buf,
sizeof(buf));
96 expect(
"NOTE.TXT reads back the same bytes", n == (
int)strlen(note) && strcmp(buf, note) == 0);
98 n = read_file(
"ram0:/MISSING.TXT", buf,
sizeof(buf));
99 expect(
"a missing file fails to open", n < 0);
101 kputs(failures ?
"driver-blockdev: FAIL\n" :
"driver-blockdev: PASS\n");
102 printf(
"[ps2rig] exit=%d\n", failures ? 1 : 0);
int SifExecModuleBuffer(void *ptr, u32 size, u32 arg_len, const char *args, int *mod_res)
int sbv_patch_disable_prefix_check(void)
int sbv_patch_enable_lmb(void)