Modifying 0xA000 - nothing changing in graphics mode
Modifying 0xA000 - nothing changing in graphics mode
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?
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?
- carbonBased
- Member
- Posts: 382
- Joined: Sat Nov 20, 2004 12:00 am
- Location: Wellesley, Ontario, Canada
- Contact:
Re: Modifying 0xA000 - nothing changing in graphics mode
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
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
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:
Also, I'm trying to write to the address from kernel space and kernel modules (which run on the kernel level.)
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) */
Last edited by Daedalus on Tue Oct 25, 2005 11:00 pm, edited 1 time in total.
Re: Modifying 0xA000 - nothing changing in graphics mode
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)
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
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!
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
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
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
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
- carbonBased
- Member
- Posts: 382
- Joined: Sat Nov 20, 2004 12:00 am
- Location: Wellesley, Ontario, Canada
- Contact:
Re: Modifying 0xA000 - nothing changing in graphics mode
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
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
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.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
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
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.