flat assembler
Message board for the users of flat assembler.

Index > Windows > Can I include a binary in my code?

Author
Thread Post new topic Reply to topic
phpdevpad



Joined: 12 Jan 2013
Posts: 37
phpdevpad
Can I include a binary in my code and make an option rom from it and then start the binary (which itself is an option rom)? How would I do this? Is there an easy to understand example? Thank you very much!
Post 14 Jan 2013, 14:33
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Yes you can.
See "file" directive in the FASM guide. But I am not very sure what actually you want to do.
Also, I am not very sure you know, what you want to do. Wink
Post 14 Jan 2013, 15:26
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
phpdevpad



Joined: 12 Jan 2013
Posts: 37
phpdevpad
Thanks. I don't know pc asm. I know very good MC 68000. I want to compile an option rom and include another option rom and misc.bin file and load it when boot, relocate the data and start the option rom. Basically my problem is to update an old southbridge 700 with a new raid option rom. I got it working but the bios doesn't boot unless I press the esc-key. Hence I need a code for an option rom, a small copy routine and then I can make my own option rom? Can you help me?

Update: Here is my option rom wrapper but how can I start the option rom? Can I call it with call raidrom?
Code:
 ;---------------------------------------------------------------------------------
;---------------------------PCI ROM Header----------------------------------------
;---------------------------------------------------------------------------------

        ROM_SIZE_IN_BLOCK = 1           ; 1 means ROM size is 1 block (512 bytes)
        ROM_SIZE_IN_BYTE = ROM_SIZE_IN_BLOCK * 512

        VENDOR_ID       equ 1002h       ; PCI Vendor ID (must match your ethernet vendor id)
                                        ; exp: 10DE = nVidia
        DEVICE_ID       equ 4392h       ; PCI Device ID (must match your ethernet devicie id)
                                        ; exp: 0057h = nforce4 CK804 NIC

ROMStart:
        db 0x055, 0x0AA                 ; ROM Header 55,AA -> Bootable rom
        db (ROMEnd - ROMStart)/512      ; ROM Size in 512byte
        jmp MAIN

        db      0                       ; checksum, to be filled in later
        TIMES   18h-($-$$) DB 0         ; padding zeros to offset 18h
        DW      PCIHDR                  ; pointer to PCI Header
        DW      PNPHDR                  ; pointer to PnP Expansion Header

PCIHDR: DB      'PCIR'                  ; PCI data structure signature
        DW      VENDOR_ID               ; vendor ID                     (must match real PCI device)
        DW      DEVICE_ID               ; device ID                     (must match real PCI device)
        DW      0                       ; pointer to vital product data (0=none)
        DW      24                      ; PCI data structure length     [B]
        DB      0                       ; PCI data structure revision   (0=PCI 2.1)
        DB      2,0,0                   ; PCI device class code         (2=network ctrlr,0=eth.)
        DW      ROM_SIZE_IN_BLOCK       ; ROM size in 512B blocks
        DW      0                       ; revision level of code
        DB      0                       ; code type                     (0=x86 compitable)
        DB      80h                     ; last image indicator
        DW      0                       ; reserved

PNPHDR: DB      '$PnP'                  ; PnP data structure signature
        DB      1                       ; PnP structure revision
        DB      2                       ; PnP structure length          (in 16B blocks)
        DW      0                       ; offset to next header         (0-none)
        DB      0                       ; reserved
        DB      33h                     ; PnP structure checksum
        DD      0                       ; device identifier
        DW      0                       ; pointer to manufacturer string
        DW      0                       ; pointer to productname string
        DB      2,0,0                   ; device class code    (2=network ctrlr,0=eth.)
        DB      64h                     ; device indicators (64h - shadowable,cacheable,not 
                                        ; only for boot,IPL device)
        DW      0                       ; boot connection vector        (0-none)
        DW      0                       ; disconnect vector             (0-none)
        DW      0                       ; bootstrap entry vector        (0-none)
        DW      0                       ; reserved
        DW      0                       ; static resource info vector   (0-none)



MAIN:
        pushfd
        push    eax
        push    ebx
        push    bx
        push    dx
        push    si
        push    ds
        push    bp


        pop bp
        pop ds
        pop si
        pop dx
        pop bx
        pop ebx
        pop eax
        popfd
        retf                            ; return far to system bios routine


raidrom:      file "raid.bin"



        times (ROM_SIZE_IN_BYTE-$) db 0 ; use 00h as the padding bytes until we reach the ROM size

        ; The last byte (512th) will be the patch_byte for the checksum
        ; patch_byte is calculated and automagically inserted below
        PREV_CHKSUM = 0
        repeat $
        load CHKSUM byte from %-1
        CHKSUM = (PREV_CHKSUM + CHKSUM) mod 0x100
        PREV_CHKSUM = CHKSUM
        end repeat
        store byte (0x100 - CHKSUM) at ($-1)  ; store the patch_byte
ROMEnd:       
Post 14 Jan 2013, 15:34
View user's profile Send private message Visit poster's website 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.