flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Boot problem (vesa mode)

Author
Thread Post new topic Reply to topic
grunge



Joined: 11 Sep 2005
Posts: 21
Location: Brasil
grunge
Hello All

I have one new problem Embarassed ... now I use the vesa mode in my OS... but have one problem in the boot... when I use the vesa mode directely in bootloader, the graph is correct, but when I use the all code of vesa mode as kernel, the graph is not correct, think that problem must be in the segments when kernel is loaded, I trying, but dont have one positive result, this problem can be solved? I use the "bootmosf.asm"(MenuetOS) for my study... already tried others bootloaders... but dont have one positive result... I need help...

Thanks for All...


My code (is my vesa test...)

Code:
;ORG 100h


;   Mov   AX,1000h ; HERE IS POSSIBLE PROBLEM
;   Mov   DS,AX
;   Mov   ES,AX

Start:
   mov ax,4f02h
   mov bx,101h
   int 10h


   mov dx,0xa000
   mov es,dx
   call window

StartAgain:
   xor dx,dx
   mov [Cor],0


      
MainLoop:

   Mov  [y],100
   Mov  [x],100
   Call Pixel


B1:
   push dx
   call window
   xor bx,bx        
   pop dx
   inc dx
   push dx
   call window
   xor bx,bx       
   pop dx

B2:
   push dx
   call window
   xor bx,bx        
   pop dx
   inc dx
   push dx
   call window
   xor bx,bx       
   pop dx

B3:
   push dx
   call window
   xor bx,bx        
   pop dx
   inc dx
   push dx
   call window
   xor bx,bx       
   pop dx

B4:
   push dx
   call window
   xor bx,bx        
   pop dx
   inc dx
   push dx
   call window
   xor bx,bx       
   pop dx



   mov byte [Row],7
   mov edi,262500 ; Position
   mov bx,di ; ver
   mov si,LetterR
   mov dh,0ah
   call DrawImage

   Mov [y],410
   Mov [x],20
   Call Pixel

   Mov [y],410
   Mov [x],620
   Call Pixel



B0:
   push dx
   mov dx,0xa000
   mov es,dx
   call window

   xor dx,dx
   pop dx


   mov byte [Row],7
   mov edi,51250
   mov bx,di
   mov si,LetterR
   mov dh,0ah
   call DrawImage

   Mov   [y],100
   Mov   [x],200
   Call  Pixel

   mov ah,01h
   int 16h

   mov ah,00h
   int 16h
   mov ax,0003h
   int 10h

   ret

Pixel:

   Push  DX
   Push  ES
   Mov   AX,0A000h 
   Mov   ES,AX
   Mov   AX,640
   Mul   [y] 
   Add   AX,[x] 
   Mov   BX,AX
   Mov   DL,9
   Mov   [ES:BX],DL
   Pop   ES
   Pop   DX
   Retn

window:
        mov ax,4f05h
        mov bx,0
        int 10h
        xor bx,bx
        ret

DrawImage:
        mov di,bx ; ver
        mov dl,[Row]
        cld
GetData:    
        lodsw
        mov bx,ax 
        mov cl,16
CheckBit:
        test bx,0x8000 ; bx
        jz ZeroBit
        mov al,dh    
        stosb
        jmp Skip                    
ZeroBit:
        inc di
Skip:
        shl bx,1  
        loop CheckBit          
        add di,624
        dec dl
        jnz  GetData
        ret

Cor    DB 0
x      DW 0
y      DW 0

Row      DB         0
LetterR  DW         7800h,4400h,4400h,7800h,4400h,4400h,4400h    


BootMosf:

Code:
;=======================================================
;= boot program for Menuet OS version 1.00
;= January 2002
;=
;= Copyright (C) Alex Nogueira Teixeira
;= E-Mail : alexwal@siteplanet.com.br
;=
;= Distributed under GPL, see file COPYING for details
;=
;= equates for program
;=======================================================
   
lf  equ 0ah
cr  equ 0dh
   
pos_read_tmp       equ 0700h ;position for temporary read
boot_program       equ 07c00h ;position for boot code
seg_read_kernel    equ 01000h ;seguiment to kernel read
   
                   jmp start_program
                   nop
   
oemname            db 'MENUETOS'
bytespersector     dw 512
sectorspercluster  db 1
ressectors         dw 1
numcopiesfat       db 2
maxallocrootdir    dw 224
maxsectors         dw 2880 ;for 1.44 mbytes disk
mediadescriptor    db 0f0h ;fd = 2 sides 18 sectors
sectorsperfat      dw 9
sectorspertrack    dw 18
heads              dw 2
hiddensectors      dd 0
hugesectors        dd 0 ;if sectors > 65536
drivenumber        db 0
                   db 0
bootsignature      db 029h ;extended boot signature
volumeid           dd 0
volumelabel        db 'MENUET DISK'
filesystemtype     db 'FAT12   '


start_program:

  xor ax,ax
  mov ss,ax
  mov sp,boot_program
  push ss
  pop ds

  mov  si,loading+boot_program
loop_loading:
  lodsb
  or al,al
  jz procura_arquivo_novamente
  mov ah,0eh
  mov bx,07h
  int 010h
  jmp loop_loading


procura_arquivo_novamente:

  push ss
  pop es

  mov  bp,16

