Building A Diskless Automation Controller Using Windows XP Embedded
Building A Diskless Automation Controller Using Windows XP Embedded
All Products
|
Support
microsoft.com
MSDN Home | Developer Centers | Library | Downloads | Code Center | Subscriptions | MSDN Worldwide
All Products
| Support| | Search
Search | |microsoft.com
GuideHome
MSDN Home
Developer Centers
Library
Downloads
Code Center
Subscriptions
MSDN Worldwide
Search for
MSDN Home > MSDN Library > Mobile and Embedded Development > Embedded Operating System Development > Windows XP Embedded >
Go
All Library
Advanced Search
Page Options
Saad Syed
Microsoft Corporation
+ Welcome to the MSDN Library
November 2002
+ Component Development
+ Data Access
Applies to:
+ Development (General)
+ Enterprise Development
+ Graphics and Multimedia
+ Messaging and Collaboration
+ Windows CE
The Remote Boot Service delivered with Windows XP Embedded with Service Pack 1 is an example of how run-time images can be downloaded and booted. Changes to the operating
- Windows XP Embedded
- Windows XP Embedded with Service Pack 1
system loader, along with system deployment image (SDI) imaging, enable flexible and extensible RAM boot solutions.
+ Product Documentation
The opportunity now exists for OEMs to couple custom download protocols for Windows XP Embedded with Service Pack 1 RAM boot. This enables a broad range of new Windows XP
- Technical Articles
Embedded boot scenarios including multicast remote boot and CD RAM boot. This document will help you to learn how to extend RAM boot technology using custom protocols and boot
Contents
SDI Imaging
Preparing the SDI
Typical SDI Boot Sequence
OEM-Authored Boot Program
Code Sample
Additional Information
SDI Imaging
Microsoft Windows XP Embedded with Service Pack 1 run-times are loaded into RAM as SDI images. SDI is a portable file format for XP Embedded images. SDI imaging is a key
technology delivered with the Windows Embedded Studio, the platform development tools in Windows XP Embedded with Service Pack 1. Several tools are provided for building, editing,
and extracting images.
SDI images are stored as a single file with the following contents:
1. BOOT BLOB (boot program)
The SDI header contains the BOOT CODE OFFSET and BOOT CODE LENGTH, which point to the BOOT BLOB within the SDI. The boot blob contains the boot program STARTROM.
COM. It is a real mode executable file. To boot from the SDI, the boot blob is copied to the real mode address 0000:7C00h by the OEM-authored boot program. When passed
control, STARTROM.COM expects EDX = 32-bit physical address of the page aligned SDI image bitwise ORed with 41h. Sample code is provided later in this white paper that
demonstrates how this call is made.
2. LOAD BLOB (NTLDR)
The LOAD BLOB contains NTLDR. STARTROM.COM launches NTLDR that boots the run-time image from the PART BLOB by mounting it as a RAMDisk volume.
3. PART BLOB (Windows XP Embedded with Service Pack 1 run-time)
The PART BLOB contains the target run-time image. The run-time image is a post First Boot Agent (FBA) embedded run-time with the following requirements:
. Downloads
+ Windows NT Embedded
The run-time configuration must contain the "Windows RAM Disk Driver" component so it can be mounted as a RAMDisk volume.
The volume should have ntdetect.com and boot.ini in the root folder.
[boot loader]
. Code Samples
default=ramdisk(0)\WINDOWS
+ .NET Development
[operating systems]
ramdisk(0)\WINDOWS="Windows XPE
+ Security
+ Setup and System Administration
+ Web Development
SDI File Manager is a command line tool used to manipulate .sdi files. SDI Manager is installed in the utilities directory with the Windows Embedded Studio. It is used to prepare the SDI
+ Windows Development
+ XML Web Services
. MSDN Library Archive
for boot. The following steps outline the SDI preparation process.
1. Create a new .sdi file.
C:\SDI>sdimgr /new image.sdi
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
SDI File Manager version 1.00.621
Copyright (C) 1999-2001 Microsoft Corp. All Rights Reserved.
SDI File
MDB Type
Boot Code Offset
Boot Code Size
Vendor ID
Device ID
Device Model
Device Role
Runtime GUID
Runtime OEM Rev
Page Alignment
:
:
:
:
:
:
:
:
:
:
:
C:\SDI\image.sdi
--0x00000000.00000000
0x00000000.00000000
0x0000 (0)
0x0000 (0)
{00000000-0000-0000-0000-000000000000}
0
{00000000-0000-0000-0000-000000000000}
0
1 (4096 bytes)
2. Import the target partition into the SDI. The target partition should typically be an SDI Disk partition mounted by SDI Loader and formatted with the Disk Management Console. The
size of the partition must be less than 500 MB.
: "C:\SDI\image.sdi"...
: 1 (4096 bytes)
6. Verify that the SDI contains the BOOT, LOAD, and PART blob.
C:\SDI>sdimgr image.sdi
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
SDI File Manager version 1.00.621
Copyright (C) 1999-2001 Microsoft Corp. All Rights Reserved.
SDI File
MDB Type
Boot Code Offset
Boot Code Size
Vendor ID
Device ID
Device Model
Device Role
Runtime GUID
Runtime OEM Rev
Page Alignment
:
:
:
:
:
:
:
:
:
:
:
C:\SDI\image.sdi
--0x00000000.00001000
0x00000000.00005FF0
0x0000 (0)
0x0000 (0)
{00000000-0000-0000-0000-000000000000}
0
{00000000-0000-0000-0000-000000000000}
0
1 (4096 bytes)
Type Offset
---- ---------------------------BOOT 0x00000000.00001000
0x00000000
LOAD 0x00000000.00007000
0x00000000
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxpesp1/html/ram_sdi.asp (3 von 6)28.12.2003 02:09:37
Size
Base Address
Attr
------------------- ------------------0x00000000.00005FF0 0x00000000.00000000
0x00000000.00034A00 0x00000000.00000000
Code Sample
The following code sample contains the BootSDI function, which performs steps 4 through 7 in the typical SDI boot sequence.
The function _BootSDI should be called from protected mode with basic flat model addressing. It needs the 32-bit physical address of the SDI as a parameter (on stack).
REAL_MODE_SEGMENT is the real mode code segment address of the boot code. This is the segment where the OEM boot program will relocate itself.
CODE_16_SELECTOR is a 16-bit code selector with a descriptor base address equal to the physical address of the OEM relocated boot program (REAL_MODE_SEGMENT << 4).
REAL_MODE_SEGMENT
CODE_16_SELECTOR
SDIHeader
struc
Signature
db
8 dup(?)
SDIReserved1
dd
?
SDIReserved2
db
4 dup(?)
BootCodeOffsetLow
dd
?
BootCodeOffsetHigh
dd
?
BootCodeSizeLow
dd
?
BootCodeSizeHigh
dd
?
SDIHeader
ends
_TEXT32 segment para use32 public 'CODE'
ASSUME CS:_TEXT32
ALIGN 4
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxpesp1/html/ram_sdi.asp (4 von 6)28.12.2003 02:09:37
public _BootSDI
;++
;
; VOID
; BootSDI(
;
VOID *pSDI
; );
;
;
; Description:
;
This routine executes the boot code from an SDI. It takes the
;
physical address of
;
the SDI image (4K aligned), obtains the boot code offset and boot
;
code
;
length from the SDI Header. It copies the boot code to 0000:7C00,
;
switches back to real mode, sets EDX = SDI Physical Address OR
;
0x41;
;
Then jumps to 0000:7C00 to perform the boot.
;
; Environment:
;
Protected Mode ONLY, basic flat model addressing required for
;
_BootSDI.
;
; Arguments:
;
Pointer to SDI image mapped into memory.
;
; Returns:
;
Does not return.
;
;--
;
;
16-bit call gate for _BootSDI16
;
_BootSDI
proc
near
push
push
retf
_BootSDI endp
_TEXT32
ends
proc
near
ebp
ebp, esp
cli
mov
mov
mov
edx, [ebp + 8]
; SDI Address
ebx, edx
; EBX = SDI Header
esi, ebx
add
esi, [ebx].BootCodeOffsetLow
; ESI points to the BOOT BLOB
; (SDIHeader+BootCodeOffset)
mov
ecx, [ebx].BootCodeSizeLow
; ECX has the boot code length
mov
edi, 07C00h
; EDI = Destination realmode address
; of boot code
cld
db
rep
067h
movsb
; move forward
; 32-bit address size prefix
; move boot blob to 0:7C00
mov
eax,cr0
and
eax, not 080000001h
; turn off paging
mov
cr0,eax
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxpesp1/html/ram_sdi.asp (5 von 6)28.12.2003 02:09:37
;
; Switch to real mode
;
jmp
RealMode:
mov
eax,cr3
nop
nop
nop
nop
mov
cr3,eax
; Flush TLB
;
; switch to real mode addressing
;
db
0EAh
; JMP FAR PTR
dw
OFFSET _TEXT:RealModeAddress
; RealModeSegment:RealModeAddress
dw
REAL_MODE_SEGMENT
; RealModeSegment value
RealModeAddress:
lidt
sti
mov
mov
mov
or
; re-enable interrupts
ax,30
ss,ax
esp,0100h
dl,041h
push
push
retf
0
07c00h
; Jump to 0:7C00
_BootSDI16
endp
IDTRegisterZero dw
dd
_TEXT
;
; Setup stack for boot code
;
0ffffh
0
ends
Additional Information
For more information about the SDI manager, see SDI Manager in the production documentation.