This is CD boot loader, USB loader is similar few lines different.
CD will boot only if num lock is disabled. You can remove this feature. It
is intended that when CD completes installation and reboots to make deployed
XPe execute by default.
offset 506 contains start, and end pos of image data on disk, expressed in
MB.
BTW. You can remove my ugly progress or modify it.
Regards,
Slobodan
;***************************************************************************
**
;******************************* PBR Loader
***********************************
;***************************** Slobodan Brcin 05.10.2003.
*************************
;***************************************************************************
**
SDIDestMem equ (1024*1024*64)
TITLE bootloader
..model small
..386P
..code
jmp start
db '3B-Elekt' ; BS_OEMName
dw 512 ; BPB_BytsPerSec ; OK
db 4 ; BPB_SecPerClus ; OK 2KB/Cluster
dw 1 ; BPB_RsvdSecCnt ; OK
db 1 ; BPB_NumFATs ; Non standard but for Flash OK
dw 512 ; BPB_RootEntCnt ; Recommended
dw 0 ; BPB_TotSec16 ; OK
db 0F8h ; BPB_Media ; Fixed ?????
dw 0FCh ; BPB_FATSz16
dw 32 ; BPB_SecPerTrk
dw 64 ; BPB_NumHeads
dd 0 ; BPB_HiddSec
dd 256*2048 ; BPB_TotSec32
db 80h ; BS_DrvNum ; HDD
db 00h ; BS_Reserved1
db 29h ; BS_BootSig
dd 06Eh ; BS_VolID
db '12345678901' ; BS_VolLab
db 'FAT16 ' ; BS_FilSysType
; --------------------------------------------------------------------------
--------------------
; ------------------------------------- RUN SDI Image
Begin ------------------------------------
; --------------------------------------------------------------------------
--------------------
RunXPE: cli
mov ax,30 ;
mov ss,ax ; Setup stack for boot code
mov esp,0100h ;
sti
mov ax, 02000h
mov es, ax
mov ax, 0
mov ds, ax
mov esi, 0FC00h
CodeCopy: mov eax, ds:[esi-8000h]
mov es:[si], eax
add si, 4
jnz CodeCopy
push 02000h
push 0fc00h + LabGo
retf ; Jump to 2000:FCxx
LabGo: mov edx, SDIDestMem
mov esi, edx
mov edi, 7C00h
call CopyMem
add esi, ds:[7c00h + 10h] ; BootCodeOffset
call CopyMem
add esi, 4000h
add edi, 4000h
call CopyMem
or dl,041h
push 0
push 07c00h
retf ; Jump to 0:7C00
; --------------------------------------------------------------------------
--------------------
; ------------------------------------- RUN SDI Image
End --------------------------------------
; --------------------------------------------------------------------------
--------------------
CopyMem: pushad
push es
mov ax, 5000h
mov es, ax
mov bp, 0
CopyMem1: mov word ptr es:[bp], 0
add bp, 2
cmp bp, 30h
jne CopyMem1
mov es:[12h], esi
mov es:[1Ah], edi
mov byte ptr es:[15h], 93h
mov byte ptr es:[1Dh], 93h
mov word ptr es:[10h], 32*512*2
mov word ptr es:[18h], 32*512*2
mov eax, esi
shr eax, 24
mov es:[17h], al
mov eax, edi
shr eax, 24
mov es:[1Fh], al
mov si, 0
mov cx, 32*512
mov ah, 87h
int 15h
pop es
popad
ret ; CF - Set on error
;AX - 0..1023 cylinder
;DH = head number
;DL = drive number (bit 7 set for hard disk)
;EDI = IO - Flat dest
LoadHead: pushad
push es
mov ch, al
mov cl, ah
shl cl, 6
or cl, 1
mov ax, 0200h + 32
mov bx, 1000h
mov es, bx
mov bx, 0
int 13h
jc LoadHead_E
mov esi, 10000h
call CopyMem
LoadHead_E: pop es
popad
ret ; CF - Set on error
;AX - 0..1023 cylinder
;DL = drive number (bit 7 set for hard disk)
;EDI = IO - Flat dest
LoadCyl: push dx
mov dh, 0
LoadCyl_1: call LoadHead
jc LoadCyl_E
inc dh
add edi, 32*512
cmp dh, 64
jne LoadCyl_1
clc
LoadCyl_E: pop dx
ret
start:
mov ah, 2
int 16h
and al, 20h
jz starting ; Num - lock off - starting
int 18h
starting:
mov ax, 0b800h
mov es, ax
mov di, 0
mov cx, 80*25
mov ax, 0
rep stosw
mov si, 160*24
mov edi, SDIDestMem
mov ax, cs:[7C00h+506]
l22: call LoadCyl
mov bh, 18h
mov bl, 'E'
jc errr
mov bl, 'O'
errr: mov es:[si], bx
errr2: jc errr2
add si, 2
inc ax
cmp ax, cs:[7C00h+508]
jne l22
jmp RunXPE
org 506
dw 1, 68
dw 0AA55h
END
Don Noonan said:
I would like to include the BOOT, PART, and BLOB in the SDI so that the
image can boot using the NTLDR, BOOT.INI, and NTDETECT.COM inside the SDI,
not externally. This eliminates the assumption that the host has a
compatible version of NTLDR, and additional entries in the BOOT.INI (i.e.
RAMDISK(0))
Using the info in the threads for booting from El Torito or local hard
disk assumes you are using an external NTLDR, BOOT.INI, and NTDETECT.COM,
and that your SDI image only contains the PART section.
If someone (Slobodan / Saad) has assembly source that can successfully do
all the steps in Saad's whitepaper (1-9), I would really appreciate it!

Even if it is for a different OS loader, it would really help!