attached BaS disk i/o routines. EmuTOS does not seem to pick them up yet

This commit is contained in:
Markus Fröschle
2013-05-11 09:54:37 +00:00
parent 62c264975f
commit ed2c1939e9
3 changed files with 28 additions and 11 deletions

View File

@@ -84,12 +84,7 @@ typedef struct _BPB
/* a riddle: how do you typedef a function pointer to a function that returns its own type? ;) */ /* a riddle: how do you typedef a function pointer to a function that returns its own type? ;) */
typedef void* (*xhdi_call_fun)(int xhdi_fun, ...); typedef void* (*xhdi_call_fun)(int xhdi_fun, ...);
struct XHDICALL_args extern unsigned long xhdi_call(uint16_t *stack);
{
uint16_t opcode;
};
extern unsigned long xhdi_call(struct XHDICALL_args *stack);
extern xhdi_call_fun xhdi_sd_install(xhdi_call_fun old_vector) __attribute__((__interrupt__)); extern xhdi_call_fun xhdi_sd_install(xhdi_call_fun old_vector) __attribute__((__interrupt__));

View File

@@ -27,9 +27,9 @@
#include "bas_printf.h" #include "bas_printf.h"
unsigned long xhdi_call(struct XHDICALL_args *stack) unsigned long xhdi_call(uint16_t *stack)
{ {
uint16_t opcode = stack->opcode; uint16_t opcode = *stack;
switch (opcode) switch (opcode)
{ {

View File

@@ -26,13 +26,14 @@
#include "xhdi_sd.h" #include "xhdi_sd.h"
#include "bas_printf.h" #include "bas_printf.h"
#include "bas_string.h" #include "bas_string.h"
#include "diskio.h"
#define DRIVER_VERSION 0x130 #define DRIVER_VERSION 0x130
static BPB sd_bpb[4]; /* space for four partitions on SD card */ static BPB sd_bpb[4]; /* space for four partitions on SD card */
static xhdi_call_fun old_vector = NULL; static xhdi_call_fun old_vector = NULL;
extern xhdi_call_fun xhdi_vec; extern uint32_t xhdi_vec(uint16_t *stack);
__attribute__((__interrupt__)) xhdi_call_fun xhdi_sd_install(xhdi_call_fun ov) __attribute__((__interrupt__)) xhdi_call_fun xhdi_sd_install(xhdi_call_fun ov)
{ {
@@ -42,6 +43,7 @@ __attribute__((__interrupt__)) xhdi_call_fun xhdi_sd_install(xhdi_call_fun ov)
__asm__ __volatile__ ( __asm__ __volatile__ (
"move.l %[xhdi_call],d1\n\t" "move.l %[xhdi_call],d1\n\t"
"move.l d1,(sp)\n\t" /* FIXME: dirty overwrite of saved register on stack with return value */ "move.l d1,(sp)\n\t" /* FIXME: dirty overwrite of saved register on stack with return value */
"move.l d1,8(sp)\n\t"
: /* output */ : /* output */
: [xhdi_call]"g"(xhdi_vec) : [xhdi_call]"g"(xhdi_vec)
: "d1","memory"); : "d1","memory");
@@ -105,11 +107,18 @@ uint32_t xhdi_drivemap(void)
return map; return map;
} }
#define MY_MAJOR 255
#define MY_MINOR 0
uint32_t xhdi_inquire_device(uint16_t bios_device, uint16_t *major, uint16_t *minor, uint32_t xhdi_inquire_device(uint16_t bios_device, uint16_t *major, uint16_t *minor,
uint32_t *start_sector, /* BPB */ void *bpb) uint32_t *start_sector, /* BPB */ void *bpb)
{ {
xprintf("xhdi_inquire_device() called\r\n"); xprintf("xhdi_inquire_device() called\r\n");
return ERROR; if (major != NULL) *major = MY_MAJOR;
if (minor != NULL) *minor = MY_MINOR;
if (start_sector != NULL) *start_sector = 0;
return E_OK;
} }
uint32_t xhdi_inquire_driver(uint16_t bios_device, char *name, char *version, uint32_t xhdi_inquire_driver(uint16_t bios_device, char *name, char *version,
@@ -142,7 +151,19 @@ uint32_t xhdi_read_write(uint16_t major, uint16_t minor, uint16_t rwflag,
{ {
xprintf("xhdi_read_write() called: major = %x, minor = %x, rwflag = %x, \r\nrecno = %lx, count = %lx, buf = %p\r\n", xprintf("xhdi_read_write() called: major = %x, minor = %x, rwflag = %x, \r\nrecno = %lx, count = %lx, buf = %p\r\n",
major, minor, rwflag, recno, count, buf); major, minor, rwflag, recno, count, buf);
return EUNDEV;
if (major == MY_MAJOR && minor == MY_MINOR)
{
if (rwflag & 1) /* write */
{
disk_write(0, buf, recno, count);
}
else if (rwflag & 1 == 0) /* read */
{
disk_read(0, buf, recno, count);
}
}
return E_OK;
} }
uint32_t xhdi_inquire_target2(uint16_t major, uint16_t minor, uint32_t *block_size, uint32_t xhdi_inquire_target2(uint16_t major, uint16_t minor, uint32_t *block_size,
@@ -159,6 +180,7 @@ uint32_t xhdi_inquire_device2(uint16_t bios_device, uint16_t *major, uint16_t *m
if (bios_device == 'S' - 'A') if (bios_device == 'S' - 'A')
{ {
return E_OK; return E_OK;
} }
return EUNDEV; return EUNDEV;