ReactOS  0.4.15-dev-5097-g328cc41
pxe.c File Reference
#include <freeldr.h>
#include <debug.h>
Include dependency graph for pxe.c:

Go to the source code of this file.

Macros

#define TAG_PXE_FILE   'FexP'
 
#define NO_FILE   ((ULONG)-1)
 

Functions

 DBG_DEFAULT_CHANNEL (FILESYSTEM)
 
static PPXE FindPxeStructure (VOID)
 
static PPXE GetPxeStructure (VOID)
 
PXENV_EXIT __cdecl PxeCallApi (UINT16 Segment, UINT16 Offset, UINT16 Service, VOID *Parameter)
 
BOOLEAN CallPxe (UINT16 Service, PVOID Parameter)
 
static ARC_STATUS PxeClose (ULONG FileId)
 
static ARC_STATUS PxeGetFileInformation (ULONG FileId, FILEINFORMATION *Information)
 
static ARC_STATUS PxeOpen (CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
 
static ARC_STATUS PxeRead (ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
 
static ARC_STATUS PxeSeek (ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
 
const DEVVTBLPxeMount (ULONG DeviceId)
 
static ARC_STATUS PxeDiskClose (ULONG FileId)
 
static ARC_STATUS PxeDiskGetFileInformation (ULONG FileId, FILEINFORMATION *Information)
 
static ARC_STATUS PxeDiskOpen (CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
 
static ARC_STATUS PxeDiskRead (ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
 
static ARC_STATUS PxeDiskSeek (ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
 
static BOOLEAN GetCachedInfo (VOID)
 
BOOLEAN PxeInit (VOID)
 

Variables

static IP4 _ServerIP = { 0, }
 
static ULONG _OpenFile = NO_FILE
 
static CHAR _OpenFileName [128]
 
static ULONG _FileSize = 0
 
static ULONG _FilePosition = 0
 
static ULONG _PacketPosition = 0
 
static UCHAR _Packet [1024]
 
static ULONG _CachedLength = 0
 
static const DEVVTBL PxeVtbl
 
static const DEVVTBL PxeDiskVtbl
 

Macro Definition Documentation

◆ NO_FILE

#define NO_FILE   ((ULONG)-1)

Definition at line 26 of file pxe.c.

◆ TAG_PXE_FILE

#define TAG_PXE_FILE   'FexP'

Definition at line 25 of file pxe.c.

Function Documentation

◆ CallPxe()

BOOLEAN CallPxe ( UINT16  Service,
PVOID  Parameter 
)

Definition at line 85 of file pxe.c.

86 {
87  PPXE pxe;
89 
90  pxe = GetPxeStructure();
91  if (!pxe)
92  return FALSE;
93 
94  if (Service != PXENV_TFTP_READ)
95  {
96  // HACK: this delay shouldn't be necessary
97  KeStallExecutionProcessor(100 * 1000); // 100 ms
98  TRACE("PxeCall(0x%x, %p)\n", Service, Parameter);
99  }
100 
102  if (exit != PXENV_EXIT_SUCCESS)
103  {
104  ERR("PxeCall(0x%x, %p) failed with exit=%d status=0x%x\n",
106  return FALSE;
107  }
109  {
110  ERR("PxeCall(0x%x, %p) succeeded, but returned error status 0x%x\n",
112  return FALSE;
113  }
114  return TRUE;
115 }
SEGOFF16 EntryPointSP
Definition: pxe.h:47
#define TRUE
Definition: types.h:120
_In_ PVOID Parameter
Definition: ldrtypes.h:241
OFF16 offset
Definition: pxe.h:34
#define FALSE
Definition: types.h:117
#define PXENV_EXIT_SUCCESS
Definition: pxe.h:457
#define TRACE(s)
Definition: solgame.cpp:4
SEGSEL segment
Definition: pxe.h:35
Definition: pxe.h:38
UINT16 PXENV_EXIT
Definition: pxe.h:7
#define ERR(fmt,...)
Definition: debug.h:110
#define PXENV_TFTP_READ
Definition: pxe.h:589
#define PXENV_STATUS_SUCCESS
Definition: pxe.h:461
PXENV_EXIT __cdecl PxeCallApi(UINT16 Segment, UINT16 Offset, UINT16 Service, VOID *Parameter)
UINT16 PXENV_STATUS
Definition: pxe.h:8
void exit(int exitcode)
Definition: _exit.c:33
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:81
static PPXE GetPxeStructure(VOID)
Definition: pxe.c:72

Referenced by GetCachedInfo(), PxeClose(), PxeOpen(), PxeRead(), and PxeSeek().

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( FILESYSTEM  )

◆ FindPxeStructure()

static PPXE FindPxeStructure ( VOID  )
static

Definition at line 38 of file pxe.c.

39 {
40  PPXE Ptr;
41  UCHAR Checksum;
42  UCHAR i;
43 
44  /* Find the '!PXE' structure */
45  Ptr = (PPXE)0xA0000;
46  while ((ULONG_PTR)Ptr > 0x10000)
47  {
48  Ptr = (PPXE)((ULONG_PTR)Ptr - 0x10);
49 
50  /* Look for signature */
51  if (memcmp(Ptr, "!PXE", 4) != 0)
52  continue;
53 
54  /* Check size */
55  if (Ptr->StructLength != sizeof(PXE))
56  continue;
57 
58  /* Check checksum */
59  Checksum = 0;
60  for (i = 0; i < Ptr->StructLength; i++)
61  Checksum += *((PUCHAR)Ptr + i);
62  if (Checksum != 0)
63  continue;
64 
65  TRACE("!PXE structure found at %p\n", Ptr);
66  return Ptr;
67  }
68 
69  return NULL;
70 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
unsigned char * PUCHAR
Definition: retypes.h:3
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define TRACE(s)
Definition: solgame.cpp:4
unsigned char UCHAR
Definition: xmlstorage.h:181
Definition: pxe.h:38
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
struct s_PXE * PPXE

Referenced by GetPxeStructure().

◆ GetCachedInfo()

static BOOLEAN GetCachedInfo ( VOID  )
static

Definition at line 327 of file pxe.c.

328 {
330  BOOLEAN res;
331  UCHAR* Packet;
332 
333  RtlZeroMemory(&Data, sizeof(Data));
335 
337  if (!res)
338  return FALSE;
339  if (Data.BufferSize < 36)
340  return FALSE;
341  Packet = (UCHAR*)((ULONG_PTR)(Data.Buffer.segment << 4) + Data.Buffer.offset);
342  RtlCopyMemory(&_ServerIP, Packet + 20, sizeof(IP4));
343  return TRUE;
344 }
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
Definition: pxe.h:16
#define PXENV_PACKET_TYPE_CACHED_REPLY
Definition: pxe.h:403
#define TRUE
Definition: types.h:120
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG _In_opt_ PVOID Data
Definition: wdfdevice.h:4527
#define PXENV_GET_CACHED_INFO
Definition: pxe.h:597
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
unsigned char UCHAR
Definition: xmlstorage.h:181
BOOLEAN CallPxe(UINT16 Service, PVOID Parameter)
Definition: pxe.c:85
GLuint res
Definition: glext.h:9613
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
static IP4 _ServerIP
Definition: pxe.c:28

Referenced by PxeInit().

◆ GetPxeStructure()

static PPXE GetPxeStructure ( VOID  )
static

Definition at line 72 of file pxe.c.

73 {
74  static PPXE pPxe = NULL;
75  static BOOLEAN bPxeSearched = FALSE;
76  if (!bPxeSearched)
77  {
78  pPxe = FindPxeStructure();
79  bPxeSearched = TRUE;
80  }
81  return pPxe;
82 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
Definition: pxe.h:38
#define NULL
Definition: types.h:112
static PPXE FindPxeStructure(VOID)
Definition: pxe.c:38

Referenced by CallPxe(), PxeInit(), and PxeMount().

◆ PxeCallApi()

PXENV_EXIT __cdecl PxeCallApi ( UINT16  Segment,
UINT16  Offset,
UINT16  Service,
VOID Parameter 
)

Referenced by CallPxe().

◆ PxeClose()

static ARC_STATUS PxeClose ( ULONG  FileId)
static

Definition at line 117 of file pxe.c.

118 {
119  t_PXENV_TFTP_CLOSE closeData;
120 
121  if (_OpenFile == NO_FILE || FileId != _OpenFile)
122  return EBADF;
123 
124  RtlZeroMemory(&closeData, sizeof(closeData));
125  if (!CallPxe(PXENV_TFTP_CLOSE, &closeData))
126  return EIO;
127 
128  _OpenFile = NO_FILE;
129  return ESUCCESS;
130 }
Definition: arc.h:32
static ULONG _OpenFile
Definition: pxe.c:29
Definition: arc.h:36
#define PXENV_TFTP_CLOSE
Definition: pxe.h:588
#define NO_FILE
Definition: pxe.c:26
BOOLEAN CallPxe(UINT16 Service, PVOID Parameter)
Definition: pxe.c:85
Definition: arc.h:40
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by PxeSeek().

◆ PxeDiskClose()

static ARC_STATUS PxeDiskClose ( ULONG  FileId)
static

Definition at line 289 of file pxe.c.

290 {
291  // Nothing to do
292  return ESUCCESS;
293 }
Definition: arc.h:32

◆ PxeDiskGetFileInformation()

static ARC_STATUS PxeDiskGetFileInformation ( ULONG  FileId,
FILEINFORMATION Information 
)
static

Definition at line 295 of file pxe.c.

296 {
297  // No disk access in PXE mode
298  return EINVAL;
299 }
Definition: arc.h:39

◆ PxeDiskOpen()

static ARC_STATUS PxeDiskOpen ( CHAR Path,
OPENMODE  OpenMode,
ULONG FileId 
)
static

Definition at line 301 of file pxe.c.

302 {
303  // Nothing to do
304  return ESUCCESS;
305 }
Definition: arc.h:32

◆ PxeDiskRead()

static ARC_STATUS PxeDiskRead ( ULONG  FileId,
VOID Buffer,
ULONG  N,
ULONG Count 
)
static

Definition at line 307 of file pxe.c.

308 {
309  // No disk access in PXE mode
310  return EINVAL;
311 }
Definition: arc.h:39

◆ PxeDiskSeek()

static ARC_STATUS PxeDiskSeek ( ULONG  FileId,
LARGE_INTEGER Position,
SEEKMODE  SeekMode 
)
static

Definition at line 313 of file pxe.c.

314 {
315  // No disk access in PXE mode
316  return EINVAL;
317 }
Definition: arc.h:39

◆ PxeGetFileInformation()

static ARC_STATUS PxeGetFileInformation ( ULONG  FileId,
FILEINFORMATION Information 
)
static

Definition at line 132 of file pxe.c.

133 {
134  if (_OpenFile == NO_FILE || FileId != _OpenFile)
135  return EBADF;
136 
138  Information->EndingAddress.LowPart = _FileSize;
139  Information->CurrentAddress.LowPart = _FilePosition;
140 
141  TRACE("PxeGetFileInformation(%lu) -> FileSize = %lu, FilePointer = 0x%lx\n",
142  FileId, Information->EndingAddress.LowPart, Information->CurrentAddress.LowPart);
143 
144  return ESUCCESS;
145 }
Definition: arc.h:32
static ULONG _OpenFile
Definition: pxe.c:29
Definition: arc.h:36
static ULONG _FilePosition
Definition: pxe.c:32
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1044
#define TRACE(s)
Definition: solgame.cpp:4
#define NO_FILE
Definition: pxe.c:26
static ULONG _FileSize
Definition: pxe.c:31
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

◆ PxeInit()

BOOLEAN PxeInit ( VOID  )

Definition at line 346 of file pxe.c.

347 {
348  static BOOLEAN Initialized = FALSE;
349  static BOOLEAN Success = FALSE;
350 
351  // Do initialization only once
352  if (Initialized)
353  return Success;
354  Initialized = TRUE;
355 
356  // Check if PXE is available
357  if (GetPxeStructure() && GetCachedInfo())
358  {
359  FsRegisterDevice("net(0)", &PxeDiskVtbl);
360  Success = TRUE;
361  }
362 
363  return Success;
364 }
#define TRUE
Definition: types.h:120
static const DEVVTBL PxeDiskVtbl
Definition: pxe.c:319
static BOOLEAN GetCachedInfo(VOID)
Definition: pxe.c:327
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
VOID FsRegisterDevice(CHAR *Prefix, const DEVVTBL *FuncTable)
Definition: fs.c:383
static PPXE GetPxeStructure(VOID)
Definition: pxe.c:72

Referenced by PcInitializeBootDevices().

◆ PxeMount()

const DEVVTBL* PxeMount ( ULONG  DeviceId)

Definition at line 282 of file pxe.c.

283 {
284  if (GetPxeStructure() == NULL)
285  return NULL;
286  return &PxeVtbl;
287 }
static const DEVVTBL PxeVtbl
Definition: pxe.c:274
#define NULL
Definition: types.h:112
static PPXE GetPxeStructure(VOID)
Definition: pxe.c:72

Referenced by ArcOpen().

◆ PxeOpen()

static ARC_STATUS PxeOpen ( CHAR Path,
OPENMODE  OpenMode,
ULONG FileId 
)
static

Definition at line 147 of file pxe.c.

148 {
149  t_PXENV_TFTP_GET_FSIZE sizeData;
150  t_PXENV_TFTP_OPEN openData;
151  SIZE_T PathLen, i;
152 
153  if (_OpenFile != NO_FILE)
154  return EIO;
155  if (OpenMode != OpenReadOnly)
156  return EACCES;
157 
158  /* Retrieve the path length without NULL terminator */
159  PathLen = (Path ? min(strlen(Path), sizeof(_OpenFileName) - 1) : 0);
160 
161  /* Lowercase the path and always use slashes as separators */
162  for (i = 0; i < PathLen; i++)
163  {
164  if (Path[i] == '\\')
165  _OpenFileName[i] = '/';
166  else
168  }
169 
170  /* Zero out rest of the file name */
171  RtlZeroMemory(_OpenFileName + PathLen, sizeof(_OpenFileName) - PathLen);
172 
173  RtlZeroMemory(&sizeData, sizeof(sizeData));
174  sizeData.ServerIPAddress = _ServerIP;
176  if (!CallPxe(PXENV_TFTP_GET_FSIZE, &sizeData))
177  {
178  ERR("Failed to get '%s' size\n", Path);
179  return EIO;
180  }
181 
182  _FileSize = sizeData.FileSize;
183  _CachedLength = 0;
184 
185  RtlZeroMemory(&openData, sizeof(openData));
186  openData.ServerIPAddress = _ServerIP;
188  openData.PacketSize = sizeof(_Packet);
189 
190  if (!CallPxe(PXENV_TFTP_OPEN, &openData))
191  return ENOENT;
192 
193  _FilePosition = 0;
194  _PacketPosition = 0;
195 
196  _OpenFile = *FileId;
197  return ESUCCESS;
198 }
static ULONG _CachedLength
Definition: pxe.c:35
#define PXENV_TFTP_GET_FSIZE
Definition: pxe.h:591
Definition: arc.h:32
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static ULONG _OpenFile
Definition: pxe.c:29
static ULONG _PacketPosition
Definition: pxe.c:33
static ULONG _FilePosition
Definition: pxe.c:32
UINT8 FileName[128]
Definition: pxe.h:354
static CHAR _OpenFileName[128]
Definition: pxe.c:30
#define PXENV_TFTP_OPEN
Definition: pxe.h:587
IP4 ServerIPAddress
Definition: pxe.h:314
UINT8 FileName[128]
Definition: pxe.h:316
static UCHAR _Packet[1024]
Definition: pxe.c:34
#define NO_FILE
Definition: pxe.c:26
Definition: arc.h:34
UINT16 PacketSize
Definition: pxe.h:318
#define ERR(fmt,...)
Definition: debug.h:110
ULONG_PTR SIZE_T
Definition: typedefs.h:80
BOOLEAN CallPxe(UINT16 Service, PVOID Parameter)
Definition: pxe.c:85
PRTL_UNICODE_STRING_BUFFER Path
static ULONG _FileSize
Definition: pxe.c:31
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define min(a, b)
Definition: monoChain.cc:55
Definition: arc.h:46
Definition: arc.h:40
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
int tolower(int c)
Definition: utclib.c:902
static IP4 _ServerIP
Definition: pxe.c:28

Referenced by PxeSeek().

◆ PxeRead()

static ARC_STATUS PxeRead ( ULONG  FileId,
VOID Buffer,
ULONG  N,
ULONG Count 
)
static

Definition at line 200 of file pxe.c.

201 {
202  t_PXENV_TFTP_READ readData;
203  ULONG i;
204 
205  *Count = 0;
206 
207  if (_OpenFile == NO_FILE || FileId != _OpenFile)
208  return EBADF;
209 
210  RtlZeroMemory(&readData, sizeof(readData));
211  readData.Buffer.segment = ((ULONG_PTR)_Packet & 0xf0000) / 16;
212  readData.Buffer.offset = (ULONG_PTR)_Packet & 0xffff;
213 
214  // Get new packets as required
215  while (N > 0)
216  {
217  if (N < _CachedLength - _FilePosition)
218  i = N;
219  else
222  _FilePosition += i;
223  Buffer = (UCHAR*)Buffer + i;
224  *Count += i;
225  N -= i;
226  if (N == 0)
227  break;
228 
229  if (!CallPxe(PXENV_TFTP_READ, &readData))
230  return EIO;
232  _CachedLength += readData.BufferSize;
233  }
234 
235  return ESUCCESS;
236 }
static ULONG _CachedLength
Definition: pxe.c:35
Definition: arc.h:32
static ULONG _OpenFile
Definition: pxe.c:29
static ULONG _PacketPosition
Definition: pxe.c:33
Definition: arc.h:36
static ULONG _FilePosition
Definition: pxe.c:32
OFF16 offset
Definition: pxe.h:34
UINT16 BufferSize
Definition: pxe.h:330
SEGOFF16 Buffer
Definition: pxe.h:331
Definition: bufpool.h:45
int Count
Definition: noreturn.cpp:7
static UCHAR _Packet[1024]
Definition: pxe.c:34
#define NO_FILE
Definition: pxe.c:26
unsigned char UCHAR
Definition: xmlstorage.h:181
SEGSEL segment
Definition: pxe.h:35
BOOLEAN CallPxe(UINT16 Service, PVOID Parameter)
Definition: pxe.c:85
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define PXENV_TFTP_READ
Definition: pxe.h:589
Definition: arc.h:40
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

◆ PxeSeek()

static ARC_STATUS PxeSeek ( ULONG  FileId,
LARGE_INTEGER Position,
SEEKMODE  SeekMode 
)
static

Definition at line 238 of file pxe.c.

239 {
240  t_PXENV_TFTP_READ readData;
241 
242  if (_OpenFile == NO_FILE || FileId != _OpenFile)
243  return EBADF;
244 
245  if (Position->HighPart != 0 || SeekMode != SeekAbsolute)
246  return EINVAL;
247 
248  if (Position->LowPart < _FilePosition)
249  {
250  // Close and reopen the file to go to position 0
251  if (PxeClose(FileId) != ESUCCESS)
252  return EIO;
253  if (PxeOpen(_OpenFileName, OpenReadOnly, &FileId) != ESUCCESS)
254  return EIO;
255  }
256 
257  RtlZeroMemory(&readData, sizeof(readData));
258  readData.Buffer.segment = ((ULONG_PTR)_Packet & 0xf0000) / 16;
259  readData.Buffer.offset = (ULONG_PTR)_Packet & 0xffff;
260 
261  // Get new packets as required
262  while (Position->LowPart > _CachedLength)
263  {
264  if (!CallPxe(PXENV_TFTP_READ, &readData))
265  return EIO;
267  _CachedLength += readData.BufferSize;
268  }
269 
270  _FilePosition = Position->LowPart;
271  return ESUCCESS;
272 }
static ULONG _CachedLength
Definition: pxe.c:35
Definition: arc.h:32
Definition: arc.h:39
static COORD Position
Definition: mouse.c:34
static ULONG _OpenFile
Definition: pxe.c:29
static ULONG _PacketPosition
Definition: pxe.c:33
Definition: arc.h:36
static ULONG _FilePosition
Definition: pxe.c:32
OFF16 offset
Definition: pxe.h:34
UINT16 BufferSize
Definition: pxe.h:330
static CHAR _OpenFileName[128]
Definition: pxe.c:30
SEGOFF16 Buffer
Definition: pxe.h:331
static ARC_STATUS PxeClose(ULONG FileId)
Definition: pxe.c:117
static UCHAR _Packet[1024]
Definition: pxe.c:34
#define NO_FILE
Definition: pxe.c:26
SEGSEL segment
Definition: pxe.h:35
BOOLEAN CallPxe(UINT16 Service, PVOID Parameter)
Definition: pxe.c:85
#define PXENV_TFTP_READ
Definition: pxe.h:589
Definition: arc.h:40
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
static ARC_STATUS PxeOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: pxe.c:147

Variable Documentation

◆ _CachedLength

ULONG _CachedLength = 0
static

Definition at line 35 of file pxe.c.

Referenced by PxeOpen(), PxeRead(), and PxeSeek().

◆ _FilePosition

ULONG _FilePosition = 0
static

Definition at line 32 of file pxe.c.

Referenced by PxeGetFileInformation(), PxeOpen(), PxeRead(), and PxeSeek().

◆ _FileSize

ULONG _FileSize = 0
static

Definition at line 31 of file pxe.c.

Referenced by PxeGetFileInformation(), and PxeOpen().

◆ _OpenFile

ULONG _OpenFile = NO_FILE
static

Definition at line 29 of file pxe.c.

Referenced by PxeClose(), PxeGetFileInformation(), PxeOpen(), PxeRead(), and PxeSeek().

◆ _OpenFileName

CHAR _OpenFileName[128]
static

Definition at line 30 of file pxe.c.

Referenced by PxeOpen(), and PxeSeek().

◆ _Packet

UCHAR _Packet[1024]
static

◆ _PacketPosition

ULONG _PacketPosition = 0
static

Definition at line 33 of file pxe.c.

Referenced by PxeOpen(), PxeRead(), and PxeSeek().

◆ _ServerIP

IP4 _ServerIP = { 0, }
static

Definition at line 28 of file pxe.c.

Referenced by GetCachedInfo(), and PxeOpen().

◆ PxeDiskVtbl

const DEVVTBL PxeDiskVtbl
static
Initial value:
= {
}
static ARC_STATUS PxeDiskSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: pxe.c:313
static ARC_STATUS PxeDiskGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: pxe.c:295
static ARC_STATUS PxeDiskRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: pxe.c:307
static ARC_STATUS PxeDiskOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: pxe.c:301
static ARC_STATUS PxeDiskClose(ULONG FileId)
Definition: pxe.c:289

Definition at line 319 of file pxe.c.

Referenced by PxeInit().

◆ PxeVtbl

const DEVVTBL PxeVtbl
static
Initial value:
= {
}
static ARC_STATUS PxeSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: pxe.c:238
static ARC_STATUS PxeRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: pxe.c:200
static ARC_STATUS PxeClose(ULONG FileId)
Definition: pxe.c:117
static ARC_STATUS PxeGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: pxe.c:132
static ARC_STATUS PxeOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: pxe.c:147

Definition at line 274 of file pxe.c.

Referenced by PxeMount().