newtry:

  dec bp
  jz  mensagem_erro_arquivo

  mov ax,020eh ;read, 14 sectors for directory
  mov bx,pos_read_tmp ;es:bx read position
  mov cx,02h ;track 0, sector 2
  mov dx,0100h ;head 1, drive 0 (aSmile
  call read_sector
;  int 013h ;read sectors
;  jc  newtry ; mensagem_erro_arquivo

  mov si,bx

loop_compara_entrada_diretorio:

  push si
  mov cx,11 ;file name
  mov di,arq_boot+boot_program
  rep cmpsb
  pop si
  je le_arquivo_kernel
  add si,32
  cmp si,pos_read_tmp+(512*14) ;end of directory
  jb loop_compara_entrada_diretorio

mensagem_erro_arquivo:

  mov si,mens_erro+boot_program

loop_envio_mensagem:

  lodsb
  or al,al
  jz espera_digitar_tecla
  mov ah,0eh
  mov bx,07h
  int 010h
  jmp loop_envio_mensagem

espera_digitar_tecla:

  jmp $


; load kernel

le_arquivo_kernel:

  mov bp,[si+01ah]
  mov ax,0209h ;read, 9 sectors
  mov bx,pos_read_tmp ;es:bx read position
  mov cx,02h ;track 0, sector 2
  xor dx,dx ;head 0, drive 0 (aSmile
  call read_sector
;  int 013h  ;read sectors
  jc mensagem_erro_arquivo
  mov ax,seg_read_kernel
  mov es,ax
  xor bx,bx

  ; read kernel to es:bx 

loop_obtem_dados_kernel:
  call le_setor_dados
  jc mensagem_erro_arquivo
;  add bx,0200h ;add one sector

  push bx
  mov bx,es
  add bx,0x20
  mov es,bx
  pop bx

  mov di,bp
  shr di,01h
  pushf
  add di,bp
  add di,pos_read_tmp
  mov ax,[di]
  popf
  jc desloca_4_direita
  and ax,0fffh
  jmp verifica_fim_setores
desloca_4_direita:
  mov cl,4
  shr ax,cl
verifica_fim_setores:
  cmp ax,0ff8h
  jae executa_kernel
  mov bp,ax
  jmp loop_obtem_dados_kernel

executa_kernel:
  push word seg_read_kernel
  push word 00h
  retf


le_setor_dados: ;es:bx -> position in read buffer

  ;bp -> logical sector to read
  ;carry <- 0 read OK
  ;carry <- 1 read error
  push bx
  mov ax,0e2eh ;decimal point
  xor bh,bh
  int 010h
  pop bx
  mov ax,bp ;data sector to read
  add ax,31 ;get logical sector
  mov cx,36 ;sector/track
  xor dx,dx
  div cx
  mov ch,al ;track transfer
  xor dh,dh ;head 0
  cmp dl,18
  jb cabeca_correta
  sub dl,18
  inc dh ;head 1
cabeca_correta:
  inc dl
  mov cl,dl
  xor dl,dl ;drive 0 (aSmile
  mov ax,0201h ;read 1 sector
  call read_sector
;  int 013h
  retn

read_sector:

  push bp
  mov  bp,20
 newread:
  dec  bp
  jz   mensagem_erro_arquivo
  push ax bx cx dx
  int  0x13
  pop  dx cx bx ax
  jc   newread
  pop  bp
  retn

loading   db 13,10,'Starting MenuetOS ',00h
mens_erro:
          db 13,10
arq_boot:
          db 'KERNEL  BIN ?',cr,lf,00h
errors    db 16


times 0x1fe-$ db 00h

  db 55h,0aah ;boot signature
   
   
    
Post 21 Oct 2006, 23:25
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
I have tested your code, i get a R .. nere to the top of page and the same at the bottom maybe a bit more spaced out.
But i do not know what it should look like, here is the way i booted it
With this program http://www.dex4u.com/Redragon/kernel.zip
This will put a com file loader on a floppy, all you need do is call your test program "kernel16.com" and put it on the floppy to test your OS.
Post 22 Oct 2006, 00:39
View user's profile Send private message Reply with quote
grunge



Joined: 11 Sep 2005
Posts: 21
Location: Brasil
grunge
Ok Dex4u...

I tried your program and replace my bootloader for one that run EXE & COM (ORGs 100h)... now my graph is correct! I study your demo for vesa in 32 bits... tried for pixel and others... Smile thanks... if you have more examples of vesa in 32 bists... I thank...

Thanks for all...
Post 23 Oct 2006, 00:08
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
Your welcome, here's a demo i made of booting and displaying a 640x480bmp image from pmode using vesa2. http://www.dex4u.com/pascal/BmpView.zip
And also try CdPod here: http://board.flatassembler.net/topic.php?t=2164&start=60
Note: i was called ASHLEY4 when i made cdpod, also, cdpod will only work with a 32bpp vesa, as some use 24bpp.
Post 23 Oct 2006, 12:16
View user's profile Send private message Reply with quote
Mac2004



Joined: 15 Dec 2003
Posts: 313
Mac2004
Hi Grunge!

If you need a working simple binary boot sector you can use mine which is posted in this forum. Here's the link:

http://board.flatassembler.net/topic.php?t=6529

I did keep the boot loader as simple as possible because it's easier to add things when the base boot is properly working.

regards,
Mac2004
Post 14 Jan 2007, 14:16
View user's profile Send private message Reply with quote
grunge



Joined: 11 Sep 2005
Posts: 21
Location: Brasil
grunge
Hi Mac2004

Thanks for your idea, but my OS run with FAT and I tried one basic file system...

thanks,

grunge
Post 20 Jan 2007, 20:41
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.