We can't just use tmpbuf because there might not be a free buffer and we'd
then get into a mess recursing through our I/O subystem. Instead grab a bit
of spare high memory for the moment.
Once the buffer reclaim logic is added we will turn discard and friends into
buffers but keep the last 512 bytes before FFFF as a bounce buffer that drivers
can share.
(FFFF itself is slot switching so magic and reserved)
blk_op.blkdev->driver_data |= FLAG_CACHE_DIRTY;
/* Shortcut: this range can only occur for a user mode I/O */
if (addr >= (uint8_t *)0x3E00U && addr < (uint8_t *)0x8000U) {
- blk_op.addr = tmpbuf();
+ /* We can't just use tmpbuf because the buffer might be dirty which would
+ trigger a recursive I/O and then badness happens */
+ blk_op.addr = bouncebuffer;
blk_op.is_user = 0;
// kprintf("bounced do_ide_xfer %p %x:", addr, mask);
if (blk_op.is_read) {
if (do_ide_xfer(mask))
goto fail;
}
- tmpfree(blk_op.addr);
// kprintf("bounced done.\n");
blk_op.addr = addr;
blk_op.is_user = old_user;
#include <kdata.h>
#include <printf.h>
#include <devtty.h>
+#include <msx.h>
/* These are set by the msx startup asm code */
extern uint16_t vdpport;
uint16_t ramtop = 0xC000;
uint8_t machine_type;
uint8_t vdptype;
+uint8_t *bouncebuffer;
void platform_idle(void)
{
void platform_discard(void)
{
- /* Until we tackle the buffers */
+ /* Until we tackle the buffers. When we do we will reserve 512 bytes
+ at the end (probably FDFE-FFFE (FFFF being magic)) */
+ bouncebuffer = (uint8_t *)0xFD00; /* Hack for now */
}
extern void copy_vectors(void);
+extern uint8_t *bouncebuffer;
+
#endif