0% found this document useful (0 votes)
187 views6 pages

Building A Diskless Automation Controller Using Windows XP Embedded

build diskless

Uploaded by

pandearroz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
187 views6 pages

Building A Diskless Automation Controller Using Windows XP Embedded

build diskless

Uploaded by

pandearroz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

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

Welcome to the MSDN Library

MSDN Home > MSDN Library > Mobile and Embedded Development > Embedded Operating System Development > Windows XP Embedded >

Go

All Library
Advanced Search

RAM Boot Using SDI in Windows XP Embedded with Service Pack 1

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

- Mobile and Embedded Development


- Embedded Operating System Development

Microsoft Windows XP Embedded with Service Pack 1


Summary: Discover how Microsoft Windows XP Embedded with Service Pack 1 provides the ability to boot an embedded run-time image directly from random access memory (RAM).
Often referred to as RAM boot, this technology allows embedded devices to boot without requiring persistent storage.

+ 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

. Adding Multiple Language Support in a

Windows XP Embedded Image


. Applying QFEs with Windows XP
Embedded Device Update Agent
. Building a Diskless Automation
Controller Using Windows XP Embedded
. Building and Deploying XP Embedded
Images
. Comparison of Windows XP Embedded
and Windows NT Embedded
. Hard Real-Time with Venturcom RTX on
Microsoft Windows XP and Windows XP
Embedded
. Introduction to MinLogon
. Managing a Real-Time Hardware
Interface with INtime and Windows XP
Embedded
. Microsoft Windows Embedded Studio
Development Tools for Windows XP
Embedded
. Microsoft Windows XP Embedded

programs. (10 printed pages)

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.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxpesp1/html/ram_sdi.asp (1 von 6)28.12.2003 02:09:37

Building a Diskless Automation Controller Using Windows XP Embedded

Technical Frequently Asked Questions


. RAM Boot Using SDI in Windows XP
Embedded with Service Pack 1
. Real-Time Operating Systems: INtime
Architecture
. Reducing the Windows XP Embedded
Run-time Image Size
. Third-Party Tools for Windows XP
Embedded
. Using Compact Flash (CF) with the
Enhanced Write Filter (EWF)
. Using the Enhanced Write Filter (EWF)
in Windows XP Embedded
. Windows XP Embedded with Service
Pack 1 Reliability
. Working with Netsh in Windows XP
Embedded
+ Windows XP Embedded

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.ini should have the following contents:

+ Server Appliance Kit


+ Columns
. Seminars
. Downloads
+ Windows Mobile
+ Windows Automotive

[boot loader]

. Code Samples

default=ramdisk(0)\WINDOWS

+ .NET Development

[operating systems]

+ Networking and Directory Services

ramdisk(0)\WINDOWS="Windows XPE

+ Office Solutions Development

From RAM" /fastdetect

+ Security
+ Setup and System Administration

The size of the run-time cannot exceed 500 MB.

+ User Interface Design and Development


+ Visual Tools and Languages

Preparing the SDI

+ 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.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxpesp1/html/ram_sdi.asp (2 von 6)28.12.2003 02:09:37

Building a Diskless Automation Controller Using Windows XP Embedded

C:\SDI>sdimgr image.sdi /readpart:f:


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.
*Reading from volume: "\\.\F:"...
3. Import the boot program STARTROM.COM into the SDI BOOT blob.
C:\SDI>sdimgr image.sdi /import:BOOT,0,startrom.com
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.
Imported File To Blob : startrom.com, Blob Type :BOOT
4. Import NTLDR into the SDI LOAD blob.
C:\SDI>sdimgr image.sdi /import:LOAD,0,ntldr
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.
Imported File To Blob : ntldr, Blob Type :LOAD
5. Pack the SDI to move the BOOT blob to the front, and align the blobs at a 4K boundary.
C:\SDI>sdimgr image.sdi /pack
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.
*Packing
New Page Alignment

: "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

Building a Diskless Automation Controller Using Windows XP Embedded

PART 0x00000000.0003C000 0x00000000.01780800 0x00000000.00000007


0x00000000
NTLDR and STARTROM.COM are provided with the Remote Boot Service Setup and installed in the \Program Files\Windows Embedded\Remote Boot Service\Downloads directory.

Typical SDI Boot Sequence


The following steps outline typical operations in an SDI boot sequence.
1. A custom protocol is used to acquire an OEM-authored boot program (boot code). This step is optional because the OEM's boot code may already reside on the device (in ROM, CD,
etc.).
2. If necessary, the boot code relocates itself away from 0000:7C00 to make room for STARTROM.COM.
3. The boot code copies the SDI into RAM, page-aligned. The image acquisition and selection mechanisms are defined by the OEM.
4. The boot code obtains the BOOT CODE OFFSET and BOOT CODE SIZE from the SDI Header.
5. The boot code copies the BOOT BLOB to physical address 07C00h.
6. The boot code switches to real mode, sets EDX = physical address of SDI bitwise ORed with 041h.
7. The boot code performs a jump to 0:7C00h to execute STARTROM.COM.
8. STARTROM.COM launches NTLDR from the LOAD blob.
9. Windows boots.

OEM-Authored Boot Program


The purpose of RAM boot is to allow OEMs to provide a boot solution that can integrate with custom technologies. Windows XP Embedded with Service Pack 1 provides one such solution
with Remote Boot Service. To complete the custom RAM boot solution, OEMs must author a boot program that can acquire the SDI image and load it into memory. It is possible for OEMs
to deliver this boot program by using the Pre-boot eXecution Environment (PXE, pronounced "pixie") and Trivial File Transfer Protocol (TFTP) support provided by Remote Boot Service (or
on a CD, floppy, or in EPROM). The job of the boot program is to acquire the appropriate SDI and place it into RAM (4K aligned).
After loading the SDI into memory the boot program has to transfer control to the boot code located inside the SDI. If the OEM protocol downloads the boot program at the address
0000:7C00h, the OEM boot program must relocate itself to another address to make that space available for the boot code. The boot code must be extracted from the SDI and placed at
the real mode address 0000:7C00h. The sample code that is provided in this paper illustrates how a custom boot program could complete the boot process.

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

equ <Supplied by OEM>


equ <Supplied by OEM>

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

; REAL MODE Segment address


; 16bit selector of boot code

Building a Diskless Automation Controller Using Windows XP Embedded

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

dword ptr CODE_16_SELECTOR


dword ptr (offset _BootSDI16)

retf

; 16-bit code selector

; Jump to 16-bit code

_BootSDI endp
_TEXT32

ends

_TEXT segment para use16 public 'CODE'


ASSUME CS:_TEXT
ALIGN 4
_BootSDI16
push
mov

proc

near

ebp
ebp, esp

; Save caller's stack frame & use EBP


; to reference stack parameters.

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
;

Building a Diskless Automation Controller Using Windows XP Embedded

jmp

far ptr RealMode

; flush the pipeline

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

fword ptr cs:[IDTRegisterZero]

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.

Contact Us | E-Mail this Page | MSDN Flash Newsletter


2003 Microsoft Corporation. All rights reserved. Terms of Use Privacy Statement
Accessibility

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxpesp1/html/ram_sdi.asp (6 von 6)28.12.2003 02:09:37

You might also like