Modifying 0xA000 - nothing changing in graphics mode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Daedalus
Member
Member
Posts: 74
Joined: Sun Oct 16, 2005 11:00 pm
Location: Australia
Contact:

Modifying 0xA000 - nothing changing in graphics mode

Post 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? :)
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Re: Modifying 0xA000 - nothing changing in graphics mode

Post 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
User avatar
Daedalus
Member
Member
Posts: 74
Joined: Sun Oct 16, 2005 11:00 pm
Location: Australia
Contact:

Re: Modifying 0xA000 - nothing changing in graphics mode

Post 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.)
Last edited by Daedalus on Tue Oct 25, 2005 11:00 pm, edited 1 time in total.
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Re: Modifying 0xA000 - nothing changing in graphics mode

Post 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)
User avatar
Daedalus
Member
Member
Posts: 74
Joined: Sun Oct 16, 2005 11:00 pm
Location: Australia
Contact:

Re: Modifying 0xA000 - nothing changing in graphics mode

Post 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!
archie
Posts: 1
Joined: Fri Dec 09, 2005 12:00 am

Re: Modifying 0xA000 - nothing changing in graphics mode

Post 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??
User avatar
Daedalus
Member
Member
Posts: 74
Joined: Sun Oct 16, 2005 11:00 pm
Location: Australia
Contact:

Re: Modifying 0xA000 - nothing changing in graphics mode

Post 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 ;)
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Re: Modifying 0xA000 - nothing changing in graphics mode

Post 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
User avatar
deadmutex
Member
Member
Posts: 85
Joined: Wed Sep 28, 2005 11:00 pm

Re: Modifying 0xA000 - nothing changing in graphics mode

Post 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.
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re: Modifying 0xA000 - nothing changing in graphics mode

Post 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
Last edited by bubach on Sat Dec 17, 2005 12:00 am, edited 1 time in total.
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
Post Reply