×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Custom staged BIOS help

Custom staged BIOS help

Custom staged BIOS help

(OP)
Hello, I am a newbie to assembly. I am working with a custom Bios that does not boot the mbr of the first drive but a custom binary file on the first partition of the first drive. It is written in 32bit nasm and loads a linux kernel directly. What I am trying to do is figure out a way to have it load a bootloader like grub or lilo. The problem is most boot loaders are 16bit so is there way to write the code so it  changes to 16bit and then loads the file and runs it?? Here is the code from stage2.asm:

CODE


bits 32
%define write_console 0082F158h
%define open_file 00808C94h
%define read_file 0080940Ch
%define outp 00828C64h
%define setup_video 82B890h
%define reset 008016CCh
%define initialise 008309C8h
%define set_vid_mode 008137DCh
%define turnoff 008013A4h
%define wait 0082EF98h


org 0x1000000

        mov    edx, 84Dh
        mov    eax, 0C0h ; 'À'
        out    dx, al


        
        cld
        push    1
        call    setup_video
        add    esp, 4
        push    3
        push    vmlinux_bin
        call    open_file
        add    esp, 8
        push    0FFFFFFFFh
        push    100000h
        push    eax
        call    read_file
        add    esp, 0Ch
        push    eax
        push    loadkernel
        call    write_console
        add    esp, 8
        mov    ebx, 90000h
        xor    eax, eax
        mov    edi, ebx
        mov    ecx, 0F00h
        rep stosb
        push    3
        push    cmdline
        call    open_file
        push    0FFFFFFFFh
        push    edi
        push    eax
        call    read_file
        cmp    eax, 0
        jge    continue
        xor    eax, eax

continue    mov    byte [edi+eax], 0
        push    edi
        push    commandline
        call    write_console
        add    esp, 8

; not exactly sure what these lines are for
        mov    word [ebx+20h], 0A33Fh
        mov    word [ebx+22h], 0F00h
        mov    word [ebx+2], 0FFFFh
        mov    dword [ebx+1E0h], 1F800h

        push    setupgdt
        call    write_console
        add    esp, 4
        mov    esi, 90000h
        cli
        lgdt    [ds:gdtinfo]

        jmp    10h:100000h
        ret


; ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

vmlinux_bin    db 'vmlinux.bin',0
loadkernel    db 'loadKernel:',9,' %d bytes read',0Ah
        db 0Dh,0
setupgdt    db 'setting up GDT',0Ah
        db 0Dh,'jumping to kernel entry',0Ah
        db 0Dh,0
cmdline        db 'cmdline',0
commandline    db 'command line: %s',0Ah
        db 0Dh,0



gdt32           db 0x00,0x00, 0x00,0x00, 0x00, 00000000b, 00000000b, 0
                db 0x00,0x00, 0x00,0x00, 0x00, 00000000b, 00000000b, 0
                db 0xff,0xff, 0x00,0x00, 0x00, 10011010b, 11001111b, 0
                db 0xff,0xff, 0x00,0x00, 0x00, 10010010b, 11001111b, 0
                db 0xff,0xff, 0x00,0x00, 0x00, 10010010b, 11001111b, 0

gdtend

gdtinfo dw (gdtend - gdt32 - 1)
        dd (gdt32)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close