i gotz VGA =]
multitasking
Hi i implemented multitasking in my baby kernel, in this modes:
SJF, FCFS, RR (round-robin)
SJF, FCFS, RR (round-robin)
Well... my VGA works. I just taken some c code end rewritten it to my asm kernel.
you just have to set a bunch of registers:
And here are some modes I have in my mode table:
You just have to call it now:
you just have to set a bunch of registers:
Code: Select all
;IN: edi=@register_set
vga.set_registers:
push eax
push ecx
push edx
push edi
;MISC
mov dx, vga.reg.misc_write
mov al, [edi]
out dx, al
inc edi
;sequencer
xor ecx, ecx
.loop_seq:
mov dx, vga.reg.seq_index
mov eax, ecx
out dx, al
mov dx, vga.reg.seq_data
mov al, [edi]
out dx, al
inc edi
inc ecx
cmp ecx, 5
jne .loop_seq
;unlock crtc registers
mov dx, vga.reg.crtc_index
mov al, 3
out dx, al
mov dx, vga.reg.crtc_data
in al, dx
or al, 0x80 ;set ? bit
out dx, al
mov dx, vga.reg.crtc_index
mov al, 11
out dx, al
mov dx, vga.reg.crtc_data
in al, dx
and al, 0x7F ;del ? bit
out dx, al
;???make sure they remain unlocked???
or byte[edi+ 3],0x80
and byte[edi+11],0x7F
;write crtc registers
xor ecx, ecx
.loop_crtc:
mov dx, vga.reg.crtc_index
mov eax, ecx
out dx, al
mov dx, vga.reg.crtc_data
mov al, [edi]
out dx, al
inc edi
inc ecx
cmp ecx, 25
jne .loop_crtc
;write gc (graphic controller) registers
xor ecx, ecx
.loop_gc:
mov dx, vga.reg.gc_index
mov eax, ecx
out dx, al
mov dx, vga.reg.gc_data
mov al, [edi]
out dx, al
inc edi
inc ecx
cmp ecx, 9
jne .loop_gc
;write ac (attribute controller) registers
xor ecx, ecx
.loop_ac:
;?
mov dx, vga.reg.instat_read
in al, dx
;?
mov dx, vga.reg.ac_index
mov eax, ecx
out dx, al
mov dx, vga.reg.ac_data_write
mov al, [edi]
out dx, al
inc edi
inc ecx
cmp ecx, 21
jne .loop_ac
;/* lock 16-color palette and unblank display */
; (void)inportb(VGA_INSTAT_READ);
; outportb(VGA_AC_INDEX, 0x20);
;???lock 16 color palette???
mov dx, vga.reg.instat_read
in al, dx
mov dx, vga.reg.ac_index
mov al, 0x20
out dx, al
pop edi
pop edx
pop ecx
pop eax
ret
Code: Select all
vga.mode.text_80x25: ;this is the standard mode!
;MISC
db 0x67
;SEQ
db 0x03, 0x00, 0x03, 0x00, 0x02
;CRTC
db 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F
db 0x00, 0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x50
db 0x9C, 0x0E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3
db 0xFF
;GC
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x00
db 0xFF
;AC
db 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07
db 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F
db 0x0C, 0x00, 0x0F, 0x08, 0x00
vga.mode.text_80x50:
;MISC
db 0x67
;SEQ
db 0x03, 0x00, 0x03, 0x00, 0x02
;CRTC
db 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F
db 0x00, 0x47, 0x06, 0x07, 0x00, 0x00, 0x01, 0x40
db 0x9C, 0x8E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3
db 0xFF
;GC
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x00
db 0xFF
;AC
db 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07
db 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F
db 0x0C, 0x00, 0x0F, 0x08, 0x00
vga.mode.graphic_320x200x256:
;MISC
db 0x63
;SEQ
db 0x03, 0x01, 0x0F, 0x00, 0x0E
;CRTC
db 0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F
db 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
db 0x9C, 0x0E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3
db 0xFF
;GC
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F
db 0xFF
;AC
db 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
db 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
db 0x41, 0x00, 0x0F, 0x00, 0x00
vga.mode.graphic_640x480x16:
;MISC
db 0xE3
;SEQ
db 0x03, 0x01, 0x08, 0x00, 0x06
;CRTC
db 0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E
db 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
db 0xEA, 0x0C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3
db 0xFF
;GC
db 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x05, 0x0F
db 0xFF
;AC
db 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07
db 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F
db 0x01, 0x00, 0x0F, 0x00, 0x00
Code: Select all
mov edi, vga.mode.graphic_320x200x256
call vga.set_registers
looks very nice. exactly what i need
but because I've not some functions, i made it
but this seems to have problems.
have anyone figure out this functions ?
but because I've not some functions, i made it
Code: Select all
byte peekb(void *S, short O)
{
byte *mm = (byte *)S;
return mm[O];
}
void pokeb(void *S, short O, byte V)
{
byte *mm = (byte *)S;
mm[O] = V;
}
void pokew(void *S, short O, word V)
{
word *mm = (word *)S;
mm[O] = V;
}
void _vmemwr(void *DS,short DO, const void *S, int N)
{
const char *sp = (const char *)S;
char *dpn = (char *)DS;
char *dp = dpn[DO];
for(; N != 0; N--) *dp++ = *sp++;
}
have anyone figure out this functions ?
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
You bumped the thread after waiting less than an hour. Impatience generally doesn't get results - you're on a forum, not everyone is in your timezone, and not everyone is able to answer your question even if they are online.
As for your question, we can't read your mind. What are the specific problems you are having? We can't help you unless we know what the problem is .
As for your question, we can't read your mind. What are the specific problems you are having? We can't help you unless we know what the problem is .
I get modes.c from the site and i made some changes, because i've not yet implemented some functions. i made some function as i described. the problem is that it get to the video mode but if i want to plot a pixel, there isn't anything on the screen. but for mode 320x200x256 i get something nice
I think there is a problem with my functions(peekb, pokeb, pokew, and _vmemwr)
Now works fine, after i used direct memory plotting(VGA_MEM[offset]=color)
I think there is a problem with my functions(peekb, pokeb, pokew, and _vmemwr)
Code: Select all
byte peekb(void *S, short O)
{
byte *mm = (byte *)S;
return mm[O];
}
void pokeb(void *S, short O, byte V)
{
byte *mm = (byte *)S;
mm[O] = V;
}
void pokew(void *S, short O, word V)
{
word *mm = (word *)S;
mm[O] = V;
}
void _vmemwr(void *DS,short DO, const void *S, int N)
{
const char *sp = (const char *)S;
char *dpn = (char *)DS;
char *dp = dpn[DO];
for(; N != 0; N--) *dp++ = *sp++;
}
- Attachments
-
- yah, the screenshot of error
- ss_err.JPG (15.36 KiB) Viewed 3419 times
this may be what your looking for, but your method works better anyway.
Code: Select all
void _farpokeb(unsigned short selector,
unsigned long offset,
unsigned char value)
{
__asm__ __volatile__ ("movw %w0,%%fs\n"
" .byte 0x64 \n"
" movb %b1,(%k2)"
:
: "rm" (selector), "qi" (value), "r" (offset));
}
unsigned char
_farpeekb(unsigned short selector,
unsigned long offset)
{
unsigned char result;
__asm__ __volatile__ ("movw %w1,%%fs \n"
" .byte 0x64 \n"
" movb (%k2),%b0"
: "=q" (result)
: "rm" (selector), "r" (offset));
return result;
}