i gotz VGA =]

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
User avatar
Aku-Aku
Posts: 19
Joined: Mon Apr 24, 2006 11:00 pm
Location: Hungary

multitasking

Post by Aku-Aku »

Hi i implemented multitasking in my baby kernel, in this modes:
SJF, FCFS, RR (round-robin)
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

i have a basic vga, basic ramfs, basic mutlitasking but nothing else so far.

in my old kernel i had working floppy i/o, but im saving that until i get my driver interface working.
~ Lukem95 [ Cake ]
Release: 0.08b
Image
The Doc
Posts: 6
Joined: Thu Feb 28, 2008 5:36 pm

Post by The Doc »

I'm currently trying to access VGA-Mode, but i can't make it work... :(
Is it possible to have a look on your sources?
Osbios
Member
Member
Posts: 116
Joined: Fri Jun 10, 2005 11:00 pm

Post by Osbios »

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:

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
And here are some modes I have in my mode table:

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
You just have to call it now:

Code: Select all

mov edi, vga.mode.graphic_320x200x256
call vga.set_registers
The Doc
Posts: 6
Joined: Thu Feb 28, 2008 5:36 pm

Post by The Doc »

Thank you! I'll have a look on it.
But i should have told you that i don't want to use asm where i don't have to. I want to get it work in C or Cpp... So i'm really interested in having a look on lukem's code :D
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

just look at chris giese's code:

http://my.execpc.com/~geezer/osd/graphics/modes.c
~ Lukem95 [ Cake ]
Release: 0.08b
Image
Osbios
Member
Member
Posts: 116
Joined: Fri Jun 10, 2005 11:00 pm

Post by Osbios »

lukem_95 wrote:just look at chris giese's code:

http://my.execpc.com/~geezer/osd/graphics/modes.c
Yes, this was the one I "stole" it from. :3
eddyb

Post by eddyb »

looks very nice. exactly what i need :D
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++;
}
but this seems to have problems.:roll:
have anyone figure out this functions ?
eddyb

Post by eddyb »

in my functions is a problem....
u, guys, how did it get to work in this problem?
pcmattman
Member
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:

Post by pcmattman »

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 ;).
eddyb

Post by eddyb »

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 :D

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++;
}
Now works fine, after i used direct memory plotting(VGA_MEM[offset]=color)
Attachments
yah, the screenshot of error
yah, the screenshot of error
ss_err.JPG (15.36 KiB) Viewed 3418 times
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

I think somebody plugged 16-bit code directly into 32-bit gcc. :roll:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

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;
}
~ Lukem95 [ Cake ]
Release: 0.08b
Image
Post Reply