Make PiSCSI always print to console if no handler is found for the file system, since this can cause a reboot loop.
Move PiStorm device SWREV out of debug output define check.
Silence loadseg debug message.
uint32_t address = *(uint32_t *)&(cc->payload[0]);
uint32_t length = cc->payload.size() - 4;
uint32_t address = *(uint32_t *)&(cc->payload[0]);
uint32_t length = cc->payload.size() - 4;
if (get_mapped_item_by_address(cfg, address) != -1) {
int32_t index = get_mapped_item_by_address(cfg, address);
uint8_t *map = &cfg->map_data[index][address - cfg->map_offset[index]];
if (get_mapped_item_by_address(cfg, address) != -1) {
int32_t index = get_mapped_item_by_address(cfg, address);
uint8_t *map = &cfg->map_data[index][address - cfg->map_offset[index]];
+
+uint8_t *get_mapped_data_pointer_by_address(struct emulator_config *cfg, uint32_t address) {
+ for (int i = 0; i < MAX_NUM_MAPPED_ITEMS; i++) {
+ if (cfg->map_type[i] == MAPTYPE_NONE || !cfg->map_data[i])
+ continue;
+ if (address >= cfg->map_offset[i] && address < cfg->map_high[i]) {
+ if (cfg->map_type[i] == MAPTYPE_RAM || cfg->map_type[i] == MAPTYPE_RAM_NOALLOC) {
+ return cfg->map_data[i] + (address - cfg->map_offset[i]);
+ } else {
+ return NULL;
+ }
+ }
+ }
+
+ return NULL;
+}
int handle_mapped_write(struct emulator_config *cfg, unsigned int addr, unsigned int value, unsigned char type);
int get_named_mapped_item(struct emulator_config *cfg, char *name);
int get_mapped_item_by_address(struct emulator_config *cfg, uint32_t address);
int handle_mapped_write(struct emulator_config *cfg, unsigned int addr, unsigned int value, unsigned char type);
int get_named_mapped_item(struct emulator_config *cfg, char *name);
int get_mapped_item_by_address(struct emulator_config *cfg, uint32_t address);
+uint8_t *get_mapped_data_pointer_by_address(struct emulator_config *cfg, uint32_t address);
void add_mapping(struct emulator_config *cfg, unsigned int type, unsigned int addr, unsigned int size, int mirr_addr, char *filename, char *map_id, unsigned int autodump);
unsigned int get_int(char *str);
#endif
void add_mapping(struct emulator_config *cfg, unsigned int type, unsigned int addr, unsigned int size, int mirr_addr, char *filename, char *map_id, unsigned int autodump);
unsigned int get_int(char *str);
#endif
- printf ("Loadseg begins.\n");
if (load_lseg(d->fd, &filesystems[piscsi_num_fs].binary_data, &filesystems[piscsi_num_fs].h_info, filesystems[piscsi_num_fs].relocs, d->block_size) != -1) {
filesystems[piscsi_num_fs].FS_ID = fhb->fhb_DosType;
filesystems[piscsi_num_fs].fhb = fhb;
if (load_lseg(d->fd, &filesystems[piscsi_num_fs].binary_data, &filesystems[piscsi_num_fs].h_info, filesystems[piscsi_num_fs].relocs, d->block_size) != -1) {
filesystems[piscsi_num_fs].FS_ID = fhb->fhb_DosType;
filesystems[piscsi_num_fs].fhb = fhb;
void handle_piscsi_write(uint32_t addr, uint32_t val, uint8_t type) {
int32_t r;
void handle_piscsi_write(uint32_t addr, uint32_t val, uint8_t type) {
int32_t r;
#ifndef PISCSI_DEBUG
if (type) {}
#endif
#ifndef PISCSI_DEBUG
if (type) {}
#endif
lseek64(d->fd, src, SEEK_SET);
}
lseek64(d->fd, src, SEEK_SET);
}
- r = get_mapped_item_by_address(cfg, piscsi_u32[2]);
- if (r != -1 && cfg->map_type[r] == MAPTYPE_RAM) {
+ map = get_mapped_data_pointer_by_address(cfg, piscsi_u32[2]);
+ if (map) {
DEBUG_TRIVIAL("[PISCSI-%d] \"DMA\" Read goes to mapped range %d.\n", val, r);
DEBUG_TRIVIAL("[PISCSI-%d] \"DMA\" Read goes to mapped range %d.\n", val, r);
- read(d->fd, cfg->map_data[r] + piscsi_u32[2] - cfg->map_offset[r], piscsi_u32[1]);
+ read(d->fd, map, piscsi_u32[1]);
}
else {
DEBUG_TRIVIAL("[PISCSI-%d] No mapped range found for read.\n", val);
}
else {
DEBUG_TRIVIAL("[PISCSI-%d] No mapped range found for read.\n", val);
lseek64(d->fd, src, SEEK_SET);
}
lseek64(d->fd, src, SEEK_SET);
}
- r = get_mapped_item_by_address(cfg, piscsi_u32[2]);
- if (r != -1) {
+ map = get_mapped_data_pointer_by_address(cfg, piscsi_u32[2]);
+ if (map) {
DEBUG_TRIVIAL("[PISCSI-%d] \"DMA\" Write comes from mapped range %d.\n", val, r);
DEBUG_TRIVIAL("[PISCSI-%d] \"DMA\" Write comes from mapped range %d.\n", val, r);
- write(d->fd, cfg->map_data[r] + piscsi_u32[2] - cfg->map_offset[r], piscsi_u32[1]);
+ write(d->fd, map, piscsi_u32[1]);
}
else {
DEBUG_TRIVIAL("[PISCSI-%d] No mapped range found for write.\n", val);
}
else {
DEBUG_TRIVIAL("[PISCSI-%d] No mapped range found for write.\n", val);
case PISCSI_CMD_DEBUGME:
piscsi_debugme(val);
break;
case PISCSI_CMD_DEBUGME:
piscsi_debugme(val);
break;
- case PISCSI_CMD_DRIVER: {
+ case PISCSI_CMD_DRIVER:
DEBUG("[PISCSI] Driver copy/patch called, destination address %.8X.\n", val);
DEBUG("[PISCSI] Driver copy/patch called, destination address %.8X.\n", val);
- int r = get_mapped_item_by_address(cfg, val);
+ r = get_mapped_item_by_address(cfg, val);
if (r != -1) {
uint32_t addr = val - cfg->map_offset[r];
uint8_t *dst_data = cfg->map_data[r];
if (r != -1) {
uint32_t addr = val - cfg->map_offset[r];
uint8_t *dst_data = cfg->map_data[r];
case PISCSI_CMD_NEXTPART:
DEBUG("[PISCSI] Switch partition %d -> %d\n", rom_cur_partition, rom_cur_partition + 1);
rom_cur_partition++;
case PISCSI_CMD_NEXTPART:
DEBUG("[PISCSI] Switch partition %d -> %d\n", rom_cur_partition, rom_cur_partition + 1);
rom_cur_partition++;
if (r != -1) {
uint32_t addr = val - cfg->map_offset[r];
struct DeviceNode *node = (struct DeviceNode *)(cfg->map_data[r] + addr);
if (r != -1) {
uint32_t addr = val - cfg->map_offset[r];
struct DeviceNode *node = (struct DeviceNode *)(cfg->map_data[r] + addr);
char *dosID = (char *)&rom_partition_dostype[rom_cur_partition];
char *dosID = (char *)&rom_partition_dostype[rom_cur_partition];
#endif
DEBUG("[PISCSI] Partition DOSType is %c%c%c/%d\n", dosID[0], dosID[1], dosID[2], dosID[3]);
for (i = 0; i < piscsi_num_fs; i++) {
#endif
DEBUG("[PISCSI] Partition DOSType is %c%c%c/%d\n", dosID[0], dosID[1], dosID[2], dosID[3]);
for (i = 0; i < piscsi_num_fs; i++) {
- DEBUG("[!!!PISCSI] Found no handler for file system!\n");
+ printf("[!!!PISCSI] Found no handler for file system %s!\n", dosID);
fs_found:;
DEBUG("[FS-HANDLER] Next: %d Type: %.8X\n", BE(node->dn_Next), BE(node->dn_Type));
DEBUG("[FS-HANDLER] Task: %d Lock: %d\n", BE(node->dn_Task), BE(node->dn_Lock));
fs_found:;
DEBUG("[FS-HANDLER] Next: %d Type: %.8X\n", BE(node->dn_Next), BE(node->dn_Type));
DEBUG("[FS-HANDLER] Task: %d Lock: %d\n", BE(node->dn_Task), BE(node->dn_Lock));
#ifdef DEBUG_PISTORM_DEVICE
#define DEBUG printf
#ifdef DEBUG_PISTORM_DEVICE
#define DEBUG printf
-#define PIDEV_SWREV 0x0105
-
static const char *op_type_names[4] = {
"BYTE",
"WORD",
static const char *op_type_names[4] = {
"BYTE",
"WORD",
#define DEBUG(...)
#endif
#define DEBUG(...)
#endif
+#define PIDEV_SWREV 0x0105
+
extern uint32_t pistorm_dev_base;
extern uint32_t do_reset;
extern uint32_t pistorm_dev_base;
extern uint32_t do_reset;