Page 1 of 1

Modifying 0xA000 - nothing changing in graphics mode

Posted: Tue Oct 25, 2005 11:00 pm
by Daedalus
In my PMode OS, I enter graphics mode when the user types a command (eg, 'mode13' or 'mode12') into the terminal application, which then sends a command using IPC to the video device manager application/daemon.

However, neither from kernel mode nor application mode does any writes to 0xA000 modify the contents of the screen in graphics mode. It remains in a 'dirty' state, with semi-random data on the screen.

I've heard I need to set selectors or something? Sorry, but could somebody please explains these to me? :)

Re: Modifying 0xA000 - nothing changing in graphics mode

Posted: Tue Oct 25, 2005 11:00 pm
by carbonBased
Yes, when you enter pmode you need to refer to memory using a 16-bit selector and a 32-bit offset. If you're already in pmode, and accessing memory, you're already doing this, so this shouldn't be new to you.

What does your gdt look like?

A quick hint: video memory in real mode is 0xA000:0. As you (should) know, this is a segment:offset syntax whereby each segment in real-mode is 16 bytes long. Therefore, the linear address of that memory is actually:

0xA000 * 0x10 + 0x0 = 0xA0000

In other words (since you're data segment is, no doubt, set with a base of 0, as most are) try writting to this address (note the extra 0).

--Jeff

Re: Modifying 0xA000 - nothing changing in graphics mode

Posted: Tue Oct 25, 2005 11:00 pm
by Daedalus
Below is my GDT.

I wish I could say I wrote it, and fully understand it, but I dont.
I thought I understood it, but alas my modifications either had no visible impact, or crashed Bochs.

I've tried writing to 0xA0000, such as : memset(0xA0000, 0, 65535) but there is no change, either as soon as the mode is set, or when I blindly type 'cls' at the command terminal app.

Heres the gdt:

Code: Select all

gdt_tss:
	.word 103
	.word 0
	.byte 0
	.byte 0x89	/* present, ring 0, available 32-bit TSS */
	.byte 0
	.byte 0

/* ring 0 kernel code segment descriptor */
.equ	KERNEL_CS,(.-gdt)
gdt_kcode:
	.word 0xFFFF
	.word 0
	.byte 0
	.byte 0x9A	/* present, ring 0, code, non-conforming, readable */
	.byte 0xCF
	.byte 0

/* ring 0 kernel data segment descriptor */
.equ	KERNEL_DS,(.-gdt)
gdt_kdata:
	.word 0xFFFF
	.word 0
	.byte 0
	.byte 0x92	/* present, ring 0, data, expand-up, writable */
	.byte 0xCF
	.byte 0

/* ring 3 user code segment descriptor */
.equ	USER_CS,((.-gdt)|3)
gdt_ucode:
	.word 0xFFFF
	.word 0
	.byte 0
	.byte 0xFA	/* present, ring 3, code, non-conforming, readable */
	.byte 0xCF
	.byte 0

/* ring 3 user data segment descriptor */
.equ	USER_DS,((.-gdt)|3)
gdt_udata:
	.word 0xFFFF
	.word 0
	.byte 0
	.byte 0xF2	/* present, ring 3, data, expand-up, writable */
	.byte 0xCF
	.byte 0
gdt_end:

gdt_ptr:
	.word gdt_end - gdt - 1	/* GDT limit */
	.long gdt		/* linear adr of GDT (set above) */
Also, I'm trying to write to the address from kernel space and kernel modules (which run on the kernel level.)

Re: Modifying 0xA000 - nothing changing in graphics mode

Posted: Wed Oct 26, 2005 11:00 pm
by JAAman
well i cant see anything wrong with your descriptors except you cannot use the first descriptor for your tss the first one must be unused(the null descriptor)

do you have the intel manuals? if not get them they are the best source of information on the GDT (and other structures)

you should be able to write directly to the screen at B8000 (however remember if your in mode 12 or 13 you will have to draw your own fonts onto the screen: you cant put characters directly onto the screen

in graphics mode the screen will be at
B0000 or A0000 (depending on which mode)

Re: Modifying 0xA000 - nothing changing in graphics mode

Posted: Sat Oct 29, 2005 11:00 pm
by Daedalus
I finally got it - mostly.

For mode 13 I had to change write location to include the virtual address used by the OS. Thats what you get for using someone else's OS for a base.

Now I've just got to work out what to do with mode 12, which doesnt seem to be working. Oh well I'll get it one day.

Thanks for the help all!

Re: Modifying 0xA000 - nothing changing in graphics mode

Posted: Fri Dec 09, 2005 12:00 am
by archie
can you share your code?? i need to change my VGA mode from 80x25 to 40x25 text mode but i dont know how can i do this in protected mode can you give me some examples??

Re: Modifying 0xA000 - nothing changing in graphics mode

Posted: Tue Dec 13, 2005 12:00 am
by Daedalus
Thats dealing with text mode, not graphical mode.

On top of that, I borrowed my code for mode switching from someone else, and it uses many hardware port operations that I frankly dont understand. The VGA's io ports are not my domain ;)

Re: Modifying 0xA000 - nothing changing in graphics mode

Posted: Wed Dec 14, 2005 12:00 am
by carbonBased
This would still be very useful to a lot of people here, I presume.

I have docs on the the VGA registers and I, personally, would be curious to see how they're used to switch to mode 0x13, etc.

If you, yourself, are looking for VGA docs, check out "VGADOC" (I believe that's what it's called) on google. Should be able to find descriptions of all these registers from std vga to custom chipsets.

Cheers,
Jeff

Re: Modifying 0xA000 - nothing changing in graphics mode

Posted: Wed Dec 14, 2005 12:00 am
by deadmutex
On top of that, I borrowed my code for mode switching from someone else, and it uses many hardware port operations that I frankly dont understand. The VGA's io ports are not my domain ;)
I wouldn't recommend you using someone else's code if you can't explain how it works. If their code contained any bugs, then it would be rather difficult to fix.

Re: Modifying 0xA000 - nothing changing in graphics mode

Posted: Sat Dec 17, 2005 12:00 am
by bubach
I have some fasm code to change mode with VGA IO ports. Look in the folder "kernel/testkernels etc/" inside the BOS 0.04 zip file on http://bos.asmhackers.net/downloads.php.

For more examples/docs on this see http://bos.asmhackers.net/docs/vga_without_bios/

/ Christoffer