void init_ata() { // First, check for a floating bus (no drives attached) uint8_t pri_status = inb(PRIMARY_BASE + COM_STAT); uint8_t sec_status = inb(SECONDARY_BASE + COM_STAT); bool primary_floating = false; bool secondary_floating = false; if (pri_status == 0xFF) primary_floating = true; if (sec_status == 0xFF) secondary_floating = true; // Both buses are floating if (primary_floating && secondary_floating) { term_puts("No drives attached! What's going on?"); return; } // Non-0xFF values are not definitive; we need to do some more checks check_drive(PRIMARY_BASE, SEL_MASTER); check_drive(PRIMARY_BASE, SEL_SLAVE); check_drive(SECONDARY_BASE, SEL_MASTER); check_drive(SECONDARY_BASE, SEL_SLAVE); if (sel_base_port == 0) // We didn't find a (PATA) drive term_puts("No drives attached! What's going on?"); else { term_printf("Found a drive!\nSelected drive is the %s on the %s bus\n", sel_master_or_slave == SEL_MASTER ? "master" : "slave", sel_base_port == PRIMARY_BASE ? "primary" : "secondary"); term_printf("Max LBA value is %d\n", max_sector); } }
int _finfo(int argc, char ** argv) { if(argc > 1) { int data[8]; fs_finfo(argv[1], &data); printf("File name: %s\n", argv[1]); printf("Inode: %d\n", data[0]); printf("File blocks: %d\n", data[1]); printf("File bytes: %d\n", data[2]); printf("File permissions: %d\n", data[3]); printf("File uid: %d\n", data[4]); printf("File dir inode: %d\n", data[5]); } check_drive(0); return 0; }
void jump(unsigned short addr) { if (swtpc) { pc = addr; return; } else { switch (addr) { /* Too many programs access ACIA directly */ #if 0 case 0xF9CF: case 0xF9DC: /* Output a character */ { term_out(acca); /* putchar(acca); fflush(stdout); */ c_flag = 0; /* Carry is error status */ break; } #endif case 0xFA8B: /* Input a character */ { acca = term_in(); if (!mem[0xFF53]) { /* Echo */ term_out(acca); /* putchar(c); fflush(stdout); */ } else { mem[0xFF53] = 0; } c_flag = 0; /* No error */ break; } case 0xE800: /* OSLOAD (no modified parms) */ { printf("\nOSLOAD...\n"); getsect(0, 0x0020, 23, 128); getsect(0, 0x0020 + 0x0080, 24, 128); pc = 0x0020; sp = 0x00FF; return; } case 0xE822: /* FDINIT (no modified parms) */ { c_flag = 0; break; } #if 0 case 0xF853: /* CHKERR */ { break; } case 0xE85A: /* PRNTER */ { break; } #endif case 0xE869: /* READSC (read full sectors) */ { mem[LSCTLN] = 128; } case 0xE86D: /* READPS (read partial sectors) (FDSTAT, carry, sides) */ { int x; int n = mem[CURDRV]; int first = (mem[STRSCT] << 8) + mem[STRSCT + 1]; int num = (mem[NUMSCT] << 8) + mem[NUMSCT + 1]; int addr = (mem[CURADR] << 8) + mem[CURADR + 1]; int last = mem[LSCTLN]; if (trace_disk) printf("Read sectors: drive=%d, first=%d, number=%d, addr=%x, size of last=%d\n", n, first, num, addr, last); if (check_drive(n)) break; for (x = 0; x != num; ++x) { if (check_sect(n, first + x)) goto oops; getsect(n, addr + 128 * x, first + x, ((x + 1 == num) ? mem[LSCTLN] : 128)); } mem[FDSTAT] = ER_NON; if (drive[n].tracks == 77) mem[SIDES] = 0x80; else mem[SIDES] = 0; c_flag = 0; oops: break; } case 0xE86F: /* RDCRC */ { if (trace_disk) printf("RDCRC\n"); int x; int n = mem[CURDRV]; int first = (mem[STRSCT] << 8) + mem[STRSCT + 1]; int num = (mem[NUMSCT] << 8) + mem[NUMSCT + 1]; int addr = (mem[CURADR] << 8) + mem[CURADR + 1]; int last = mem[LSCTLN]; if (trace_disk) printf("RDCRC: drive=%d, first=%d, number=%d, addr=%x, size of last=%d\n", n, first, num, addr, last); if (check_drive(n)) break; for (x = 0; x != num; ++x) { if (check_sect(n, first + x)) goto oops; } mem[FDSTAT] = ER_NON; if (drive[n].tracks == 77) mem[SIDES] = 0x80; else mem[SIDES] = 0; c_flag = 0; break; } case 0xE875: /* RESTOR */ { int n = mem[CURDRV]; if (trace_disk) printf("RESTOR\n"); if (check_drive(n)) break; mem[FDSTAT] = ER_NON; if (drive[n].tracks == 77) mem[SIDES] = 0x80; else mem[SIDES] = 0; c_flag = 0; break; } case 0xE878: /* SEEK */ { int n = mem[CURDRV]; int first = (mem[STRSCT] << 8) + mem[STRSCT + 1]; if (trace_disk) printf("SEEK\n"); if (check_drive(n)) break; if (check_sect(n, first)) break; if (drive[n].tracks == 77) mem[SIDES] = 0x80; else mem[SIDES] = 0; c_flag = 0; break; } case 0xE872: /* RWTEST */ { if (trace_disk) printf("RWTEST\n"); } case 0xE87B: /* WRTEST */ { unsigned char buf[128]; int x; int n = mem[CURDRV]; int first = (mem[STRSCT] << 8) + mem[STRSCT + 1]; int num = (mem[NUMSCT] << 8) + mem[NUMSCT + 1]; int addr = (mem[CURADR] << 8) + mem[CURADR + 1]; int last = mem[LSCTLN]; if (trace_disk) printf("WRTEST\n"); if (check_drive(n)) break; for (x = 0; x != 128; x += 2) { buf[x] = mem[addr]; buf[x + 1] = mem[addr + 1]; } for(x=0; x != num; ++x) { if (check_sect(n, first + x)) goto oops; if (trace_disk) printf("Wrtest sector %d drive %d\n", first + x, n); fseek(drive[n].f, (first + x) * 128, SEEK_SET); fwrite(buf, 128, 1, drive[n].f); fflush(drive[n].f); } c_flag = 0; if (drive[n].tracks == 77) mem[SIDES] = 0x80; else mem[SIDES] = 0; mem[FDSTAT] = ER_NON; break; } case 0xE87E: /* WRDDAM */ { int n = mem[CURDRV]; printf("\r\nFloppy error: we do not support WRDDAM\n"); c_flag = 1; if (drive[n].tracks == 77) mem[SIDES] = 0x80; else mem[SIDES] = 0; mem[FDSTAT] = ER_WRT; break; } case 0xE884: /* WRITSC */ { if (trace_disk) printf("WRITSC\n"); } case 0xE881: /* WRVERF */ { int x; int n = mem[CURDRV]; int first = (mem[STRSCT] << 8) + mem[STRSCT + 1]; int num = (mem[NUMSCT] << 8) + mem[NUMSCT + 1]; int addr = (mem[CURADR] << 8) + mem[CURADR + 1]; int last = mem[LSCTLN]; if (trace_disk) printf("WRVERF: drive=%d, first=%d, number=%d, addr=%x, size of last=%d\n", n, first, num, addr, last); if (check_drive(n)) break; for(x=0; x != num; ++x) { if (check_sect(n, first + x)) goto oops; putsect(n, addr + 128 * x, first + x, 128); } if (drive[n].tracks == 77) mem[SIDES] = 0x80; else mem[SIDES] = 0; mem[FDSTAT] = ER_NON; c_flag = 0; break; } case 0xE887: /* CLOCK */ { printf("Floppy: Someone called CLOCK?\n"); c_flag = 0; break; } case 0xEBC0: /* LPINIT */ { if (trace_disk) printf("LPINIT\n"); c_flag = 0; break; } case 0xEBCC: /* LIST */ { if (trace_disk) printf("LIST\n"); term_out(acca); /* putchar(acca); fflush(stdout); */ c_flag = 0; break; } case 0xEBE4: /* LDATA */ { if (trace_disk)printf("LDATA\n"); while (mem[ix] != 4) { term_out(mem[ix]); /* putchar(mem[ix]); */ ++ix; } term_out('\r'); term_out('\n'); /* printf("\n"); */ c_flag = 0; break; } case 0xEBF2: /* LDATA1 */ { if (trace_disk) printf("LDATA1\n"); while (mem[ix] != 4) { /* putchar(mem[ix]); */ term_out(mem[ix]); ++ix; } /* fflush(stdout); */ c_flag = 0; break; } default: { pc = addr; return; } } simulated(addr); addr = pull2(); jump(addr); } }
static void hndlkey(int key, int kstate) { int i = 0, k; APPLINFO *appl; int title; /* DjV 019 110103 rsc index of current menu title */ if ( (unsigned int)key == HELP ) showhelp(); /* DjV 007 251202 */ k = key & ~XD_CTRL; if ((((unsigned int) k >= 0x803B) && ((unsigned int) k <= 0x8044)) || (((unsigned int) k >= 0x8154) && ((unsigned int) k <= 0x815D))) { k &= 0xFF; k = (k >= 0x54) ? (k - 0x54 + 11) : (k - 0x3B + 1); if ((appl = find_fkey(k)) != NULL) app_exec(NULL, appl, NULL, NULL, 0, kstate, FALSE); } else { /* k = key & ~XD_ALT; DjV 019 100103 */ k = scansh ( key, kstate ); /* DjV 019 100103 */ /* DjV 019 110103 ---vvv--- */ /* while ((keys[i].scancode != k) && (i < (NKEYS - 1))) i++; if (keys[i].scancode == k) */ title = TFIRST; while ( (options.V2_2.kbshort[i] != k) && (i <= ( MLAST - MFIRST)) ) { if ( (options.V2_2.kbshort[i] & XD_ALT) != 0 ) title++; i++; } if ( options.V2_2.kbshort[i] == k ) { /* menu_tnormal(menu, keys[i].title, 0); hndlmenu(keys[i].title, keys[i].item, kstate); */ menu_tnormal(menu, title, 0 ); hndlmenu( title, i + MFIRST, kstate ); } /* DjV 019 110103 ---^^^--- */ else { i = 0; if ((key >= ALT_A) && (key <= ALT_Z)) { i = key - (XD_ALT | 'A'); if (check_drive(i)) { char *path; if ((path = strdup("A:\\")) != NULL) { path[0] = (char) i + 'A'; /* dir_add_window(path); DjV 017 280103 */ dir_add_window(path, NULL); /* DjV 017 280103 */ itm_set_menu(xw_top()); /* DjV 029 160203 */ } else xform_error(ENSMEM); } } } } }