3 #include <conio.h> /* this is where Open Watcom hides the outp() etc. functions */
12 #include <hw/vga/vga.h>
13 #include <hw/pci/pci.h>
14 #include <hw/dos/dos.h>
15 #include <hw/8254/8254.h> /* 8254 timer */
16 #include <hw/8259/8259.h> /* 8259 PIC interrupts */
17 #include <hw/vga/vgagui.h>
18 #include <hw/vga/vgatty.h>
19 #include <hw/ide/idelib.h>
42 /*-----------------------------------------------------------------*/
44 static const char *drive_misc_tests_menustrings[] = {
45 "Show IDE register taskfile", /* 0 */
47 "Flush cache ext (LBA48)",
48 "Execute device diagnostic",
49 "CFA Disable Media Card Pass through",
50 "CFA Enable Media Card Pass through" /* 5*/
53 void do_drive_misc_tests(struct ide_controller *ide,unsigned char which) {
54 struct menuboxbounds mbox;
55 struct vga_msg_box vgabox;
64 menuboxbounds_set_def_list(&mbox,/*ofsx=*/4,/*ofsy=*/7,/*cols=*/1);
65 menuboxbounds_set_item_strings_arraylen(&mbox,drive_misc_tests_menustrings);
73 for (y=0;y < vga_height;y++) {
74 for (x=0;x < vga_width;x++) {
75 *vga++ = 0x1E00 + 177;
81 vga_write_color(0x1F);
82 vga_write(" IDE controller read/write tests ");
83 sprintf(tmp,"@%X",ide->base_io);
85 if (ide->alt_io != 0) {
86 sprintf(tmp," alt %X",ide->alt_io);
90 sprintf(tmp," IRQ %d",ide->irq);
93 vga_write(which ? " Slave" : " Master");
94 while (vga_pos_x < vga_width && vga_pos_x != 0) vga_writec(' ');
97 vga_write("WARNING: This code talks directly to your hard disk controller.");
98 while (vga_pos_x < vga_width && vga_pos_x != 0) vga_writec(' ');
100 vga_write(" If you value the data on your hard drive do not run this program.");
101 while (vga_pos_x < vga_width && vga_pos_x != 0) vga_writec(' ');
107 vga_moveto(mbox.ofsx,mbox.ofsy - 2);
108 vga_write_color((select == -1) ? 0x70 : 0x0F);
109 vga_write("Back to IDE controller main menu");
110 while (vga_pos_x < (mbox.width+mbox.ofsx) && vga_pos_x != 0) vga_writec(' ');
112 menuboxbound_redraw(&mbox,select);
116 if (c == 0) c = getch() << 8;
126 case 0: /* show IDE register taskfile */
127 do_common_show_ide_taskfile(ide,which);
128 redraw = backredraw = 1;
130 case 1: /* Flush cache */
131 do_ide_flush(ide,which,/*lba48*/0);
132 if (!idelib_controller_is_error(ide))
133 vga_msg_box_create(&vgabox,"Success",0,0);
135 common_ide_success_or_error_vga_msg_box(ide,&vgabox);
137 wait_for_enter_or_escape();
138 vga_msg_box_destroy(&vgabox);
141 case 2: /* Flush cache ext */
142 do_ide_flush(ide,which,/*lba48*/1);
143 if (!idelib_controller_is_error(ide))
144 vga_msg_box_create(&vgabox,"Success",0,0);
146 common_ide_success_or_error_vga_msg_box(ide,&vgabox);
148 wait_for_enter_or_escape();
149 vga_msg_box_destroy(&vgabox);
152 case 3: /* Execute device diagnostic */
153 do_ide_device_diagnostic(ide,which);
154 if (!idelib_controller_is_error(ide))
155 vga_msg_box_create(&vgabox,"Success",0,0);
157 common_ide_success_or_error_vga_msg_box(ide,&vgabox);
159 wait_for_enter_or_escape();
160 vga_msg_box_destroy(&vgabox);
163 case 4: /* Disable media card pass through */
164 do_ide_media_card_pass_through(ide,which,0);
165 if (!idelib_controller_is_error(ide))
166 vga_msg_box_create(&vgabox,"Success",0,0);
168 common_ide_success_or_error_vga_msg_box(ide,&vgabox);
170 wait_for_enter_or_escape();
171 vga_msg_box_destroy(&vgabox);
174 case 5: /* Enable media card pass through */
175 do_ide_media_card_pass_through(ide,which,1);
176 if (!idelib_controller_is_error(ide))
177 vga_msg_box_create(&vgabox,"Success",0,0);
179 common_ide_success_or_error_vga_msg_box(ide,&vgabox);
181 wait_for_enter_or_escape();
182 vga_msg_box_destroy(&vgabox);
187 else if (c == 0x4800) {
189 select = mbox.item_max;
193 else if (c == 0x4B00) { /* left */
196 else if (c == 0x4D00) { /* right */
199 else if (c == 0x5000) {
200 if (++select > mbox.item_max)
208 #endif /* MISC_TEST */