7 void outxay(PUSHORT ad, UCHAR x, UCHAR y)
9 USHORT xy = (x << 8) + y;
11 VideoPortWritePortUshort(ad, xy);
14 void setMode(VideoMode mode)
17 unsigned int y, c, a, m, n;
19 VideoPortWritePortUchar((PUCHAR)MISC, mode.Misc);
20 VideoPortWritePortUchar((PUCHAR)STATUS, 0);
21 VideoPortWritePortUchar((PUCHAR)FEATURE, mode.Feature);
25 outxay((PUSHORT)SEQ, mode.Seq[x], x);
28 VideoPortWritePortUshort((PUSHORT)CRTC, 0x11);
29 VideoPortWritePortUshort((PUSHORT)CRTC, (mode.Crtc[0x11] & 0x7f));
33 outxay((PUSHORT)CRTC, mode.Crtc[x], x);
38 outxay((PUSHORT)GRAPHICS, mode.Gfx[x], x);
41 x=VideoPortReadPortUchar((PUCHAR)FEATURE);
45 VideoPortWritePortUchar((PUCHAR)ATTRIB, x);
46 VideoPortWritePortUchar((PUCHAR)ATTRIB, mode.Attrib[x]);
49 x=VideoPortReadPortUchar((PUCHAR)STATUS);
51 VideoPortWritePortUchar((PUCHAR)ATTRIB, 0x20);
57 {0x03, 0x01, 0x0f, 0x00, 0x06 },
59 {0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, 0x00, 0x40, 0x00, 0x00,
60 0x00, 0x00, 0x00, 0x59, 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3,
63 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff},
65 {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
66 0x0c, 0x0d, 0x0e, 0x0f, 0x81, 0x00, 0x0f, 0x00, 0x00}
72 VIDEO_X86_BIOS_ARGUMENTS vxba;
75 // FIXME: Use Vidport to map the memory properly
76 vidmem = (char *)(0xd0000000 + 0xa0000);
77 memset(&vxba, 0, sizeof(vxba));
79 vps = VideoPortInt10(NULL, &vxba);
81 // Get VGA registers into the correct state (mainly for setting up the palette registers correctly)
84 // Get the VGA into the mode we want to work with
85 WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // Set
86 WRITE_PORT_UCHAR((PUCHAR)GRA_D,0); // the MASK
87 WRITE_PORT_USHORT((PUSHORT)GRA_I,0x0205); // write mode = 2 (bits 0,1) read mode = 0 (bit 3)
88 i = READ_REGISTER_UCHAR(vidmem); // Update bit buffer
89 WRITE_REGISTER_UCHAR(vidmem, 0); // Write the pixel
90 WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08);
91 WRITE_PORT_UCHAR((PUCHAR)GRA_D,0xff);
93 // Zero out video memory (clear a possibly trashed screen)
94 RtlZeroMemory(vidmem, 64000);
99 VOID VGAResetDevice(OUT PSTATUS_BLOCK StatusBlock)
103 OBJECT_ATTRIBUTES Attr;
104 UNICODE_STRING Name = UNICODE_STRING_INITIALIZER(L"\\TextConsoleRefreshEvent");
106 VIDEO_X86_BIOS_ARGUMENTS vxba;
108 ULONG ThreadRelease = 1;
113 memset(&vxba, 0, sizeof(vxba));
115 vps = VideoPortInt10(NULL, &vxba);
116 memset(&vxba, 0, sizeof(vxba));
118 vps = VideoPortInt10(NULL, &vxba);
119 InitializeObjectAttributes( &Attr, &Name, 0, 0, 0 );
120 Status = ZwOpenEvent( &Event, STANDARD_RIGHTS_ALL, &Attr );
121 if( !NT_SUCCESS( Status ) )
122 DbgPrint( "VGA: Failed to open refresh event\n" );
124 ZwSetEvent( Event, &ThreadRelease );