flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Video Mode Switch |
Author |
|
Dex4u 13 Jun 2005, 15:41
The info you want is available on bubach's site here: http://bos.asmhackers.net/docs/vga_without_bios/
|
|||
13 Jun 2005, 15:41 |
|
Opcode 16 Jun 2005, 12:01
Well, I read all documentation that I found by Google including the bubach's docs.
But I'm still not able to switch my video card mode to text mode again. This is a experimental project. I'm running a device drivers inside the kernel of Windows XP, that is running at the resolution 1152x864x32bits and I want to switch it to text mode 80x25. Take a look: ( I know that this is a C code, but I will translate it to ASM as soon it works!) Code: VOID VgaSetContext(PVGA_CONTEXT VgaCtx) { unsigned int i; // // Reset flip-flop by reading the Input Status #1 Register // PORTINB(VGA_MISC_READ_INPUT_STATUS_1); // Disable video PORTOUTB(VGA_AC_IO_REG, 0x00); // // Set the Misc register // PORTOUTB(VGA_MISC_WRITE_OUTPUT_REG, VgaCtx->Misc[0]); // synchronous reset on PORTOUTB(VGA_SC_INDEX_REG, 0x0); PORTOUTB(VGA_SC_DATA_REG, 0x1); // // Set the SC registers // for ( i = 1; i < VGA_SC_REGS; i++) { PORTOUTB(VGA_SC_INDEX_REG, i); PORTOUTB(VGA_SC_DATA_REG, VgaCtx->Sc[i]); } // synchronous reset off PORTOUTB(VGA_SC_INDEX_REG, 0x0); PORTOUTB(VGA_SC_DATA_REG, 0x3); // // Unprotect the CRTC registers 0-7 // PORTOUTB(VGA_CRTC_INDEX_REG, CRTC_VERTICAL_RETRACE_END); PORTOUTB(VGA_CRTC_DATA_REG, (PORTINB(VGA_CRTC_DATA_REG)&~0x80)); // // Set the CRTC registers // for ( i = 0; i < VGA_CRTC_REGS; i++) { PORTOUTB(VGA_CRTC_INDEX_REG, i); // (<- THE MONITOR SHUTDOWN ITSELF RIGHT HERE!!!) PORTOUTB(VGA_CRTC_DATA_REG, VgaCtx->Crtc[i]); } ... The are more code The VGA_CONTEXT structure: Code: typedef struct tagVGA_CONTEXT { UCHAR Misc[VGA_MISC_REGS]; // Miscellaneous registers UCHAR Sc[VGA_SC_REGS]; // SC registers UCHAR Crtc[VGA_CRTC_REGS]; // CRTC registers UCHAR Gc[VGA_GC_REGS]; // GC registers UCHAR Ac[VGA_AC_REGS]; // AC registers } VGA_CONTEXT, *PVGA_CONTEXT; PORT definitions: Code: // // VGA Registers // #define VGA_AC_IO_REG 0x3c0 // AC Index/Output Register #define VGA_AC_DATA_REG 0x3c1 // AC Data Read Register #define VGA_MISC_READ_INPUT_STATUS_0 0x3c2 // Input Status #0 Register #define VGA_MISC_WRITE_OUTPUT_REG 0x3c2 // Miscellaneous Output Register (WRITE) #define VGA_SC_INDEX_REG 0x3c4 // Sequencer Index Register #define VGA_SC_DATA_REG 0x3c5 // Sequencer Data Register #define VGA_MISC_READ_FEATURE_CONTROL 0x3ca // Feature Control Register (READ) #define VGA_MISC_READ_OUTPUT_REG 0x3cc // Miscellaneous Output Register (READ) #define VGA_GC_INDEX_REG 0x3ce // Graphics Controller Index Register #define VGA_GC_DATA_REG 0x3cf // Graphics Controller Data Register #define VGA_CRTC_INDEX_REG 0x3d4 // CRT Controller Index Register (color) #define VGA_CRTC_DATA_REG 0x3d5 // CRT Controller Data Register (color) #define VGA_MISC_READ_INPUT_STATUS_1 0x3da // Input Status #1 Register (READ) #define VGA_MISC_WRITE_FEATURE_CONTROL_REG 0x3da // Feature Control Register (WRITE) // // VGA Registers Total Indexes // #define VGA_AC_REGS 0x15 #define VGA_SC_REGS 0x05 #define VGA_GC_REGS 0x09 #define VGA_CRTC_REGS 0x19 #define VGA_MISC_REGS 0x01 Please, I really need to understand why my monitor is shutdown itself when I access the CRT controler registers at ports 0x3d4 and 0x3d5. The are more registers that I need to configure before? If someone can post some code, rather in ASM I apreciate Thanks for any help Regards, Opc0de Last edited by Opcode on 16 Jun 2005, 13:42; edited 1 time in total |
|||
16 Jun 2005, 12:01 |
|
vid 16 Jun 2005, 12:11
have you been looking at BIOS's code for this? I recall i found something totally undescribed anywhere with EGA palette this way long time ago.
|
|||
16 Jun 2005, 12:11 |
|
Opcode 16 Jun 2005, 12:17
Hi vid,
No, I don't have BIOS code. Do you have some code to help me? Thanks. |
|||
16 Jun 2005, 12:17 |
|
Dex4u 16 Jun 2005, 15:20
If your running your code from a device driver inside XP kernel, would it not be better to ask in the windows part ?.
|
|||
16 Jun 2005, 15:20 |
|
Opcode 16 Jun 2005, 18:21
The kernel don't have API to do what I want specifically.
It is not possible to do what I want only with the VGA registers? |
|||
16 Jun 2005, 18:21 |
|
tom tobias 16 Jun 2005, 18:43
Opcode wrote: The kernel don't have API to do what I want specifically. I may be completely in error here, sorry not to have a specific reference, but, in my opinion, what you seek to accomplish is quite difficult WITHIN windows, because of ring zero requirement to access the video control registers directly, and windows insistence that you NOT access ring zero. May I suggest menuet or sol as alternative operating systems..... Once you are able to work at ring zero, i.e. user access to all components on the motherboard, then, you can access the video control registers. Perhaps my opinion is incorrect. |
|||
16 Jun 2005, 18:43 |
|
Opcode 16 Jun 2005, 23:39
tom tobias wrote:
Hi tom, I can assure you that I have complete access to ring 0. BTW, to create device drivers for Windows in assembly is a very fun task And unfortunatelly, this project is Windows specific, I can't use another OS. My fear is the lack of documentation about these new video modes and the registers configuration. Is very strange the fact that my monitor is shutdown itself just because I'm writing in the CRTC_HORIZONTAL_TOTAL register (Index 0) at port 0x3d5. I really don't understand this Regards, Opc0de |
|||
16 Jun 2005, 23:39 |
|
THEWizardGenius 17 Jun 2005, 04:13
Another useful VGA Programming page is http://www.osdever.net/FreeVGA/home.htm - check it out. It isn't complete (apparently the project was halted) so it only has VGA programming info. (sorry, no SVGA) but it does have VGA documentation. One of bubach's pages is actually one of these documents.
For SVGA and XGA programming info., search for VGADOC and WHATVGA. They aren't very helpful, but you might be able to use them. |
|||
17 Jun 2005, 04:13 |
|
vid 17 Jun 2005, 08:57
opcode: use debugger to "walk into" interrupt int 10h / al=3, until it reches BIOS's are. It is probably somewhere at the top of 1Mb, segments 0D000h to 0FFFFh. Then look at segment in CS, and use utility to grab memory range from CS:0 to CS:FFFF (i mean CS when you was in that BIOS routine). Then use some disassembler (i suggest IDA for such "special" causes), and look what it does.
PS: first thing you will see will be checking for value of AL |
|||
17 Jun 2005, 08:57 |
|
bogdanontanu 17 Jun 2005, 10:15
I think he wants to do this setup directly from Windows driver/ring-0 without BIOS help (talking directly to VGA ports/registers)
However this is also very dificult ... mainly because windows will interfere with this ... and the video driver etc. You must understand the windows kernel internals and the relation between kernel modules IRQ virtualization etc. It is normal for the monitor to shut down (it can be even damaged) if you write wrong values into VGA registers . You must setup only values that are acceptable for that video card and video mode and monitor... this is error prone and it might damage some hardware while working ok with other hardware. Take care, because you can permanently damage hardware by writting wrong values into hardware registers |
|||
17 Jun 2005, 10:15 |
|
Opcode 17 Jun 2005, 14:06
Unfortunatelly appears that I will need to find another way.
I don't know how but I will keep my research. Windows internals programming is not a problem to me, I'm doing programming in the kernel for 3 years. I will try to find out how the Windows XP clone( the Open Source ReactOS project) manages the video card. Thanks for the answers! |
|||
17 Jun 2005, 14:06 |
|
THEWizardGenius 17 Jun 2005, 16:51
In Windows? Why do that in Windows? I don't think you'll be able to, as Windows is very picky about these things.
BTW vid, if you're willing to do some dirty work (debugging BIOS) then why not use some BIOS source code? I have found some in several places online. It might be illegal, but you can learn a lot from it, and learning isn't illegal. |
|||
17 Jun 2005, 16:51 |
|
f0dder 19 Jun 2005, 12:22
Quote:
AFAIK by using windows drivers Opcode, are you trying to write a kernel-mode debugger? If you don't specifically need textmode, you could try going the SoftICE way of "universal video driver", by hooking DirectDraw or whatever it is they do... |
|||
19 Jun 2005, 12:22 |
|
vid 23 Jun 2005, 14:41
found this MASM code
|
|||||||||||
23 Jun 2005, 14:41 |
|
Opcode 23 Jun 2005, 17:47
To f0dder:
Its is not exactly a kernel-mode debugger, but it have some functions in common. Thanks for the DirectDraw hint. To vid: Thanks for the modes.zip. I will try run it from inside the kernel. Regards, Opc0de |
|||
23 Jun 2005, 17:47 |
|
vid 23 Jun 2005, 19:33
Opcode: rather try to understand it and rewrite it yoursef
|
|||
23 Jun 2005, 19:33 |
|
Opcode 23 Jun 2005, 23:10
vid wrote: Opcode: rather try to understand it and rewrite it yoursef Of course. This is exactly what I'm doing |
|||
23 Jun 2005, 23:10 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.