/** * open_buffer - function to open a direct-access buffer * @secondary: secondary address used * * This function is called when the computer wants to open a direct * access buffer (#). */ static void open_buffer(uint8_t secondary) { buffer_t *buf,*prev; uint8_t count; if (command_length == 3 && command_buffer[1] == '#') { /* Open a large buffer */ count = command_buffer[2] - '0'; if (count == 0) return; /* Allocate a chain of linked buffers */ buf = alloc_linked_buffers(count); if (buf == NULL) return; do { buf->secondary = BUFFER_SEC_CHAIN - secondary; buf->refill = directbuffer_refill; buf->cleanup = largebuffer_cleanup; buf->read = 1; buf->lastused = 255; stick_buffer(buf); mark_write_buffer(buf); prev = buf; buf = buf->pvt.buffer.next; } while (buf != NULL); prev->sendeoi = 1; buf = prev->pvt.buffer.first; /* Set the first buffer as active by using the real secondary */ buf->secondary = secondary; } else { /* Normal buffer request */ // FIXME: This command can specify a specific buffer number. buf = alloc_buffer(); if (!buf) return; buf->secondary = secondary; buf->read = 1; buf->position = 1; /* Sic! */ buf->lastused = 255; buf->sendeoi = 1; buf->pvt.buffer.size = 1; /* directbuffer_refill is used to check for # buffers in iec.c */ buf->refill = directbuffer_refill; buf->pvt.buffer.first = buf; mark_write_buffer(buf); stick_buffer(buf); } return; }
static void eefs_open_write(path_t *path, cbmdirent_t *dent, uint8_t type, buffer_t *buf, uint8_t append) { eefs_error_t res; repad_filename(dent->name); if (append) { res = eepromfs_open(dent->name, &buf->pvt.eefh, EEFS_MODE_APPEND); } else { res = eepromfs_open(dent->name, &buf->pvt.eefh, EEFS_MODE_WRITE); } translate_error(res); if (res != EEFS_ERROR_OK) return; /* set up buffer fields for writing */ mark_write_buffer(buf); buf->position = 2; buf->lastused = 2; buf->data[2] = 0x0d; buf->refill = eefs_refill_write; buf->cleanup = eefs_cleanup_write; }