]> 4ch.mooo.com Git - 16.git/blob - src/lib/doslib/hw/ide/testnop.c
added a bunch of things~ and midi stuff~
[16.git] / src / lib / doslib / hw / ide / testnop.c
1 /* IDE NOP test */
2
3 #include <stdio.h>
4 #include <conio.h> /* this is where Open Watcom hides the outp() etc. functions */
5 #include <stdlib.h>
6 #include <string.h>
7 #include <unistd.h>
8 #include <malloc.h>
9 #include <ctype.h>
10 #include <fcntl.h>
11 #include <dos.h>
12
13 #include <hw/vga/vga.h>
14 #include <hw/pci/pci.h>
15 #include <hw/dos/dos.h>
16 #include <hw/8254/8254.h>               /* 8254 timer */
17 #include <hw/8259/8259.h>               /* 8259 PIC interrupts */
18 #include <hw/vga/vgagui.h>
19 #include <hw/vga/vgatty.h>
20 #include <hw/ide/idelib.h>
21
22 #include "testutil.h"
23 #include "testmbox.h"
24 #include "testcmui.h"
25 #include "testbusy.h"
26 #include "test.h"
27
28 #include "testnop.h"
29
30 #ifdef NOP_TEST
31 void do_ide_controller_drive_nop_test(struct ide_controller *ide,unsigned char which) {
32         struct vga_msg_box vgabox;
33         struct ide_taskfile *tsk;
34
35         if (do_ide_controller_user_wait_busy_controller(ide) != 0 || do_ide_controller_user_wait_drive_ready(ide) < 0)
36                 return;
37         idelib_controller_ack_irq(ide); /* <- make sure to ack IRQ */
38
39         /* fill the registers with a pattern and then issue the NOP command.
40          * the NOP command should come back with unmodified registers */
41         tsk = idelib_controller_get_taskfile(ide,-1/*selected drive*/);
42         tsk->features = 0x00; /* will read back into error reg */
43         tsk->sector_count = 0x12;
44         tsk->lba0_3 = 0x34;
45         tsk->lba1_4 = 0x56;
46         tsk->lba2_5 = 0x78;
47         tsk->command = 0x00; /* <- NOP */
48         idelib_controller_apply_taskfile(ide,0xBE/*base_io+1-5&7*/,IDELIB_TASKFILE_LBA48_UPDATE/*clear LBA48*/);
49         if (ide->flags.io_irq_enable) {
50                 do_ide_controller_user_wait_irq(ide,1);
51                 idelib_controller_ack_irq(ide); /* <- or else it won't fire again */
52         }
53         do_ide_controller_user_wait_busy_controller(ide);
54         do_ide_controller_user_wait_drive_ready(ide);
55         if (!(ide->last_status&1)) {
56                 vga_msg_box_create(&vgabox,"Success?? (It's not supposed to!)",0,0);
57         }
58         else if ((ide->last_status&0xC9) != 0x41) {
59                 sprintf(tmp,"Device rejected with status %02X (not the way it's supposed to)",ide->last_status);
60                 vga_msg_box_create(&vgabox,tmp,0,0);
61         }
62         else {
63                 idelib_controller_update_taskfile(ide,0xBE,0);
64                 if ((tsk->error&0x04) != 0x04) {
65                         vga_msg_box_create(&vgabox,"Device rejected with non-abort (not the way it's supposed to)",0,0);
66                 }
67                 else {
68                         unsigned char c=0,cc=0;
69
70                         c=tsk->sector_count; cc += (c == 0x12)?1:0;
71                         c=tsk->lba0_3; cc += (c == 0x34)?1:0;
72                         c=tsk->lba1_4; cc += (c == 0x56)?1:0;
73                         c=tsk->lba2_5; cc += (c == 0x78)?1:0;
74
75                         if (cc == 4)
76                                 vga_msg_box_create(&vgabox,"Success",0,0);
77                         else
78                                 vga_msg_box_create(&vgabox,"Failed. Registers were modified.",0,0);
79                 }
80         }
81
82         wait_for_enter_or_escape();
83         vga_msg_box_destroy(&vgabox);
84 }
85 #endif /* NOP_TEST */
86