mirror of
https://github.com/WindowsNT351/CE-Collections.git
synced 2025-12-26 17:10:25 +08:00
201B02
This commit is contained in:
parent
828a22463b
commit
8312ba839e
BIN
DOS/LOADCEPC/LOADCEPC.EXE
Normal file
BIN
DOS/LOADCEPC/LOADCEPC.EXE
Normal file
Binary file not shown.
BIN
DOS/LOADCEPC/LOADCEPC.bsc
Normal file
BIN
DOS/LOADCEPC/LOADCEPC.bsc
Normal file
Binary file not shown.
0
DOS/LOADCEPC/MAIN.SBR
Normal file
0
DOS/LOADCEPC/MAIN.SBR
Normal file
0
DOS/LOADCEPC/PPFS.SBR
Normal file
0
DOS/LOADCEPC/PPFS.SBR
Normal file
BIN
DOS/LOADCEPC/TRANSFER.OBJ
Normal file
BIN
DOS/LOADCEPC/TRANSFER.OBJ
Normal file
Binary file not shown.
0
DOS/LOADCEPC/VIDEO.SBR
Normal file
0
DOS/LOADCEPC/VIDEO.SBR
Normal file
0
DOS/LOADCEPC/XMSAPI.SBR
Normal file
0
DOS/LOADCEPC/XMSAPI.SBR
Normal file
4
DOS/LOADCEPC/bld.bat
Normal file
4
DOS/LOADCEPC/bld.bat
Normal file
@ -0,0 +1,4 @@
|
||||
del *.obj
|
||||
del *.sbr
|
||||
del *.cod
|
||||
nmake /f loadcepc.mak
|
||||
123
DOS/LOADCEPC/bootarg.h
Normal file
123
DOS/LOADCEPC/bootarg.h
Normal file
@ -0,0 +1,123 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
/*++
|
||||
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|
||||
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
||||
PARTICULAR PURPOSE.
|
||||
|
||||
Module Name:
|
||||
bootarg.h
|
||||
|
||||
Abstract:
|
||||
Definitions for arguments passed by loadcepc at boot time.
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _BOOTARG_H
|
||||
#define _BOOTARG_H
|
||||
|
||||
#include <halether.h>
|
||||
|
||||
// Contains a pointer to the actual boot args structure
|
||||
#define BOOT_ARG_PTR_LOCATION 0x801FFFFC
|
||||
|
||||
#define BOOT_ARG_VERSION_SIG 0x12345678
|
||||
#define BOOT_ARG_MAJOR_VER 1
|
||||
#define BOOT_ARG_MINOR_VER 0
|
||||
|
||||
#define MAX_DEV_NAMELEN 16 // Should match EDBG_MAX_DEV_NAMELEN.
|
||||
// NAND controller boot flags
|
||||
#define NAND_PCI_PRESENT (1 << 0)
|
||||
|
||||
typedef struct _BOOT_ARGS {
|
||||
UCHAR ucVideoMode;
|
||||
UCHAR ucComPort;
|
||||
UCHAR ucBaudDivisor;
|
||||
UCHAR ucPCIConfigType;
|
||||
|
||||
// The following args are not set by older versions of loadcepc,
|
||||
// so include a sig to verify that the remaining params are valid.
|
||||
// Also, include a length to allow expansion in the future.
|
||||
DWORD dwSig;
|
||||
#define BOOTARG_SIG 0x544F4F42 // "BOOT"
|
||||
DWORD dwLen; // Total length of boot args struct
|
||||
UCHAR ucLoaderFlags; // Flags set by loader
|
||||
UCHAR ucEshellFlags; // Flags from eshell
|
||||
UCHAR ucEdbgAdapterType; // Type of debug Ether adapter
|
||||
UCHAR ucEdbgIRQ; // IRQ line to use for debug Ether adapter
|
||||
DWORD dwEdbgBaseAddr; // Base I/O address for debug Ether adapter
|
||||
DWORD dwEdbgDebugZone; // Allow EDBG debug zones to be turned on from loadcepc
|
||||
// The following is only valid if LDRFL_ADDR_VALID is set
|
||||
EDBG_ADDR EdbgAddr; // IP/ether addr to use for debug Ethernet
|
||||
// The following addresses are only valid if LDRFL_JUMPIMG is set, and corresponding bit in
|
||||
// ucEshellFlags is set (configured by eshell, bit definitions in ethdbg.h).
|
||||
EDBG_ADDR EshellHostAddr; // IP/ether addr and UDP port of host running eshell
|
||||
EDBG_ADDR DbgHostAddr; // IP/ether addr and UDP port of host receiving dbg msgs
|
||||
EDBG_ADDR CeshHostAddr; // IP/ether addr and UDP port of host running ether text shell
|
||||
EDBG_ADDR KdbgHostAddr; // IP/ether addr and UDP port of host running kernel debugger
|
||||
DWORD DHCPLeaseTime; // Length of DHCP IP lease in seconds
|
||||
WORD EdbgFlags; // Information about the ethernet system
|
||||
WORD KitlTransport; // Transport for Kitl communication
|
||||
|
||||
DWORD dwEBootFlag; // Eboot flags indicating whether EBoot supports warm reset (older version may not)
|
||||
DWORD dwEBootAddr; // Eboot entry point set by eboot and used during warm reset
|
||||
DWORD dwLaunchAddr; // Old image launch address saved by EBoot when it receives jmpimage
|
||||
|
||||
// The following args added to support passing info to flat framebuffer display driver
|
||||
DWORD pvFlatFrameBuffer; // pointer to flat frame buffer
|
||||
WORD vesaMode; // VESA mode being used
|
||||
WORD cxDisplayScreen; // displayable X size
|
||||
WORD cyDisplayScreen; // displayable Y size
|
||||
WORD cxPhysicalScreen; // physical X size
|
||||
WORD cyPhysicalScreen; // physical Y size
|
||||
WORD cbScanLineLength; // scan line byte count
|
||||
WORD bppScreen; // color depth
|
||||
UCHAR RedMaskSize; // size of red color mask
|
||||
UCHAR RedMaskPosition; // position for red color mask
|
||||
UCHAR GreenMaskSize; // size of green color mask
|
||||
UCHAR GreenMaskPosition; // position for green color mask
|
||||
UCHAR BlueMaskSize; // size of blue color mask
|
||||
UCHAR BlueMaskPosition; // position for blue color mask
|
||||
|
||||
// Version information for bootargs structure.
|
||||
ULONG dwVersionSig;
|
||||
USHORT MajorVersion;
|
||||
USHORT MinorVersion;
|
||||
|
||||
// Version 1.0 additions
|
||||
UCHAR szDeviceNameRoot[MAX_DEV_NAMELEN]; // EDBG device name root.
|
||||
|
||||
DWORD dwImgStoreAddr; // Flash storage address.
|
||||
DWORD dwImgLoadAddr; // RAM load address.
|
||||
DWORD dwImgLength; // Image length.
|
||||
BYTE NANDBootFlags; // Boot flags related to NAND support.
|
||||
BYTE NANDBusNumber; // NAND controller PCI bus number.
|
||||
DWORD NANDSlotNumber;// NAND controller PCI slot number.
|
||||
|
||||
} BOOT_ARGS, *PBOOT_ARGS;
|
||||
|
||||
// Defs for loader flags
|
||||
#define LDRFL_USE_EDBG 0x0001 // Set to attempt to use debug Ethernet
|
||||
// The following two flags are only looked at if LDRFL_USE_EDBG is set
|
||||
#define LDRFL_ADDR_VALID 0x0002 // Set if EdbgAddr field is valid
|
||||
#define LDRFL_JUMPIMG 0x0004 // If set, don't communicate with eshell to get
|
||||
// The following flag is only used for backup FLASH operation
|
||||
#define LDRFL_FLASH_BACKUP 0x80
|
||||
// configuration, use ucEshellFlags field.
|
||||
|
||||
// Use this constant in EdbgIRQ to specify that EDBG should run without an interrupt.
|
||||
#define EDBG_IRQ_NONE 0xFF
|
||||
|
||||
#endif // _BOOTARG_H
|
||||
166
DOS/LOADCEPC/debug.c
Normal file
166
DOS/LOADCEPC/debug.c
Normal file
@ -0,0 +1,166 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
/*++
|
||||
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|
||||
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
||||
PARTICULAR PURPOSE.
|
||||
|
||||
Module Name:
|
||||
|
||||
Abstract:
|
||||
|
||||
Functions:
|
||||
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
unsigned char __inline READ_PORT_UCHAR(unsigned char *port)
|
||||
{
|
||||
return _inp((unsigned short)port);
|
||||
}
|
||||
|
||||
void __inline WRITE_PORT_UCHAR(unsigned char * port, unsigned char value)
|
||||
{
|
||||
_outp((unsigned short)port, (value));
|
||||
}
|
||||
|
||||
#define LS_TSR_EMPTY 0x40
|
||||
#define LS_THR_EMPTY 0x20
|
||||
#define LS_RX_BREAK 0x10
|
||||
#define LS_RX_FRAMING_ERR 0x08
|
||||
#define LS_RX_PARITY_ERR 0x04
|
||||
#define LS_RX_OVERRUN 0x02
|
||||
#define LS_RX_DATA_READY 0x01
|
||||
|
||||
#define LS_RX_ERRORS ( LS_RX_FRAMING_ERR | LS_RX_PARITY_ERR | LS_RX_OVERRUN )
|
||||
|
||||
#define COM1_BASE 0x03F8
|
||||
#define COM2_BASE 0x02F8
|
||||
|
||||
#define comTxBuffer 0x00
|
||||
#define comRxBuffer 0x00
|
||||
#define comDivisorLow 0x00
|
||||
#define comDivisorHigh 0x01
|
||||
#define comIntEnable 0x01
|
||||
#define comIntId 0x02
|
||||
#define comFIFOControl 0x02
|
||||
#define comLineControl 0x03
|
||||
#define comModemControl 0x04
|
||||
#define comLineStatus 0x05
|
||||
#define comModemStatus 0x06
|
||||
|
||||
#define IoPortBase ( (unsigned char *) COM1_BASE )
|
||||
|
||||
extern struct _ARGUMENTS
|
||||
{
|
||||
unsigned char ucVideoMode;
|
||||
unsigned char ucComPort;
|
||||
unsigned char ucBaudDivisor;
|
||||
unsigned char ucPCIConfigType;
|
||||
} BootArgs;
|
||||
|
||||
// 14400 = 8
|
||||
// 16457 = 7 +/-
|
||||
// 19200 = 6
|
||||
// 23040 = 5
|
||||
// 28800 = 4
|
||||
// 38400 = 3
|
||||
// 57600 = 2
|
||||
// 115200 = 1
|
||||
|
||||
|
||||
void OEMInitDebugSerial(void)
|
||||
{
|
||||
unsigned char ucArgs[3];
|
||||
unsigned int dwSize;
|
||||
|
||||
dwSize = sizeof(ucArgs);
|
||||
|
||||
WRITE_PORT_UCHAR(IoPortBase+comLineControl, 0x80); // Access Baud Divisor
|
||||
WRITE_PORT_UCHAR(IoPortBase+comDivisorLow, BootArgs.ucBaudDivisor&0x7f); // 19200
|
||||
WRITE_PORT_UCHAR(IoPortBase+comDivisorHigh, 0x00);
|
||||
WRITE_PORT_UCHAR(IoPortBase+comFIFOControl, 0x01); // Enable FIFO if present
|
||||
WRITE_PORT_UCHAR(IoPortBase+comLineControl, 0x03); // 8 bit, no parity
|
||||
|
||||
WRITE_PORT_UCHAR(IoPortBase+comIntEnable, 0x00); // No interrupts, polled
|
||||
|
||||
WRITE_PORT_UCHAR(IoPortBase+comModemControl, 0x03); // Assert DTR, RTS
|
||||
}
|
||||
|
||||
void OEMWriteDebugString(unsigned short *str)
|
||||
{
|
||||
while (*str)
|
||||
{
|
||||
while (!(READ_PORT_UCHAR(IoPortBase+comLineStatus) & LS_THR_EMPTY))
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
WRITE_PORT_UCHAR(IoPortBase+comTxBuffer, (unsigned char)*str++);
|
||||
}
|
||||
}
|
||||
|
||||
void OEMWriteDebugByte(BYTE ucChar)
|
||||
{
|
||||
while (!(READ_PORT_UCHAR(IoPortBase+comLineStatus) & LS_THR_EMPTY))
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
WRITE_PORT_UCHAR(IoPortBase+comTxBuffer, ucChar);
|
||||
}
|
||||
|
||||
int iComTotal=0;
|
||||
void OEMReadDebugBytes(unsigned char * ucBuffer, int usReadSize) {
|
||||
int i=0;
|
||||
unsigned char uStat;
|
||||
|
||||
while (usReadSize--) {
|
||||
do {
|
||||
uStat=READ_PORT_UCHAR(IoPortBase+comLineStatus);
|
||||
if (uStat & LS_RX_ERRORS) {
|
||||
while (1)
|
||||
printf("port status error=%xh i=%u\r",uStat,iComTotal);
|
||||
}
|
||||
} while (!(uStat&LS_RX_DATA_READY));
|
||||
ucBuffer[i++]=READ_PORT_UCHAR(IoPortBase+comRxBuffer);
|
||||
iComTotal++;
|
||||
}
|
||||
}
|
||||
|
||||
int OEMReadDebugByte(void)
|
||||
{
|
||||
int i;
|
||||
OEMReadDebugBytes((unsigned char *)&i,1);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
*
|
||||
* @func void | OEMClearDebugComError | Clear a debug communications er
|
||||
or
|
||||
*
|
||||
*/
|
||||
void
|
||||
OEMClearDebugCommError(
|
||||
void
|
||||
)
|
||||
{
|
||||
}
|
||||
394
DOS/LOADCEPC/debug.cod
Normal file
394
DOS/LOADCEPC/debug.cod
Normal file
@ -0,0 +1,394 @@
|
||||
; Static Name Aliases
|
||||
;
|
||||
TITLE debug.c
|
||||
.286p
|
||||
.287
|
||||
INCLUDELIB SLIBCE
|
||||
INCLUDELIB OLDNAMES.LIB
|
||||
_TEXT SEGMENT WORD PUBLIC 'CODE'
|
||||
_TEXT ENDS
|
||||
_DATA SEGMENT WORD PUBLIC 'DATA'
|
||||
_DATA ENDS
|
||||
CONST SEGMENT WORD PUBLIC 'CONST'
|
||||
CONST ENDS
|
||||
_BSS SEGMENT WORD PUBLIC 'BSS'
|
||||
_BSS ENDS
|
||||
$$SYMBOLS SEGMENT BYTE PUBLIC 'DEBSYM'
|
||||
$$SYMBOLS ENDS
|
||||
$$TYPES SEGMENT BYTE PUBLIC 'DEBTYP'
|
||||
$$TYPES ENDS
|
||||
DGROUP GROUP CONST, _BSS, _DATA
|
||||
ASSUME DS: DGROUP, SS: DGROUP
|
||||
PUBLIC _iComTotal
|
||||
EXTRN _printf:NEAR
|
||||
EXTRN _BootArgs:DWORD
|
||||
_DATA SEGMENT
|
||||
_iComTotal DW 00H
|
||||
$SG370 DB 'port status error=%xh i=%u', 0dH, 00H
|
||||
_DATA ENDS
|
||||
_TEXT SEGMENT
|
||||
ASSUME CS: _TEXT
|
||||
PUBLIC _OEMInitDebugSerial
|
||||
_OEMInitDebugSerial PROC NEAR
|
||||
;|*** //
|
||||
;|*** // Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
;|*** //
|
||||
;|*** //
|
||||
;|*** // Use of this sample source code is subject to the terms of the Microsoft
|
||||
;|*** // license agreement under which you licensed this sample source code. If
|
||||
;|*** // you did not accept the terms of the license agreement, you are not
|
||||
;|*** // authorized to use this sample source code. For the terms of the license,
|
||||
;|*** // please see the license agreement between you and Microsoft or, if applicable,
|
||||
;|*** // see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
;|*** // THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
;|*** //
|
||||
;|*** /*++
|
||||
;|*** THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|
||||
;|*** ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
;|*** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
||||
;|*** PARTICULAR PURPOSE.
|
||||
;|***
|
||||
;|*** Module Name:
|
||||
;|***
|
||||
;|*** Abstract:
|
||||
;|***
|
||||
;|*** Functions:
|
||||
;|***
|
||||
;|***
|
||||
;|*** Notes:
|
||||
;|***
|
||||
;|*** --*/
|
||||
;|***
|
||||
;|*** #include <windows.h>
|
||||
;|***
|
||||
;|*** unsigned char __inline READ_PORT_UCHAR(unsigned char *port)
|
||||
;|*** {
|
||||
;|*** return _inp((unsigned short)port);
|
||||
;|*** }
|
||||
;|***
|
||||
;|*** void __inline WRITE_PORT_UCHAR(unsigned char * port, unsigned char value)
|
||||
;|*** {
|
||||
;|*** _outp((unsigned short)port, (value));
|
||||
;|*** }
|
||||
;|***
|
||||
;|*** #define LS_TSR_EMPTY 0x40
|
||||
;|*** #define LS_THR_EMPTY 0x20
|
||||
;|*** #define LS_RX_BREAK 0x10
|
||||
;|*** #define LS_RX_FRAMING_ERR 0x08
|
||||
;|*** #define LS_RX_PARITY_ERR 0x04
|
||||
;|*** #define LS_RX_OVERRUN 0x02
|
||||
;|*** #define LS_RX_DATA_READY 0x01
|
||||
;|***
|
||||
;|*** #define LS_RX_ERRORS ( LS_RX_FRAMING_ERR | LS_RX_PARITY_ERR | LS_RX_OVERRUN )
|
||||
;|***
|
||||
;|*** #define COM1_BASE 0x03F8
|
||||
;|*** #define COM2_BASE 0x02F8
|
||||
;|***
|
||||
;|*** #define comTxBuffer 0x00
|
||||
;|*** #define comRxBuffer 0x00
|
||||
;|*** #define comDivisorLow 0x00
|
||||
;|*** #define comDivisorHigh 0x01
|
||||
;|*** #define comIntEnable 0x01
|
||||
;|*** #define comIntId 0x02
|
||||
;|*** #define comFIFOControl 0x02
|
||||
;|*** #define comLineControl 0x03
|
||||
;|*** #define comModemControl 0x04
|
||||
;|*** #define comLineStatus 0x05
|
||||
;|*** #define comModemStatus 0x06
|
||||
;|***
|
||||
;|*** #define IoPortBase ( (unsigned char *) COM1_BASE )
|
||||
;|***
|
||||
;|*** extern struct _ARGUMENTS
|
||||
;|*** {
|
||||
;|*** unsigned char ucVideoMode;
|
||||
;|*** unsigned char ucComPort;
|
||||
;|*** unsigned char ucBaudDivisor;
|
||||
;|*** unsigned char ucPCIConfigType;
|
||||
;|*** } BootArgs;
|
||||
;|***
|
||||
;|*** // 14400 = 8
|
||||
;|*** // 16457 = 7 +/-
|
||||
;|*** // 19200 = 6
|
||||
;|*** // 23040 = 5
|
||||
;|*** // 28800 = 4
|
||||
;|*** // 38400 = 3
|
||||
;|*** // 57600 = 2
|
||||
;|*** // 115200 = 1
|
||||
;|***
|
||||
;|***
|
||||
;|*** void OEMInitDebugSerial(void)
|
||||
;|*** {
|
||||
; Line 88
|
||||
; ucArgs = -4
|
||||
; dwSize = -6
|
||||
;|*** unsigned char ucArgs[3];
|
||||
;|*** unsigned int dwSize;
|
||||
;|***
|
||||
;|*** dwSize = sizeof(ucArgs);
|
||||
;|***
|
||||
;|*** WRITE_PORT_UCHAR(IoPortBase+comLineControl, 0x80); // Access Baud Divisor
|
||||
; Line 94
|
||||
*** 000000 b8 80 00 mov ax,128 ;0080H
|
||||
*** 000003 ba fb 03 mov dx,1019 ;03fbH
|
||||
*** 000006 ee out dx, al
|
||||
|
||||
;|*** WRITE_PORT_UCHAR(IoPortBase+comDivisorLow, BootArgs.ucBaudDivisor&0x7f); // 19200
|
||||
; Line 95
|
||||
*** 000007 a0 02 00 mov al,BYTE PTR _BootArgs+2
|
||||
*** 00000a 25 7f 00 and ax,127 ;007fH
|
||||
*** 00000d ba f8 03 mov dx,1016 ;03f8H
|
||||
*** 000010 ee out dx, al
|
||||
|
||||
;|*** WRITE_PORT_UCHAR(IoPortBase+comDivisorHigh, 0x00);
|
||||
; Line 96
|
||||
*** 000011 33 c0 xor ax,ax
|
||||
*** 000013 ba f9 03 mov dx,1017 ;03f9H
|
||||
*** 000016 ee out dx, al
|
||||
|
||||
;|*** WRITE_PORT_UCHAR(IoPortBase+comFIFOControl, 0x01); // Enable FIFO if present
|
||||
; Line 97
|
||||
*** 000017 b8 01 00 mov ax,1
|
||||
*** 00001a ba fa 03 mov dx,1018 ;03faH
|
||||
*** 00001d ee out dx, al
|
||||
|
||||
;|*** WRITE_PORT_UCHAR(IoPortBase+comLineControl, 0x03); // 8 bit, no parity
|
||||
; Line 98
|
||||
*** 00001e b8 03 00 mov ax,3
|
||||
*** 000021 ba fb 03 mov dx,1019 ;03fbH
|
||||
*** 000024 ee out dx, al
|
||||
|
||||
;|***
|
||||
;|*** WRITE_PORT_UCHAR(IoPortBase+comIntEnable, 0x00); // No interrupts, polled
|
||||
; Line 100
|
||||
*** 000025 33 c0 xor ax,ax
|
||||
*** 000027 ba f9 03 mov dx,1017 ;03f9H
|
||||
*** 00002a ee out dx, al
|
||||
|
||||
;|***
|
||||
;|*** WRITE_PORT_UCHAR(IoPortBase+comModemControl, 0x03); // Assert DTR, RTS
|
||||
; Line 102
|
||||
*** 00002b b8 03 00 mov ax,3
|
||||
*** 00002e ba fc 03 mov dx,1020 ;03fcH
|
||||
*** 000031 ee out dx, al
|
||||
|
||||
;|*** }
|
||||
; Line 103
|
||||
*** 000032 c3 ret
|
||||
*** 000033 90 nop
|
||||
|
||||
_OEMInitDebugSerial ENDP
|
||||
PUBLIC _OEMWriteDebugString
|
||||
_OEMWriteDebugString PROC NEAR
|
||||
;|***
|
||||
;|*** void OEMWriteDebugString(unsigned short *str)
|
||||
;|*** {
|
||||
; Line 106
|
||||
*** 000034 55 push bp
|
||||
*** 000035 8b ec mov bp,sp
|
||||
*** 000037 57 push di
|
||||
; str = 4
|
||||
*** 000038 8b 5e 04 mov bx,WORD PTR [bp+4] ;str
|
||||
;|*** while (*str)
|
||||
; Line 107
|
||||
*** 00003b 83 3f 00 cmp WORD PTR [bx],0
|
||||
*** 00003e 74 1d je $EX337
|
||||
$FC339:
|
||||
*** 000040 89 5e 04 mov WORD PTR [bp+4],bx ;str
|
||||
;|*** {
|
||||
;|*** while (!(READ_PORT_UCHAR(IoPortBase+comLineStatus) & LS_THR_EMPTY))
|
||||
; Line 109
|
||||
$L398:
|
||||
*** 000043 ba fd 03 mov dx,1021 ;03fdH
|
||||
*** 000046 ec in al,dx
|
||||
*** 000047 a8 20 test al,32 ;0020H
|
||||
*** 000049 74 f8 je $L398
|
||||
;|*** {
|
||||
;|*** ;
|
||||
;|*** }
|
||||
;|***
|
||||
;|*** WRITE_PORT_UCHAR(IoPortBase+comTxBuffer, (unsigned char)*str++);
|
||||
; Line 114
|
||||
*** 00004b 8b fb mov di,bx
|
||||
*** 00004d 2a e4 sub ah,ah
|
||||
*** 00004f 8a 05 mov al,BYTE PTR [di]
|
||||
*** 000051 ba f8 03 mov dx,1016 ;03f8H
|
||||
*** 000054 ee out dx, al
|
||||
|
||||
;|*** }
|
||||
; Line 115
|
||||
*** 000055 83 c3 02 add bx,2
|
||||
*** 000058 83 3f 00 cmp WORD PTR [bx],0
|
||||
*** 00005b 75 e3 jne $FC339
|
||||
;|*** }
|
||||
; Line 116
|
||||
$EX337:
|
||||
*** 00005d 5f pop di
|
||||
*** 00005e c9 leave
|
||||
*** 00005f c3 ret
|
||||
|
||||
_OEMWriteDebugString ENDP
|
||||
PUBLIC _OEMWriteDebugByte
|
||||
_OEMWriteDebugByte PROC NEAR
|
||||
;|***
|
||||
;|*** void OEMWriteDebugByte(BYTE ucChar)
|
||||
;|*** {
|
||||
; Line 119
|
||||
*** 000060 55 push bp
|
||||
*** 000061 8b ec mov bp,sp
|
||||
; ucChar = 4
|
||||
;|*** while (!(READ_PORT_UCHAR(IoPortBase+comLineStatus) & LS_THR_EMPTY))
|
||||
; Line 120
|
||||
$L408:
|
||||
*** 000063 ba fd 03 mov dx,1021 ;03fdH
|
||||
*** 000066 ec in al,dx
|
||||
*** 000067 a8 20 test al,32 ;0020H
|
||||
*** 000069 74 f8 je $L408
|
||||
;|*** {
|
||||
;|*** ;
|
||||
;|*** }
|
||||
;|***
|
||||
;|*** WRITE_PORT_UCHAR(IoPortBase+comTxBuffer, ucChar);
|
||||
; Line 125
|
||||
*** 00006b 8a 46 04 mov al,BYTE PTR [bp+4] ;ucChar
|
||||
*** 00006e 2a e4 sub ah,ah
|
||||
*** 000070 ba f8 03 mov dx,1016 ;03f8H
|
||||
*** 000073 ee out dx, al
|
||||
|
||||
;|*** }
|
||||
; Line 126
|
||||
*** 000074 c9 leave
|
||||
*** 000075 c3 ret
|
||||
|
||||
_OEMWriteDebugByte ENDP
|
||||
PUBLIC _OEMReadDebugBytes
|
||||
_OEMReadDebugBytes PROC NEAR
|
||||
;|***
|
||||
;|*** int iComTotal=0;
|
||||
;|*** void OEMReadDebugBytes(unsigned char * ucBuffer, int usReadSize) {
|
||||
; Line 129
|
||||
*** 000076 c8 04 00 00 enter 4,0
|
||||
*** 00007a 57 push di
|
||||
; ucBuffer = 4
|
||||
; usReadSize = 6
|
||||
; i = -4
|
||||
; uStat = -1
|
||||
;|*** int i=0;
|
||||
; Line 130
|
||||
*** 00007b 33 db xor bx,bx
|
||||
*** 00007d 8b 4e 06 mov cx,WORD PTR [bp+6] ;usReadSize
|
||||
*** 000080 8b 7e 04 mov di,WORD PTR [bp+4] ;ucBuffer
|
||||
;|*** unsigned char uStat;
|
||||
;|***
|
||||
;|*** while (usReadSize--) {
|
||||
; Line 133
|
||||
$FC361:
|
||||
*** 000083 8b c1 mov ax,cx
|
||||
*** 000085 49 dec cx
|
||||
*** 000086 0b c0 or ax,ax
|
||||
*** 000088 74 38 je $EX357
|
||||
*** 00008a 89 4e 06 mov WORD PTR [bp+6],cx ;usReadSize
|
||||
;|*** do {
|
||||
;|*** uStat=READ_PORT_UCHAR(IoPortBase+comLineStatus);
|
||||
; Line 135
|
||||
$L414:
|
||||
;|*** if (uStat & LS_RX_ERRORS) {
|
||||
; Line 136
|
||||
*** 00008d ba fd 03 mov dx,1021 ;03fdH
|
||||
*** 000090 ec in al,dx
|
||||
*** 000091 88 46 ff mov BYTE PTR [bp-1],al ;uStat
|
||||
*** 000094 a8 0e test al,14 ;000eH
|
||||
*** 000096 75 14 jne $L420
|
||||
;|*** while (1)
|
||||
;|*** printf("port status error=%xh i=%u\r",uStat,iComTotal);
|
||||
;|*** }
|
||||
;|*** } while (!(uStat&LS_RX_DATA_READY));
|
||||
; Line 140
|
||||
*** 000098 f6 46 ff 01 test BYTE PTR [bp-1],1 ;uStat
|
||||
*** 00009c 74 ef je $L414
|
||||
;|*** ucBuffer[i++]=READ_PORT_UCHAR(IoPortBase+comRxBuffer);
|
||||
; Line 141
|
||||
*** 00009e ba f8 03 mov dx,1016 ;03f8H
|
||||
*** 0000a1 ec in al,dx
|
||||
*** 0000a2 88 01 mov BYTE PTR [bx][di],al
|
||||
*** 0000a4 43 inc bx
|
||||
;|*** iComTotal++;
|
||||
; Line 142
|
||||
*** 0000a5 ff 06 00 00 inc WORD PTR _iComTotal
|
||||
;|*** }
|
||||
; Line 143
|
||||
*** 0000a9 eb d8 jmp SHORT $FC361
|
||||
*** 0000ab 90 nop
|
||||
$L420:
|
||||
;|*** printf("port status error=%xh i=%u\r",uStat,iComTotal);
|
||||
; Line 138
|
||||
*** 0000ac ff 36 00 00 push WORD PTR _iComTotal
|
||||
*** 0000b0 8a 46 ff mov al,BYTE PTR [bp-1] ;uStat
|
||||
*** 0000b3 2a e4 sub ah,ah
|
||||
*** 0000b5 50 push ax
|
||||
*** 0000b6 68 00 00 push OFFSET DGROUP:$SG370
|
||||
*** 0000b9 e8 00 00 call _printf
|
||||
*** 0000bc 83 c4 06 add sp,6
|
||||
*** 0000bf eb eb jmp SHORT $L420
|
||||
*** 0000c1 90 nop
|
||||
;|*** }
|
||||
;|*** } while (!(uStat&LS_RX_DATA_READY));
|
||||
;|*** ucBuffer[i++]=READ_PORT_UCHAR(IoPortBase+comRxBuffer);
|
||||
;|*** iComTotal++;
|
||||
;|*** }
|
||||
;|*** }
|
||||
; Line 144
|
||||
$EX357:
|
||||
*** 0000c2 5f pop di
|
||||
*** 0000c3 c9 leave
|
||||
*** 0000c4 c3 ret
|
||||
*** 0000c5 90 nop
|
||||
|
||||
_OEMReadDebugBytes ENDP
|
||||
PUBLIC _OEMReadDebugByte
|
||||
_OEMReadDebugByte PROC NEAR
|
||||
;|***
|
||||
;|*** int OEMReadDebugByte(void)
|
||||
;|*** {
|
||||
; Line 147
|
||||
*** 0000c6 c8 02 00 00 enter 2,0
|
||||
; i = -2
|
||||
;|*** int i;
|
||||
;|*** OEMReadDebugBytes((unsigned char *)&i,1);
|
||||
; Line 149
|
||||
*** 0000ca 6a 01 push 1
|
||||
*** 0000cc 8d 46 fe lea ax,WORD PTR [bp-2] ;i
|
||||
*** 0000cf 50 push ax
|
||||
*** 0000d0 e8 a3 ff call _OEMReadDebugBytes
|
||||
;|*** return i;
|
||||
; Line 150
|
||||
*** 0000d3 8b 46 fe mov ax,WORD PTR [bp-2] ;i
|
||||
;|*** }
|
||||
; Line 151
|
||||
*** 0000d6 c9 leave
|
||||
*** 0000d7 c3 ret
|
||||
|
||||
_OEMReadDebugByte ENDP
|
||||
PUBLIC _OEMClearDebugCommError
|
||||
_OEMClearDebugCommError PROC NEAR
|
||||
;|***
|
||||
;|***
|
||||
;|*** /*****************************************************************************
|
||||
;|*** *
|
||||
;|*** *
|
||||
;|*** * @func void | OEMClearDebugComError | Clear a debug communications er
|
||||
;|*** or
|
||||
;|*** *
|
||||
;|*** */
|
||||
;|*** void
|
||||
;|*** OEMClearDebugCommError(
|
||||
;|*** void
|
||||
;|*** )
|
||||
;|*** {
|
||||
;|*** }
|
||||
; Line 166
|
||||
*** 0000d8 c3 ret
|
||||
*** 0000d9 90 nop
|
||||
|
||||
_OEMClearDebugCommError ENDP
|
||||
_TEXT ENDS
|
||||
END
|
||||
BIN
DOS/LOADCEPC/debug.obj
Normal file
BIN
DOS/LOADCEPC/debug.obj
Normal file
Binary file not shown.
BIN
DOS/LOADCEPC/debug.sbr
Normal file
BIN
DOS/LOADCEPC/debug.sbr
Normal file
Binary file not shown.
57
DOS/LOADCEPC/ethernet.h
Normal file
57
DOS/LOADCEPC/ethernet.h
Normal file
@ -0,0 +1,57 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
/*++
|
||||
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|
||||
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
||||
PARTICULAR PURPOSE.
|
||||
|
||||
Module Name:
|
||||
|
||||
Abstract:
|
||||
|
||||
Functions:
|
||||
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _ETHERNET_H
|
||||
#define _ETHERNET_H 1
|
||||
|
||||
|
||||
/*
|
||||
* Addressing info struct. We don't ARP for unknown ethernet addresses, so
|
||||
* even the ethernet address must be configured.
|
||||
*/
|
||||
typedef struct _EDBG_ADDR {
|
||||
DWORD dwIP;
|
||||
USHORT wMAC[3];
|
||||
USHORT wPort;
|
||||
|
||||
} EDBG_ADDR;
|
||||
|
||||
|
||||
#define EDBG_SYSINTR_NOINTR 0xFFFFFFFF
|
||||
|
||||
// The following defs can be used for platforms which support multiple adapter types.
|
||||
// Identifiers are provided here for drivers which are built in common\oak\drivers\ethdbg.
|
||||
// Any platform specific adapter types can be identified based off of EDBG_ADAPTER_OEM.
|
||||
#define EDBG_ADAPTER_SMC9000 0
|
||||
#define EDBG_ADAPTER_NE2000 1
|
||||
#define EDBG_ADAPTER_DEFAULT 2
|
||||
|
||||
#define EDBG_ADAPTER_OEM 16
|
||||
|
||||
|
||||
#endif // _ETHERNET_H
|
||||
277
DOS/LOADCEPC/ethmain.c
Normal file
277
DOS/LOADCEPC/ethmain.c
Normal file
@ -0,0 +1,277 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
/*++
|
||||
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|
||||
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
||||
PARTICULAR PURPOSE.
|
||||
|
||||
Module Name:
|
||||
|
||||
Abstract:
|
||||
Loadcepc Ethernet routines.
|
||||
|
||||
Functions:
|
||||
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
#include <conio.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#include "loadcepc.h"
|
||||
#include "smchw.h"
|
||||
#include "wdm.h"
|
||||
|
||||
#include "ethernet.h"
|
||||
#include "bootarg.h"
|
||||
|
||||
BOOT_ARGS BootArgs;
|
||||
|
||||
// The base address for the card
|
||||
static BYTE volatile *pbEthernetBase;
|
||||
#define ReadWord( wOffset ) _inpw((USHORT)(pbEthernetBase + wOffset))
|
||||
#define WriteWord( wOffset, Value ) _outpw((USHORT)(pbEthernetBase + wOffset), (USHORT)Value)
|
||||
|
||||
|
||||
WORD
|
||||
hex_atoi(char * hexstr)
|
||||
{
|
||||
WORD wRet = 0;
|
||||
while (*hexstr) {
|
||||
wRet <<= 4;
|
||||
switch (*hexstr) {
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
wRet += (WORD)(*hexstr - '0');
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'd':
|
||||
case 'e':
|
||||
case 'f':
|
||||
wRet += (WORD)(*hexstr - 'a');
|
||||
wRet += 10;
|
||||
break;
|
||||
|
||||
case 'A':
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'D':
|
||||
case 'E':
|
||||
case 'F':
|
||||
wRet += (WORD)(*hexstr - 'A');
|
||||
wRet += 10;
|
||||
break;
|
||||
}
|
||||
hexstr++;
|
||||
}
|
||||
return wRet;
|
||||
} // hex_atoi
|
||||
|
||||
|
||||
// This routine will take a dotted decimal IP address as represent here and return a binary version of it
|
||||
DWORD inet_addr( char *pszDottedD ) {
|
||||
|
||||
DWORD dwIP = 0;
|
||||
DWORD cBytes;
|
||||
char *pszLastNum;
|
||||
|
||||
// Replace the dots with NULL terminators
|
||||
pszLastNum = pszDottedD;
|
||||
for( cBytes = 0; cBytes < 4; cBytes++ ) {
|
||||
while(*pszDottedD != '.' && *pszDottedD != '\0')
|
||||
pszDottedD++;
|
||||
if (*pszDottedD == '\0' && cBytes != 3)
|
||||
return 0;
|
||||
*pszDottedD = '\0';
|
||||
dwIP |= (atol(pszLastNum) & 0xFF) << (8*cBytes);
|
||||
pszLastNum = ++pszDottedD;
|
||||
}
|
||||
|
||||
return dwIP;
|
||||
|
||||
} // inet_ntoa()
|
||||
|
||||
|
||||
//
|
||||
// Function to extract the device name from the command line.
|
||||
//
|
||||
// Expect argstr = "/N:name
|
||||
//
|
||||
// Return FALSE for failure
|
||||
//
|
||||
BOOL
|
||||
ParseDeviceName(char * argstr)
|
||||
{
|
||||
UCHAR *pStart = NULL;
|
||||
UCHAR *pEnd = NULL;
|
||||
|
||||
if (argstr == NULL)
|
||||
return(FALSE);
|
||||
|
||||
pStart = (argstr + 2);
|
||||
while ((*pStart == ':') || (*pStart == '"'))
|
||||
{
|
||||
if (*pStart == '\0')
|
||||
return(FALSE);
|
||||
|
||||
++pStart;
|
||||
}
|
||||
|
||||
pEnd = pStart;
|
||||
while ((*pEnd != '"') && (*pEnd != '\0'))
|
||||
{
|
||||
++pEnd;
|
||||
}
|
||||
*pEnd = '\0';
|
||||
|
||||
if (pStart == pEnd)
|
||||
return(FALSE);
|
||||
|
||||
// Leave enough room for two character Ethernet controller type and
|
||||
// a numeric value derived from the MAC address, hence the 7.
|
||||
//
|
||||
strncpy(BootArgs.szDeviceNameRoot, pStart, (MAX_DEV_NAMELEN - 7));
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Function to extract the debug ethernet adapter options from the command line
|
||||
//
|
||||
// Expect argstr = "/E:<io addr>:<irq>:<debug zone mask>"
|
||||
//
|
||||
// Return FALSE for failure
|
||||
//
|
||||
BOOL
|
||||
ParseEthernetOptions(char * argstr)
|
||||
{
|
||||
BOOL bRet;
|
||||
char * begin;
|
||||
char * end;
|
||||
char endch;
|
||||
BYTE *pBase = NULL;
|
||||
UCHAR ucIRQ = 0;
|
||||
int a; // argument counter 0 = I/O Base Address, 1 = IRQ, etc.
|
||||
|
||||
bRet = FALSE;
|
||||
|
||||
if (strlen(argstr) < 6) { // "/E:0:1" or "/K:0:1" at minimum.
|
||||
goto peo_exit;
|
||||
}
|
||||
|
||||
// If the user wishes to use an RNDIS adapter, check for that here.
|
||||
// otherwise, just set it to default and let xBoot.bin change it if necessary.
|
||||
if (tolower(*(argstr + 1)) == 'k')
|
||||
BootArgs.ucEdbgAdapterType = 'R';
|
||||
else
|
||||
BootArgs.ucEdbgAdapterType = EDBG_ADAPTER_DEFAULT;
|
||||
|
||||
end = argstr + 2;
|
||||
|
||||
//
|
||||
// Extract the I/O Base address and IRQ from the command line
|
||||
// (and super secret EDBG debug zone mask)
|
||||
//
|
||||
for (a = 0; a < 4; a++) {
|
||||
begin = end;
|
||||
//
|
||||
// Colon delimited list
|
||||
//
|
||||
if (*begin != ':') {
|
||||
break;
|
||||
}
|
||||
begin++; // skip colon
|
||||
end = begin;
|
||||
while ((*end) && (*end != ':') && (*end != ' ')) {
|
||||
end++;
|
||||
}
|
||||
|
||||
if (begin == end) {
|
||||
break;
|
||||
}
|
||||
|
||||
endch = *end;
|
||||
*end = 0; // temporarily zero terminate the option string
|
||||
|
||||
switch (a) {
|
||||
case 0: // I/O base address
|
||||
pBase = (BYTE *)hex_atoi(begin);
|
||||
break;
|
||||
|
||||
case 1: // IRQ
|
||||
ucIRQ = (UCHAR)hex_atoi(begin);
|
||||
if (ucIRQ >= 0x10) // check for decimal value instead of hex value
|
||||
{
|
||||
ucIRQ -= 6;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: // IP address
|
||||
if ((BootArgs.EdbgAddr.dwIP = inet_addr(begin)) != 0) {
|
||||
printf("Using IP address %u.%u.%u.%u\n",
|
||||
(BYTE)(BootArgs.EdbgAddr.dwIP),
|
||||
(BYTE)(BootArgs.EdbgAddr.dwIP >> 8),
|
||||
(BYTE)(BootArgs.EdbgAddr.dwIP >> 16),
|
||||
(BYTE)(BootArgs.EdbgAddr.dwIP >> 24));
|
||||
}
|
||||
else
|
||||
printf("Invalid IP address %s\n",begin);
|
||||
break;
|
||||
|
||||
case 3: // EDBG Debug zone mask (defined in oak\inc\ethdbg.h)
|
||||
BootArgs.dwEdbgDebugZone = (DWORD)hex_atoi(begin);
|
||||
BootArgs.dwEdbgDebugZone |= 0x10000; // Add DHCP zones
|
||||
printf("Using debug zone mask 0x%X\n",BootArgs.dwEdbgDebugZone);
|
||||
break;
|
||||
|
||||
default: // error!
|
||||
goto peo_exit;
|
||||
}
|
||||
|
||||
*end = endch; // un-zero-terminate if need be.
|
||||
}
|
||||
|
||||
if (a < 2) {
|
||||
goto peo_exit;
|
||||
}
|
||||
|
||||
BootArgs.ucEdbgIRQ = ucIRQ;
|
||||
// WARNING - must mask off high bits
|
||||
BootArgs.dwEdbgBaseAddr = (DWORD)pBase & 0xFFFF;
|
||||
BootArgs.ucLoaderFlags |= LDRFL_USE_EDBG;
|
||||
printf("Debug network card at I/O port 0x%x, IRQ 0x%x\n", pBase, ucIRQ);
|
||||
bRet = TRUE;
|
||||
|
||||
peo_exit:
|
||||
return bRet;
|
||||
} // ParseEthernetOptions
|
||||
894
DOS/LOADCEPC/ethmain.cod
Normal file
894
DOS/LOADCEPC/ethmain.cod
Normal file
@ -0,0 +1,894 @@
|
||||
; Static Name Aliases
|
||||
;
|
||||
; $S477_pbEthernetBase EQU pbEthernetBase
|
||||
TITLE ethmain.c
|
||||
.286p
|
||||
.287
|
||||
INCLUDELIB SLIBCE
|
||||
INCLUDELIB OLDNAMES.LIB
|
||||
_TEXT SEGMENT WORD PUBLIC 'CODE'
|
||||
_TEXT ENDS
|
||||
_DATA SEGMENT WORD PUBLIC 'DATA'
|
||||
_DATA ENDS
|
||||
CONST SEGMENT WORD PUBLIC 'CONST'
|
||||
CONST ENDS
|
||||
_BSS SEGMENT WORD PUBLIC 'BSS'
|
||||
_BSS ENDS
|
||||
$$SYMBOLS SEGMENT BYTE PUBLIC 'DEBSYM'
|
||||
$$SYMBOLS ENDS
|
||||
$$TYPES SEGMENT BYTE PUBLIC 'DEBTYP'
|
||||
$$TYPES ENDS
|
||||
DGROUP GROUP CONST, _BSS, _DATA
|
||||
ASSUME DS: DGROUP, SS: DGROUP
|
||||
EXTRN _atol:NEAR
|
||||
EXTRN _printf:NEAR
|
||||
EXTRN _strncpy:NEAR
|
||||
EXTRN _tolower:NEAR
|
||||
_BSS SEGMENT
|
||||
COMM NEAR _BootArgs: BYTE: 170
|
||||
_BSS ENDS
|
||||
_DATA SEGMENT
|
||||
$SG555 DB 'Using IP address %u.%u.%u.%u', 0aH, 00H
|
||||
$SG557 DB 'Invalid IP address %s', 0aH, 00H
|
||||
$SG559 DB 'Using debug zone mask 0x%X', 0aH, 00H
|
||||
$SG562 DB 'Debug network card at I/O port 0x%x, IRQ 0x%x', 0aH, 00H
|
||||
_DATA ENDS
|
||||
_BSS SEGMENT
|
||||
$S477_pbEthernetBase DW 01H DUP (?)
|
||||
_BSS ENDS
|
||||
_TEXT SEGMENT
|
||||
ASSUME CS: _TEXT
|
||||
PUBLIC _hex_atoi
|
||||
_hex_atoi PROC NEAR
|
||||
;|*** //
|
||||
;|*** // Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
;|*** //
|
||||
;|*** //
|
||||
;|*** // Use of this sample source code is subject to the terms of the Microsoft
|
||||
;|*** // license agreement under which you licensed this sample source code. If
|
||||
;|*** // you did not accept the terms of the license agreement, you are not
|
||||
;|*** // authorized to use this sample source code. For the terms of the license,
|
||||
;|*** // please see the license agreement between you and Microsoft or, if applicable,
|
||||
;|*** // see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
;|*** // THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
;|*** //
|
||||
;|*** /*++
|
||||
;|*** THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|
||||
;|*** ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
;|*** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
||||
;|*** PARTICULAR PURPOSE.
|
||||
;|***
|
||||
;|*** Module Name:
|
||||
;|***
|
||||
;|*** Abstract:
|
||||
;|*** Loadcepc Ethernet routines.
|
||||
;|***
|
||||
;|*** Functions:
|
||||
;|***
|
||||
;|***
|
||||
;|*** Notes:
|
||||
;|***
|
||||
;|*** --*/
|
||||
;|***
|
||||
;|***
|
||||
;|*** #include <conio.h>
|
||||
;|*** #include <fcntl.h>
|
||||
;|*** #include <io.h>
|
||||
;|*** #include <stdio.h>
|
||||
;|*** #include <stdlib.h>
|
||||
;|*** #include <string.h>
|
||||
;|***
|
||||
;|***
|
||||
;|*** #include "loadcepc.h"
|
||||
;|*** #include "smchw.h"
|
||||
;|*** #include "wdm.h"
|
||||
;|***
|
||||
;|*** #include "ethernet.h"
|
||||
;|*** #include "bootarg.h"
|
||||
;|***
|
||||
;|*** BOOT_ARGS BootArgs;
|
||||
;|***
|
||||
;|*** // The base address for the card
|
||||
;|*** static BYTE volatile *pbEthernetBase;
|
||||
;|*** #define ReadWord( wOffset ) _inpw((USHORT)(pbEthernetBase + wOffset))
|
||||
;|*** #define WriteWord( wOffset, Value ) _outpw((USHORT)(pbEthernetBase + wOffset), (USHORT)Value)
|
||||
;|***
|
||||
;|***
|
||||
;|*** WORD
|
||||
;|*** hex_atoi(char * hexstr)
|
||||
;|*** {
|
||||
; Line 57
|
||||
*** 000000 c8 02 00 00 enter 2,0
|
||||
*** 000004 57 push di
|
||||
*** 000005 56 push si
|
||||
; hexstr = 4
|
||||
; register di = wRet
|
||||
*** 000006 8b 76 04 mov si,WORD PTR [bp+4] ;hexstr
|
||||
;|*** WORD wRet = 0;
|
||||
; Line 58
|
||||
*** 000009 33 ff xor di,di
|
||||
;|*** while (*hexstr) {
|
||||
; Line 59
|
||||
*** 00000b 80 3c 00 cmp BYTE PTR [si],0
|
||||
*** 00000e 74 4a je $FB485
|
||||
$FC484:
|
||||
;|*** wRet <<= 4;
|
||||
; Line 60
|
||||
*** 000010 c1 e7 04 shl di,4
|
||||
;|*** switch (*hexstr) {
|
||||
; Line 61
|
||||
*** 000013 8a 04 mov al,BYTE PTR [si]
|
||||
*** 000015 98 cbw
|
||||
*** 000016 89 46 fe mov WORD PTR [bp-2],ax
|
||||
;|*** case '1':
|
||||
;|*** case '2':
|
||||
;|*** case '3':
|
||||
;|*** case '4':
|
||||
;|*** case '5':
|
||||
;|*** case '6':
|
||||
;|*** case '7':
|
||||
;|*** case '8':
|
||||
;|*** case '9':
|
||||
;|*** wRet += (WORD)(*hexstr - '0');
|
||||
;|*** break;
|
||||
;|***
|
||||
;|*** case 'a':
|
||||
;|*** case 'b':
|
||||
;|*** case 'c':
|
||||
;|*** case 'd':
|
||||
;|*** case 'e':
|
||||
;|*** case 'f':
|
||||
;|*** wRet += (WORD)(*hexstr - 'a');
|
||||
;|*** wRet += 10;
|
||||
;|*** break;
|
||||
;|***
|
||||
;|*** case 'A':
|
||||
;|*** case 'B':
|
||||
;|*** case 'C':
|
||||
;|*** case 'D':
|
||||
;|*** case 'E':
|
||||
;|*** case 'F':
|
||||
;|*** wRet += (WORD)(*hexstr - 'A');
|
||||
;|*** wRet += 10;
|
||||
;|*** break;
|
||||
;|*** }
|
||||
; Line 93
|
||||
*** 000019 2d 31 00 sub ax,49 ;0031H
|
||||
*** 00001c 7c 36 jl $SB487
|
||||
*** 00001e 70 34 jo $SB487
|
||||
*** 000020 2d 08 00 sub ax,8
|
||||
*** 000023 7e 17 jle $SC490
|
||||
*** 000025 2d 08 00 sub ax,8
|
||||
*** 000028 7c 2a jl $SB487
|
||||
*** 00002a 2d 05 00 sub ax,5
|
||||
*** 00002d 7e 15 jle $SC492
|
||||
*** 00002f 2d 1b 00 sub ax,27 ;001bH
|
||||
*** 000032 7c 20 jl $SB487
|
||||
*** 000034 2d 05 00 sub ax,5
|
||||
*** 000037 7e 13 jle $SC491
|
||||
*** 000039 eb 19 jmp SHORT $SB487
|
||||
*** 00003b 90 nop
|
||||
;|*** case '1':
|
||||
; Line 62
|
||||
$SC490:
|
||||
;|*** case '2':
|
||||
;|*** case '3':
|
||||
;|*** case '4':
|
||||
;|*** case '5':
|
||||
;|*** case '6':
|
||||
;|*** case '7':
|
||||
;|*** case '8':
|
||||
;|*** case '9':
|
||||
;|*** wRet += (WORD)(*hexstr - '0');
|
||||
; Line 71
|
||||
*** 00003c 8b 46 fe mov ax,WORD PTR [bp-2]
|
||||
*** 00003f 2d 30 00 sub ax,48 ;0030H
|
||||
*** 000042 eb 0e jmp SHORT $L586
|
||||
;|*** break;
|
||||
;|***
|
||||
;|*** case 'a':
|
||||
;|*** case 'b':
|
||||
;|*** case 'c':
|
||||
;|*** case 'd':
|
||||
;|*** case 'e':
|
||||
;|*** case 'f':
|
||||
;|*** wRet += (WORD)(*hexstr - 'a');
|
||||
;|*** wRet += 10;
|
||||
;|*** break;
|
||||
;|***
|
||||
;|*** case 'A':
|
||||
; Line 84
|
||||
$SC492:
|
||||
;|*** case 'B':
|
||||
;|*** case 'C':
|
||||
;|*** case 'D':
|
||||
;|*** case 'E':
|
||||
;|*** case 'F':
|
||||
;|*** wRet += (WORD)(*hexstr - 'A');
|
||||
;|*** wRet += 10;
|
||||
; Line 91
|
||||
*** 000044 8b 46 fe mov ax,WORD PTR [bp-2]
|
||||
*** 000047 2d 37 00 sub ax,55 ;0037H
|
||||
*** 00004a eb 06 jmp SHORT $L586
|
||||
;|*** case 'a':
|
||||
; Line 74
|
||||
$SC491:
|
||||
;|*** case 'b':
|
||||
;|*** case 'c':
|
||||
;|*** case 'd':
|
||||
;|*** case 'e':
|
||||
;|*** case 'f':
|
||||
;|*** wRet += (WORD)(*hexstr - 'a');
|
||||
;|*** wRet += 10;
|
||||
; Line 81
|
||||
*** 00004c 8b 46 fe mov ax,WORD PTR [bp-2]
|
||||
*** 00004f 2d 57 00 sub ax,87 ;0057H
|
||||
$L586:
|
||||
*** 000052 03 f8 add di,ax
|
||||
;|*** break;
|
||||
;|***
|
||||
;|*** case 'A':
|
||||
;|*** case 'B':
|
||||
;|*** case 'C':
|
||||
;|*** case 'D':
|
||||
;|*** case 'E':
|
||||
;|*** case 'F':
|
||||
;|*** wRet += (WORD)(*hexstr - 'A');
|
||||
;|*** wRet += 10;
|
||||
;|*** break;
|
||||
;|*** }
|
||||
; Line 93
|
||||
$SB487:
|
||||
;|*** hexstr++;
|
||||
;|*** }
|
||||
; Line 95
|
||||
*** 000054 46 inc si
|
||||
*** 000055 80 3c 00 cmp BYTE PTR [si],0
|
||||
*** 000058 75 b6 jne $FC484
|
||||
$FB485:
|
||||
;|*** return wRet;
|
||||
; Line 96
|
||||
*** 00005a 8b c7 mov ax,di
|
||||
;|*** } // hex_atoi
|
||||
; Line 97
|
||||
*** 00005c 5e pop si
|
||||
*** 00005d 5f pop di
|
||||
*** 00005e c9 leave
|
||||
*** 00005f c3 ret
|
||||
|
||||
_hex_atoi ENDP
|
||||
PUBLIC _inet_addr
|
||||
_inet_addr PROC NEAR
|
||||
;|***
|
||||
;|***
|
||||
;|*** // This routine will take a dotted decimal IP address as represent here and return a binary version of it
|
||||
;|*** DWORD inet_addr( char *pszDottedD ) {
|
||||
; Line 101
|
||||
*** 000060 c8 0a 00 00 enter 10,0
|
||||
*** 000064 57 push di
|
||||
*** 000065 56 push si
|
||||
; pszDottedD = 4
|
||||
; dwIP = -8
|
||||
; cBytes = -4
|
||||
; pszLastNum = -10
|
||||
*** 000066 8b 76 04 mov si,WORD PTR [bp+4] ;pszDottedD
|
||||
;|***
|
||||
;|*** DWORD dwIP = 0;
|
||||
; Line 103
|
||||
*** 000069 2b c0 sub ax,ax
|
||||
*** 00006b 89 46 fa mov WORD PTR [bp-6],ax
|
||||
*** 00006e 89 46 f8 mov WORD PTR [bp-8],ax ;dwIP
|
||||
;|*** DWORD cBytes;
|
||||
;|*** char *pszLastNum;
|
||||
;|***
|
||||
;|*** // Replace the dots with NULL terminators
|
||||
;|*** pszLastNum = pszDottedD;
|
||||
; Line 108
|
||||
*** 000071 8b fe mov di,si
|
||||
;|*** for( cBytes = 0; cBytes < 4; cBytes++ ) {
|
||||
; Line 109
|
||||
*** 000073 89 46 fe mov WORD PTR [bp-2],ax
|
||||
*** 000076 89 46 fc mov WORD PTR [bp-4],ax ;cBytes
|
||||
$F500:
|
||||
*** 000079 83 7e fe 00 cmp WORD PTR [bp-2],0
|
||||
*** 00007d 75 5b jne $L567
|
||||
*** 00007f 83 7e fc 04 cmp WORD PTR [bp-4],4 ;cBytes
|
||||
*** 000083 73 55 jae $L567
|
||||
;|*** while(*pszDottedD != '.' && *pszDottedD != '\0')
|
||||
; Line 110
|
||||
*** 000085 80 3c 2e cmp BYTE PTR [si],46 ;002eH
|
||||
*** 000088 74 0b je $FB505
|
||||
$FC504:
|
||||
*** 00008a 80 3c 00 cmp BYTE PTR [si],0
|
||||
*** 00008d 74 06 je $FB505
|
||||
;|*** pszDottedD++;
|
||||
; Line 111
|
||||
*** 00008f 46 inc si
|
||||
*** 000090 80 3c 2e cmp BYTE PTR [si],46 ;002eH
|
||||
*** 000093 75 f5 jne $FC504
|
||||
$FB505:
|
||||
;|*** if (*pszDottedD == '\0' && cBytes != 3)
|
||||
; Line 112
|
||||
*** 000095 80 3c 00 cmp BYTE PTR [si],0
|
||||
*** 000098 75 0c jne $I506
|
||||
*** 00009a 83 7e fc 03 cmp WORD PTR [bp-4],3 ;cBytes
|
||||
*** 00009e 75 44 jne $L568
|
||||
*** 0000a0 83 7e fe 00 cmp WORD PTR [bp-2],0
|
||||
*** 0000a4 75 3e jne $L568
|
||||
;|*** return 0;
|
||||
;|*** *pszDottedD = '\0';
|
||||
; Line 114
|
||||
$I506:
|
||||
*** 0000a6 c6 04 00 mov BYTE PTR [si],0
|
||||
;|*** dwIP |= (atol(pszLastNum) & 0xFF) << (8*cBytes);
|
||||
; Line 115
|
||||
*** 0000a9 57 push di
|
||||
*** 0000aa e8 00 00 call _atol
|
||||
*** 0000ad 83 c4 02 add sp,2
|
||||
*** 0000b0 2a e4 sub ah,ah
|
||||
*** 0000b2 2b d2 sub dx,dx
|
||||
*** 0000b4 8a 4e fc mov cl,BYTE PTR [bp-4] ;cBytes
|
||||
*** 0000b7 c0 e1 03 shl cl,3
|
||||
*** 0000ba 0a c9 or cl,cl
|
||||
*** 0000bc 74 08 je $L573
|
||||
$L572:
|
||||
*** 0000be 03 c0 add ax,ax
|
||||
*** 0000c0 13 d2 adc dx,dx
|
||||
*** 0000c2 fe c9 dec cl
|
||||
*** 0000c4 75 f8 jne $L572
|
||||
$L573:
|
||||
*** 0000c6 09 46 f8 or WORD PTR [bp-8],ax ;dwIP
|
||||
*** 0000c9 09 56 fa or WORD PTR [bp-6],dx
|
||||
;|*** pszLastNum = ++pszDottedD;
|
||||
; Line 116
|
||||
*** 0000cc 46 inc si
|
||||
*** 0000cd 8b fe mov di,si
|
||||
;|*** for( cBytes = 0; cBytes < 4; cBytes++ ) {
|
||||
; Line 109
|
||||
*** 0000cf 83 46 fc 01 add WORD PTR [bp-4],1 ;cBytes
|
||||
*** 0000d3 83 56 fe 00 adc WORD PTR [bp-2],0
|
||||
*** 0000d7 eb a0 jmp SHORT $F500
|
||||
*** 0000d9 90 nop
|
||||
$L567:
|
||||
;|*** while(*pszDottedD != '.' && *pszDottedD != '\0')
|
||||
;|*** pszDottedD++;
|
||||
;|*** if (*pszDottedD == '\0' && cBytes != 3)
|
||||
;|*** return 0;
|
||||
;|*** *pszDottedD = '\0';
|
||||
;|*** dwIP |= (atol(pszLastNum) & 0xFF) << (8*cBytes);
|
||||
;|*** pszLastNum = ++pszDottedD;
|
||||
;|*** }
|
||||
;|***
|
||||
;|*** return dwIP;
|
||||
; Line 119
|
||||
*** 0000da 8b 46 f8 mov ax,WORD PTR [bp-8] ;dwIP
|
||||
*** 0000dd 8b 56 fa mov dx,WORD PTR [bp-6]
|
||||
*** 0000e0 5e pop si
|
||||
*** 0000e1 5f pop di
|
||||
*** 0000e2 c9 leave
|
||||
*** 0000e3 c3 ret
|
||||
$L568:
|
||||
;|*** return 0;
|
||||
; Line 113
|
||||
*** 0000e4 33 c0 xor ax,ax
|
||||
*** 0000e6 99 cwd
|
||||
;|*** *pszDottedD = '\0';
|
||||
;|*** dwIP |= (atol(pszLastNum) & 0xFF) << (8*cBytes);
|
||||
;|*** pszLastNum = ++pszDottedD;
|
||||
;|*** }
|
||||
;|***
|
||||
;|*** return dwIP;
|
||||
;|***
|
||||
;|*** } // inet_ntoa()
|
||||
; Line 121
|
||||
*** 0000e7 5e pop si
|
||||
*** 0000e8 5f pop di
|
||||
*** 0000e9 c9 leave
|
||||
*** 0000ea c3 ret
|
||||
*** 0000eb 90 nop
|
||||
|
||||
_inet_addr ENDP
|
||||
PUBLIC _ParseDeviceName
|
||||
_ParseDeviceName PROC NEAR
|
||||
;|***
|
||||
;|***
|
||||
;|*** //
|
||||
;|*** // Function to extract the device name from the command line.
|
||||
;|*** //
|
||||
;|*** // Expect argstr = "/N:name
|
||||
;|*** //
|
||||
;|*** // Return FALSE for failure
|
||||
;|*** //
|
||||
;|*** BOOL
|
||||
;|*** ParseDeviceName(char * argstr)
|
||||
;|*** {
|
||||
; Line 133
|
||||
*** 0000ec c8 02 00 00 enter 2,0
|
||||
*** 0000f0 56 push si
|
||||
; register bx = pEnd
|
||||
; argstr = 4
|
||||
; pStart = -2
|
||||
*** 0000f1 8b 56 04 mov dx,WORD PTR [bp+4] ;argstr
|
||||
;|*** UCHAR *pStart = NULL;
|
||||
;|*** UCHAR *pEnd = NULL;
|
||||
;|***
|
||||
;|*** if (argstr == NULL)
|
||||
; Line 137
|
||||
*** 0000f4 0b d2 or dx,dx
|
||||
*** 0000f6 74 44 je $L577
|
||||
;|*** return(FALSE);
|
||||
;|***
|
||||
;|*** pStart = (argstr + 2);
|
||||
; Line 140
|
||||
*** 0000f8 8b f2 mov si,dx
|
||||
*** 0000fa 83 c6 02 add si,2
|
||||
;|*** while ((*pStart == ':') || (*pStart == '"'))
|
||||
; Line 141
|
||||
$FC515:
|
||||
*** 0000fd 80 3c 3a cmp BYTE PTR [si],58 ;003aH
|
||||
*** 000100 74 05 je $FB517
|
||||
*** 000102 80 3c 22 cmp BYTE PTR [si],34 ;0022H
|
||||
*** 000105 75 09 jne $L576
|
||||
$FB517:
|
||||
;|*** {
|
||||
;|*** if (*pStart == '\0')
|
||||
; Line 143
|
||||
*** 000107 80 3c 00 cmp BYTE PTR [si],0
|
||||
*** 00010a 74 30 je $L577
|
||||
;|*** return(FALSE);
|
||||
;|***
|
||||
;|*** ++pStart;
|
||||
; Line 146
|
||||
*** 00010c 46 inc si
|
||||
;|*** }
|
||||
; Line 147
|
||||
*** 00010d eb ee jmp SHORT $FC515
|
||||
*** 00010f 90 nop
|
||||
$L576:
|
||||
;|***
|
||||
;|*** pEnd = pStart;
|
||||
;|*** while ((*pEnd != '"') && (*pEnd != '\0'))
|
||||
; Line 150
|
||||
*** 000110 8b de mov bx,si
|
||||
*** 000112 80 3f 22 cmp BYTE PTR [bx],34 ;0022H
|
||||
*** 000115 74 0b je $FB521
|
||||
$FC520:
|
||||
*** 000117 80 3f 00 cmp BYTE PTR [bx],0
|
||||
*** 00011a 74 06 je $FB521
|
||||
;|*** {
|
||||
;|*** ++pEnd;
|
||||
;|*** }
|
||||
; Line 153
|
||||
*** 00011c 43 inc bx
|
||||
*** 00011d 80 3f 22 cmp BYTE PTR [bx],34 ;0022H
|
||||
*** 000120 75 f5 jne $FC520
|
||||
$FB521:
|
||||
;|*** *pEnd = '\0';
|
||||
; Line 154
|
||||
*** 000122 c6 07 00 mov BYTE PTR [bx],0
|
||||
;|***
|
||||
;|*** if (pStart == pEnd)
|
||||
; Line 156
|
||||
*** 000125 3b de cmp bx,si
|
||||
*** 000127 74 13 je $L577
|
||||
;|*** return(FALSE);
|
||||
;|***
|
||||
;|*** // Leave enough room for two character Ethernet controller type and
|
||||
;|*** // a numeric value derived from the MAC address, hence the 7.
|
||||
;|*** //
|
||||
;|*** strncpy(BootArgs.szDeviceNameRoot, pStart, (MAX_DEV_NAMELEN - 7));
|
||||
; Line 162
|
||||
*** 000129 6a 09 push 9
|
||||
*** 00012b 56 push si
|
||||
*** 00012c 68 88 00 push OFFSET DGROUP:_BootArgs+136
|
||||
*** 00012f e8 00 00 call _strncpy
|
||||
*** 000132 83 c4 06 add sp,6
|
||||
;|***
|
||||
;|*** return(TRUE);
|
||||
; Line 164
|
||||
*** 000135 b8 01 00 mov ax,1
|
||||
*** 000138 5e pop si
|
||||
*** 000139 c9 leave
|
||||
*** 00013a c3 ret
|
||||
*** 00013b 90 nop
|
||||
$L577:
|
||||
;|*** return(FALSE);
|
||||
; Line 144
|
||||
*** 00013c 33 c0 xor ax,ax
|
||||
;|***
|
||||
;|*** ++pStart;
|
||||
;|*** }
|
||||
;|***
|
||||
;|*** pEnd = pStart;
|
||||
;|*** while ((*pEnd != '"') && (*pEnd != '\0'))
|
||||
;|*** {
|
||||
;|*** ++pEnd;
|
||||
;|*** }
|
||||
;|*** *pEnd = '\0';
|
||||
;|***
|
||||
;|*** if (pStart == pEnd)
|
||||
;|*** return(FALSE);
|
||||
;|***
|
||||
;|*** // Leave enough room for two character Ethernet controller type and
|
||||
;|*** // a numeric value derived from the MAC address, hence the 7.
|
||||
;|*** //
|
||||
;|*** strncpy(BootArgs.szDeviceNameRoot, pStart, (MAX_DEV_NAMELEN - 7));
|
||||
;|***
|
||||
;|*** return(TRUE);
|
||||
;|*** }
|
||||
; Line 165
|
||||
*** 00013e 5e pop si
|
||||
*** 00013f c9 leave
|
||||
*** 000140 c3 ret
|
||||
*** 000141 90 nop
|
||||
|
||||
_ParseDeviceName ENDP
|
||||
PUBLIC _ParseEthernetOptions
|
||||
_ParseEthernetOptions PROC NEAR
|
||||
;|***
|
||||
;|***
|
||||
;|*** //
|
||||
;|*** // Function to extract the debug ethernet adapter options from the command line
|
||||
;|*** //
|
||||
;|*** // Expect argstr = "/E:<io addr>:<irq>:<debug zone mask>"
|
||||
;|*** //
|
||||
;|*** // Return FALSE for failure
|
||||
;|*** //
|
||||
;|*** BOOL
|
||||
;|*** ParseEthernetOptions(char * argstr)
|
||||
;|*** {
|
||||
; Line 177
|
||||
*** 000142 c8 0c 00 00 enter 12,0
|
||||
*** 000146 57 push di
|
||||
*** 000147 56 push si
|
||||
; argstr = 4
|
||||
; bRet = -10
|
||||
; begin = -6
|
||||
; end = -2
|
||||
; endch = -3
|
||||
; pBase = -12
|
||||
; ucIRQ = -4
|
||||
; a = -8
|
||||
*** 000148 8b 76 04 mov si,WORD PTR [bp+4] ;argstr
|
||||
;|*** BOOL bRet;
|
||||
;|*** char * begin;
|
||||
;|*** char * end;
|
||||
;|*** char endch;
|
||||
;|*** BYTE *pBase = NULL;
|
||||
; Line 182
|
||||
*** 00014b c7 46 f4 00 00 mov WORD PTR [bp-12],0 ;pBase
|
||||
;|*** UCHAR ucIRQ = 0;
|
||||
; Line 183
|
||||
*** 000150 c6 46 fc 00 mov BYTE PTR [bp-4],0 ;ucIRQ
|
||||
;|*** int a; // argument counter 0 = I/O Base Address, 1 = IRQ, etc.
|
||||
;|***
|
||||
;|*** bRet = FALSE;
|
||||
; Line 186
|
||||
*** 000154 c7 46 f6 00 00 mov WORD PTR [bp-10],0 ;bRet
|
||||
;|***
|
||||
;|*** if (strlen(argstr) < 6) { // "/E:0:1" or "/K:0:1" at minimum.
|
||||
; Line 188
|
||||
*** 000159 8b fe mov di,si
|
||||
*** 00015b 8c d8 mov ax,ds
|
||||
*** 00015d 8e c0 mov es,ax
|
||||
*** 00015f b9 ff ff mov cx,-1 ;ffffH
|
||||
*** 000162 33 c0 xor ax,ax
|
||||
*** 000164 f2 repnz
|
||||
*** 000165 ae scasb
|
||||
*** 000166 f7 d1 not cx
|
||||
*** 000168 49 dec cx
|
||||
*** 000169 83 f9 06 cmp cx,6
|
||||
*** 00016c 73 03 jae $JCC364
|
||||
*** 00016e e9 3f 01 jmp $peo_exit535
|
||||
$JCC364:
|
||||
;|*** goto peo_exit;
|
||||
;|*** }
|
||||
;|***
|
||||
;|*** // If the user wishes to use an RNDIS adapter, check for that here.
|
||||
;|*** // otherwise, just set it to default and let xBoot.bin change it if necessary.
|
||||
;|*** if (tolower(*(argstr + 1)) == 'k')
|
||||
; Line 194
|
||||
*** 000171 8a 44 01 mov al,BYTE PTR [si+1]
|
||||
*** 000174 98 cbw
|
||||
*** 000175 50 push ax
|
||||
*** 000176 e8 00 00 call _tolower
|
||||
*** 000179 83 c4 02 add sp,2
|
||||
*** 00017c 3d 6b 00 cmp ax,107 ;006bH
|
||||
*** 00017f 75 05 jne $I536
|
||||
*** 000181 b0 52 mov al,82 ;0052H
|
||||
*** 000183 eb 03 jmp SHORT $I537
|
||||
*** 000185 90 nop
|
||||
$I536:
|
||||
*** 000186 b0 02 mov al,2
|
||||
$I537:
|
||||
*** 000188 a2 0e 00 mov BYTE PTR _BootArgs+14,al
|
||||
;|*** BootArgs.ucEdbgAdapterType = 'R';
|
||||
;|*** else
|
||||
;|*** BootArgs.ucEdbgAdapterType = EDBG_ADAPTER_DEFAULT;
|
||||
;|***
|
||||
;|*** end = argstr + 2;
|
||||
; Line 199
|
||||
*** 00018b 8d 44 02 lea ax,WORD PTR [si+2]
|
||||
;|***
|
||||
;|*** //
|
||||
;|*** // Extract the I/O Base address and IRQ from the command line
|
||||
;|*** // (and super secret EDBG debug zone mask)
|
||||
;|*** //
|
||||
;|*** for (a = 0; a < 4; a++) {
|
||||
; Line 205
|
||||
*** 00018e c7 46 f8 00 00 mov WORD PTR [bp-8],0 ;a
|
||||
*** 000193 8b f0 mov si,ax
|
||||
$F538:
|
||||
;|*** begin = end;
|
||||
;|*** //
|
||||
;|*** // Colon delimited list
|
||||
;|*** //
|
||||
;|*** if (*begin != ':') {
|
||||
; Line 210
|
||||
*** 000195 8b fe mov di,si
|
||||
*** 000197 80 3d 3a cmp BYTE PTR [di],58 ;003aH
|
||||
*** 00019a 74 03 je $JCC410
|
||||
*** 00019c e9 e1 00 jmp $FB540
|
||||
$JCC410:
|
||||
;|*** break;
|
||||
;|*** }
|
||||
;|*** begin++; // skip colon
|
||||
;|*** end = begin;
|
||||
; Line 214
|
||||
*** 00019f 47 inc di
|
||||
*** 0001a0 8b f7 mov si,di
|
||||
*** 0001a2 89 7e fa mov WORD PTR [bp-6],di ;begin
|
||||
;|*** while ((*end) && (*end != ':') && (*end != ' ')) {
|
||||
; Line 215
|
||||
*** 0001a5 80 3c 00 cmp BYTE PTR [si],0
|
||||
*** 0001a8 74 10 je $FB544
|
||||
$FC543:
|
||||
*** 0001aa 80 3c 3a cmp BYTE PTR [si],58 ;003aH
|
||||
*** 0001ad 74 0b je $FB544
|
||||
*** 0001af 80 3c 20 cmp BYTE PTR [si],32 ;0020H
|
||||
*** 0001b2 74 06 je $FB544
|
||||
;|*** end++;
|
||||
;|*** }
|
||||
; Line 217
|
||||
*** 0001b4 46 inc si
|
||||
*** 0001b5 80 3c 00 cmp BYTE PTR [si],0
|
||||
*** 0001b8 75 f0 jne $FC543
|
||||
$FB544:
|
||||
;|***
|
||||
;|*** if (begin == end) {
|
||||
; Line 219
|
||||
*** 0001ba 39 76 fa cmp WORD PTR [bp-6],si ;begin
|
||||
*** 0001bd 75 03 jne $JCC445
|
||||
*** 0001bf e9 be 00 jmp $FB540
|
||||
$JCC445:
|
||||
;|*** break;
|
||||
;|*** }
|
||||
;|***
|
||||
;|*** endch = *end;
|
||||
; Line 223
|
||||
*** 0001c2 8a 04 mov al,BYTE PTR [si]
|
||||
*** 0001c4 88 46 fd mov BYTE PTR [bp-3],al ;endch
|
||||
;|*** *end = 0; // temporarily zero terminate the option string
|
||||
; Line 224
|
||||
*** 0001c7 c6 04 00 mov BYTE PTR [si],0
|
||||
;|***
|
||||
;|*** switch (a) {
|
||||
; Line 226
|
||||
*** 0001ca 8b 46 f8 mov ax,WORD PTR [bp-8] ;a
|
||||
;|*** case 0: // I/O base address
|
||||
;|*** pBase = (BYTE *)hex_atoi(begin);
|
||||
;|*** break;
|
||||
;|***
|
||||
;|*** case 1: // IRQ
|
||||
;|*** ucIRQ = (UCHAR)hex_atoi(begin);
|
||||
;|*** if (ucIRQ >= 0x10) // check for decimal value instead of hex value
|
||||
;|*** {
|
||||
;|*** ucIRQ -= 6;
|
||||
;|*** }
|
||||
;|*** break;
|
||||
;|***
|
||||
;|*** case 2: // IP address
|
||||
;|*** if ((BootArgs.EdbgAddr.dwIP = inet_addr(begin)) != 0) {
|
||||
;|*** printf("Using IP address %u.%u.%u.%u\n",
|
||||
;|*** (BYTE)(BootArgs.EdbgAddr.dwIP),
|
||||
;|*** (BYTE)(BootArgs.EdbgAddr.dwIP >> 8),
|
||||
;|*** (BYTE)(BootArgs.EdbgAddr.dwIP >> 16),
|
||||
;|*** (BYTE)(BootArgs.EdbgAddr.dwIP >> 24));
|
||||
;|*** }
|
||||
;|*** else
|
||||
;|*** printf("Invalid IP address %s\n",begin);
|
||||
;|*** break;
|
||||
;|***
|
||||
;|*** case 3: // EDBG Debug zone mask (defined in oak\inc\ethdbg.h)
|
||||
;|*** BootArgs.dwEdbgDebugZone = (DWORD)hex_atoi(begin);
|
||||
;|*** BootArgs.dwEdbgDebugZone |= 0x10000; // Add DHCP zones
|
||||
;|*** printf("Using debug zone mask 0x%X\n",BootArgs.dwEdbgDebugZone);
|
||||
;|*** break;
|
||||
;|***
|
||||
;|*** default: // error!
|
||||
;|*** goto peo_exit;
|
||||
;|*** }
|
||||
; Line 259
|
||||
*** 0001cd 0b c0 or ax,ax
|
||||
*** 0001cf 74 0d je $SC550
|
||||
*** 0001d1 48 dec ax
|
||||
*** 0001d2 74 1a je $SC551
|
||||
*** 0001d4 48 dec ax
|
||||
*** 0001d5 74 2d je $SC553
|
||||
*** 0001d7 48 dec ax
|
||||
*** 0001d8 74 70 je $SC558
|
||||
*** 0001da e9 d3 00 jmp $peo_exit535
|
||||
*** 0001dd 90 nop
|
||||
;|*** case 0: // I/O base address
|
||||
; Line 227
|
||||
$SC550:
|
||||
;|*** pBase = (BYTE *)hex_atoi(begin);
|
||||
; Line 228
|
||||
*** 0001de ff 76 fa push WORD PTR [bp-6] ;begin
|
||||
*** 0001e1 e8 1c fe call _hex_atoi
|
||||
*** 0001e4 83 c4 02 add sp,2
|
||||
*** 0001e7 89 46 f4 mov WORD PTR [bp-12],ax ;pBase
|
||||
;|*** break;
|
||||
; Line 229
|
||||
*** 0001ea e9 82 00 jmp $SB547
|
||||
*** 0001ed 90 nop
|
||||
;|***
|
||||
;|*** case 1: // IRQ
|
||||
; Line 231
|
||||
$SC551:
|
||||
;|*** ucIRQ = (UCHAR)hex_atoi(begin);
|
||||
;|*** if (ucIRQ >= 0x10) // check for decimal value instead of hex value
|
||||
; Line 233
|
||||
*** 0001ee ff 76 fa push WORD PTR [bp-6] ;begin
|
||||
*** 0001f1 e8 0c fe call _hex_atoi
|
||||
*** 0001f4 83 c4 02 add sp,2
|
||||
*** 0001f7 88 46 fc mov BYTE PTR [bp-4],al ;ucIRQ
|
||||
*** 0001fa 3c 10 cmp al,16 ;0010H
|
||||
*** 0001fc 72 71 jb $SB547
|
||||
;|*** {
|
||||
;|*** ucIRQ -= 6;
|
||||
; Line 235
|
||||
*** 0001fe 80 6e fc 06 sub BYTE PTR [bp-4],6 ;ucIRQ
|
||||
;|*** }
|
||||
;|*** break;
|
||||
; Line 237
|
||||
*** 000202 eb 6b jmp SHORT $SB547
|
||||
;|***
|
||||
;|*** case 2: // IP address
|
||||
; Line 239
|
||||
$SC553:
|
||||
*** 000204 8b 7e fa mov di,WORD PTR [bp-6] ;begin
|
||||
;|*** if ((BootArgs.EdbgAddr.dwIP = inet_addr(begin)) != 0) {
|
||||
; Line 240
|
||||
*** 000207 57 push di
|
||||
*** 000208 e8 55 fe call _inet_addr
|
||||
*** 00020b 83 c4 02 add sp,2
|
||||
*** 00020e a3 18 00 mov WORD PTR _BootArgs+24,ax
|
||||
*** 000211 89 16 1a 00 mov WORD PTR _BootArgs+26,dx
|
||||
*** 000215 8b c2 mov ax,dx
|
||||
*** 000217 0b 06 18 00 or ax,WORD PTR _BootArgs+24
|
||||
*** 00021b 74 21 je $I554
|
||||
;|*** printf("Using IP address %u.%u.%u.%u\n",
|
||||
;|*** (BYTE)(BootArgs.EdbgAddr.dwIP),
|
||||
;|*** (BYTE)(BootArgs.EdbgAddr.dwIP >> 8),
|
||||
;|*** (BYTE)(BootArgs.EdbgAddr.dwIP >> 16),
|
||||
;|*** (BYTE)(BootArgs.EdbgAddr.dwIP >> 24));
|
||||
; Line 245
|
||||
*** 00021d a0 1b 00 mov al,BYTE PTR _BootArgs+27
|
||||
*** 000220 2a e4 sub ah,ah
|
||||
*** 000222 50 push ax
|
||||
*** 000223 a0 1a 00 mov al,BYTE PTR _BootArgs+26
|
||||
*** 000226 50 push ax
|
||||
*** 000227 a1 18 00 mov ax,WORD PTR _BootArgs+24
|
||||
*** 00022a 8a c4 mov al,ah
|
||||
*** 00022c 2a e4 sub ah,ah
|
||||
*** 00022e 50 push ax
|
||||
*** 00022f a0 18 00 mov al,BYTE PTR _BootArgs+24
|
||||
*** 000232 50 push ax
|
||||
*** 000233 68 00 00 push OFFSET DGROUP:$SG555
|
||||
*** 000236 e8 00 00 call _printf
|
||||
*** 000239 83 c4 0a add sp,10 ;000aH
|
||||
;|*** }
|
||||
;|*** else
|
||||
; Line 247
|
||||
*** 00023c eb 31 jmp SHORT $SB547
|
||||
$I554:
|
||||
;|*** printf("Invalid IP address %s\n",begin);
|
||||
; Line 248
|
||||
*** 00023e 57 push di
|
||||
*** 00023f 68 00 00 push OFFSET DGROUP:$SG557
|
||||
*** 000242 e8 00 00 call _printf
|
||||
*** 000245 83 c4 04 add sp,4
|
||||
;|*** break;
|
||||
; Line 249
|
||||
*** 000248 eb 25 jmp SHORT $SB547
|
||||
;|***
|
||||
;|*** case 3: // EDBG Debug zone mask (defined in oak\inc\ethdbg.h)
|
||||
; Line 251
|
||||
$SC558:
|
||||
;|*** BootArgs.dwEdbgDebugZone = (DWORD)hex_atoi(begin);
|
||||
; Line 252
|
||||
*** 00024a ff 76 fa push WORD PTR [bp-6] ;begin
|
||||
*** 00024d e8 b0 fd call _hex_atoi
|
||||
*** 000250 83 c4 02 add sp,2
|
||||
*** 000253 a3 14 00 mov WORD PTR _BootArgs+20,ax
|
||||
*** 000256 c7 06 16 00 00 00 mov WORD PTR _BootArgs+22,0
|
||||
;|*** BootArgs.dwEdbgDebugZone |= 0x10000; // Add DHCP zones
|
||||
;|*** printf("Using debug zone mask 0x%X\n",BootArgs.dwEdbgDebugZone);
|
||||
; Line 254
|
||||
*** 00025c 80 0e 16 00 01 or BYTE PTR _BootArgs+22,1
|
||||
*** 000261 ff 36 16 00 push WORD PTR _BootArgs+22
|
||||
*** 000265 50 push ax
|
||||
*** 000266 68 00 00 push OFFSET DGROUP:$SG559
|
||||
*** 000269 e8 00 00 call _printf
|
||||
*** 00026c 83 c4 06 add sp,6
|
||||
;|*** break;
|
||||
;|***
|
||||
;|*** default: // error!
|
||||
;|*** goto peo_exit;
|
||||
;|*** }
|
||||
; Line 259
|
||||
$SB547:
|
||||
;|***
|
||||
;|*** *end = endch; // un-zero-terminate if need be.
|
||||
; Line 261
|
||||
*** 00026f 8a 46 fd mov al,BYTE PTR [bp-3] ;endch
|
||||
*** 000272 88 04 mov BYTE PTR [si],al
|
||||
*** 000274 ff 46 f8 inc WORD PTR [bp-8] ;a
|
||||
*** 000277 83 7e f8 04 cmp WORD PTR [bp-8],4 ;a
|
||||
*** 00027b 7d 03 jge $JCC635
|
||||
*** 00027d e9 15 ff jmp $F538
|
||||
$JCC635:
|
||||
;|*** }
|
||||
; Line 262
|
||||
$FB540:
|
||||
;|***
|
||||
;|*** if (a < 2) {
|
||||
; Line 264
|
||||
*** 000280 83 7e f8 02 cmp WORD PTR [bp-8],2 ;a
|
||||
*** 000284 7c 2a jl $peo_exit535
|
||||
;|*** goto peo_exit;
|
||||
;|*** }
|
||||
;|***
|
||||
;|*** BootArgs.ucEdbgIRQ = ucIRQ;
|
||||
; Line 268
|
||||
*** 000286 8a 46 fc mov al,BYTE PTR [bp-4] ;ucIRQ
|
||||
*** 000289 a2 0f 00 mov BYTE PTR _BootArgs+15,al
|
||||
;|*** // WARNING - must mask off high bits
|
||||
;|*** BootArgs.dwEdbgBaseAddr = (DWORD)pBase & 0xFFFF;
|
||||
; Line 270
|
||||
*** 00028c 8b 4e f4 mov cx,WORD PTR [bp-12] ;pBase
|
||||
*** 00028f 89 0e 10 00 mov WORD PTR _BootArgs+16,cx
|
||||
*** 000293 c7 06 12 00 00 00 mov WORD PTR _BootArgs+18,0
|
||||
;|*** BootArgs.ucLoaderFlags |= LDRFL_USE_EDBG;
|
||||
; Line 271
|
||||
*** 000299 80 0e 0c 00 01 or BYTE PTR _BootArgs+12,1
|
||||
;|*** printf("Debug network card at I/O port 0x%x, IRQ 0x%x\n", pBase, ucIRQ);
|
||||
; Line 272
|
||||
*** 00029e 2a e4 sub ah,ah
|
||||
*** 0002a0 50 push ax
|
||||
*** 0002a1 51 push cx
|
||||
*** 0002a2 68 00 00 push OFFSET DGROUP:$SG562
|
||||
*** 0002a5 e8 00 00 call _printf
|
||||
*** 0002a8 83 c4 06 add sp,6
|
||||
;|*** bRet = TRUE;
|
||||
; Line 273
|
||||
*** 0002ab c7 46 f6 01 00 mov WORD PTR [bp-10],1 ;bRet
|
||||
;|***
|
||||
;|*** peo_exit:
|
||||
; Line 275
|
||||
$peo_exit535:
|
||||
;|*** return bRet;
|
||||
; Line 276
|
||||
*** 0002b0 8b 46 f6 mov ax,WORD PTR [bp-10] ;bRet
|
||||
;|*** } // ParseEthernetOptions
|
||||
; Line 277
|
||||
*** 0002b3 5e pop si
|
||||
*** 0002b4 5f pop di
|
||||
*** 0002b5 c9 leave
|
||||
*** 0002b6 c3 ret
|
||||
*** 0002b7 90 nop
|
||||
|
||||
_ParseEthernetOptions ENDP
|
||||
_TEXT ENDS
|
||||
END
|
||||
BIN
DOS/LOADCEPC/ethmain.obj
Normal file
BIN
DOS/LOADCEPC/ethmain.obj
Normal file
Binary file not shown.
BIN
DOS/LOADCEPC/ethmain.sbr
Normal file
BIN
DOS/LOADCEPC/ethmain.sbr
Normal file
Binary file not shown.
56
DOS/LOADCEPC/halether.h
Normal file
56
DOS/LOADCEPC/halether.h
Normal file
@ -0,0 +1,56 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
/*++
|
||||
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|
||||
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
||||
PARTICULAR PURPOSE.
|
||||
|
||||
Module Name:
|
||||
|
||||
Abstract:
|
||||
|
||||
Functions:
|
||||
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _ETHERNET_H
|
||||
#define _ETHERNET_H 1
|
||||
|
||||
|
||||
/*
|
||||
* Addressing info struct. We don't ARP for unknown ethernet addresses, so
|
||||
* even the ethernet address must be configured.
|
||||
*/
|
||||
typedef struct _EDBG_ADDR {
|
||||
DWORD dwIP;
|
||||
USHORT wMAC[3];
|
||||
USHORT wPort;
|
||||
|
||||
} EDBG_ADDR;
|
||||
|
||||
|
||||
#define EDBG_SYSINTR_NOINTR 0xFFFFFFFF
|
||||
|
||||
// The following defs can be used for platforms which support multiple adapter types.
|
||||
// Identifiers are provided here for drivers which are built in common\oak\drivers\ethdbg.
|
||||
// Any platform specific adapter types can be identified based off of EDBG_ADAPTER_OEM.
|
||||
#define EDBG_ADAPTER_SMC9000 0
|
||||
#define EDBG_ADAPTER_NE2000 1
|
||||
|
||||
#define EDBG_ADAPTER_OEM 16
|
||||
|
||||
|
||||
#endif // _ETHERNET_H
|
||||
30
DOS/LOADCEPC/kernel.h
Normal file
30
DOS/LOADCEPC/kernel.h
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
#include "windows.h"
|
||||
#include <string.h>
|
||||
|
||||
#define LOCKFLAG_WRITE 1
|
||||
|
||||
#define int long
|
||||
|
||||
#define ZONE_DEBUG 1
|
||||
|
||||
#define DEBUGMSG(a, b) printf b
|
||||
|
||||
int OEMParallelPortGetByte(void);
|
||||
VOID OEMParallelPortSendByte(BYTE chData);
|
||||
|
||||
#define LockPages(a, b, c, d)
|
||||
#define UnlockPages(a, b)
|
||||
|
||||
#define KUnicodeToAscii(a, b, c) strncpy(a, b, c)
|
||||
33
DOS/LOADCEPC/loadcepc.h
Normal file
33
DOS/LOADCEPC/loadcepc.h
Normal file
@ -0,0 +1,33 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#define _MOREINFO 1
|
||||
|
||||
typedef int BOOL;
|
||||
|
||||
typedef unsigned char BYTE, *LPBYTE, UCHAR, *PUCHAR;
|
||||
typedef unsigned int USHORT, *PUSHORT;
|
||||
typedef unsigned long ULONG, *PULONG;
|
||||
|
||||
typedef unsigned short WORD, *PWORD;
|
||||
typedef unsigned long DWORD, *PDWORD;
|
||||
|
||||
typedef signed char INT8;
|
||||
typedef unsigned char UINT8;
|
||||
typedef signed short INT16;
|
||||
typedef unsigned short UINT16;
|
||||
typedef signed int INT32;
|
||||
typedef unsigned int UINT32;
|
||||
|
||||
151
DOS/LOADCEPC/loadcepc.mak
Normal file
151
DOS/LOADCEPC/loadcepc.mak
Normal file
@ -0,0 +1,151 @@
|
||||
!if 0
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
!endif
|
||||
!if 0
|
||||
Use of this sample source code is subject to the terms of the Microsoft
|
||||
license agreement under which you licensed this sample source code. If
|
||||
you did not accept the terms of the license agreement, you are not
|
||||
authorized to use this sample source code. For the terms of the license,
|
||||
please see the license agreement between you and Microsoft or, if applicable,
|
||||
see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
!endif
|
||||
|
||||
#
|
||||
#
|
||||
# Microsoft Visual C++ generated build script - Do not modify
|
||||
|
||||
PROJ = LOADCEPC
|
||||
DEBUG = 0
|
||||
PROGTYPE = 6
|
||||
CALLER =
|
||||
ARGS =
|
||||
DLLS =
|
||||
D_RCDEFINES = -d_DEBUG
|
||||
R_RCDEFINES = -dNDEBUG
|
||||
ORIGIN = MSVC
|
||||
ORIGIN_VER = 1.00
|
||||
USEMFC = 0
|
||||
CC = cl
|
||||
CPP = cl
|
||||
CXX = cl
|
||||
CCREATEPCHFLAG =
|
||||
CPPCREATEPCHFLAG =
|
||||
CUSEPCHFLAG =
|
||||
CPPUSEPCHFLAG =
|
||||
FIRSTC = MAIN.C
|
||||
FIRSTCPP =
|
||||
RC = rc
|
||||
CFLAGS_D_DEXE = /I . /nologo /G2 /W4 /Z7 /Od /D "_DEBUG" /D "_DOS" /D "CEDDK_USEDDKMACRO" /Fc /FR
|
||||
CFLAGS_R_DEXE = /I . /nologo /Gs /G2 /W4 /Z7 /Ox /D "NDEBUG" /D "_DOS" /D "CEDDK_USEDDKMACRO" /Fc /FR
|
||||
LFLAGS_D_DEXE = /NOLOGO /NOI /STACK:5120 /ONERROR:NOEXE /CO /MAP /LINE
|
||||
LFLAGS_R_DEXE = /NOLOGO /NOI /STACK:5120 /ONERROR:NOEXE /CO /MAP /LINE
|
||||
LIBS_D_DEXE = slibce oldnames
|
||||
LIBS_R_DEXE = slibce oldnames
|
||||
RCFLAGS = /nologo
|
||||
RESFLAGS = /nologo
|
||||
RUNFLAGS =
|
||||
LIBS_EXT =
|
||||
!if "$(DEBUG)" == "1"
|
||||
CFLAGS = $(CFLAGS_D_DEXE)
|
||||
LFLAGS = $(LFLAGS_D_DEXE)
|
||||
LIBS = $(LIBS_D_DEXE)
|
||||
MAPFILE = nul
|
||||
RCDEFINES = $(D_RCDEFINES)
|
||||
!else
|
||||
CFLAGS = $(CFLAGS_R_DEXE)
|
||||
LFLAGS = $(LFLAGS_R_DEXE)
|
||||
LIBS = $(LIBS_R_DEXE)
|
||||
MAPFILE = nul
|
||||
RCDEFINES = $(R_RCDEFINES)
|
||||
!endif
|
||||
CFLAGS = $(CFLAGS) /I ..\..\INC
|
||||
!if [if exist MSVC.BND del MSVC.BND]
|
||||
!endif
|
||||
SBRS = MAIN.SBR \
|
||||
XMSAPI.SBR \
|
||||
VIDEO.SBR \
|
||||
PPFS.SBR
|
||||
|
||||
|
||||
TRANSFER_DEP =
|
||||
|
||||
MAIN_DEP = loadcepc.h \
|
||||
xmsapi.h
|
||||
|
||||
XMSAPI_DEP = xmsapi.h
|
||||
|
||||
|
||||
VIDEO_DEP = loadcepc.h \
|
||||
video.h
|
||||
|
||||
MDPPFS_DEP = wdm.h \
|
||||
pc.h
|
||||
|
||||
|
||||
PPFS_DEP = kernel.h
|
||||
|
||||
|
||||
PPFSTOOL_DEP = ppfs.h
|
||||
|
||||
ETHMAIN_DEP = loadcepc.h \
|
||||
smchw.h
|
||||
|
||||
all: $(PROJ).EXE $(PROJ).BSC
|
||||
|
||||
clean:
|
||||
del /f /q $(PROJ).exe *.obj *.cod *.sbr
|
||||
|
||||
MAIN.OBJ: MAIN.C $(MAIN_DEP)
|
||||
$(CC) $(CFLAGS) $(CCREATEPCHFLAG) /c MAIN.C
|
||||
|
||||
XMSAPI.OBJ: XMSAPI.C $(XMSAPI_DEP)
|
||||
$(CC) $(CFLAGS) $(CUSEPCHFLAG) /c XMSAPI.C
|
||||
|
||||
VIDEO.OBJ: VIDEO.C $(VIDEO_DEP)
|
||||
$(CC) $(CFLAGS) $(CUSEPCHFLAG) /c VIDEO.C
|
||||
|
||||
MDPPFS.OBJ: MDPPFS.C $(MDPPFS_DEP)
|
||||
$(CC) $(CFLAGS) $(CCREATEPCHFLAG) /c MDPPFS.C
|
||||
|
||||
PPFS.OBJ: PPFS.C $(PPFS_DEP)
|
||||
$(CC) $(CFLAGS) $(CUSEPCHFLAG) /c PPFS.C
|
||||
|
||||
DEBUG.OBJ: DEBUG.C $(PPFS_DEP)
|
||||
$(CC) $(CFLAGS) $(CUSEPCHFLAG) /c DEBUG.C
|
||||
|
||||
PPFSTOOL.OBJ: PPFSTOOL.C $(PPFSTOOL_DEP)
|
||||
$(CC) $(CFLAGS) $(CUSEPCHFLAG) /c PPFSTOOL.C
|
||||
|
||||
ETHMAIN.OBJ: ETHMAIN.C $(ETHMAIN_DEP)
|
||||
$(CC) $(CFLAGS) $(CUSEPCHFLAG) /c ETHMAIN.C
|
||||
|
||||
TRANSFER.OBJ: TRANSFER.ASM
|
||||
ml /c TRANSFER.ASM
|
||||
|
||||
$(PROJ).EXE:: MAIN.OBJ XMSAPI.OBJ VIDEO.OBJ MDPPFS.OBJ DEBUG.OBJ PPFS.OBJ PPFSTOOL.OBJ ETHMAIN.OBJ TRANSFER.OBJ $(DEFFILE)
|
||||
echo >NUL @<<$(PROJ).CRF
|
||||
MAIN.OBJ +
|
||||
XMSAPI.OBJ +
|
||||
VIDEO.OBJ +
|
||||
MDPPFS.OBJ +
|
||||
PPFS.OBJ +
|
||||
PPFSTOOL.OBJ +
|
||||
ETHMAIN.OBJ +
|
||||
DEBUG.OBJ +
|
||||
TRANSFER.OBJ
|
||||
$(PROJ).EXE
|
||||
$(MAPFILE)
|
||||
$(LIBS)
|
||||
$(DEFFILE);
|
||||
<<
|
||||
link $(LFLAGS) @$(PROJ).CRF
|
||||
|
||||
run: $(PROJ).EXE
|
||||
$(PROJ) $(RUNFLAGS)
|
||||
|
||||
|
||||
$(PROJ).BSc: $(SBRS)
|
||||
bscmake @<<
|
||||
/o$@ $(SBRS)
|
||||
<<
|
||||
23
DOS/LOADCEPC/loadnkpc.h
Normal file
23
DOS/LOADCEPC/loadnkpc.h
Normal file
@ -0,0 +1,23 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
typedef int BOOL;
|
||||
|
||||
typedef unsigned char UCHAR, *PUCHAR;
|
||||
typedef unsigned int USHORT, *PUSHORT;
|
||||
typedef unsigned long ULONG, *PULONG;
|
||||
|
||||
typedef unsigned short WORD, *PWORD;
|
||||
typedef unsigned long DWORD, *PDWORD;
|
||||
1537
DOS/LOADCEPC/main.c
Normal file
1537
DOS/LOADCEPC/main.c
Normal file
File diff suppressed because it is too large
Load Diff
4574
DOS/LOADCEPC/main.cod
Normal file
4574
DOS/LOADCEPC/main.cod
Normal file
File diff suppressed because it is too large
Load Diff
BIN
DOS/LOADCEPC/main.obj
Normal file
BIN
DOS/LOADCEPC/main.obj
Normal file
Binary file not shown.
500
DOS/LOADCEPC/mdppfs.c
Normal file
500
DOS/LOADCEPC/mdppfs.c
Normal file
@ -0,0 +1,500 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
/*++
|
||||
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|
||||
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
||||
PARTICULAR PURPOSE.
|
||||
|
||||
Module Name:
|
||||
|
||||
mdppfs.c
|
||||
|
||||
Abstract:
|
||||
|
||||
This file implements the NK kernel ppfs client side interface
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
#include "windows.h"
|
||||
#include "wdm.h"
|
||||
#include "pc.h"
|
||||
|
||||
#define PAR_PORT_BASE 0x0378
|
||||
#define PAR_PORT_DATA 0
|
||||
#define PAR_PORT_STAT 1
|
||||
#define PAR_PORT_CTRL 2
|
||||
|
||||
#define PAR_STAT_NBUSY 0x80
|
||||
#define PAR_STAT_NACK 0x40
|
||||
#define PAR_STAT_PE 0x20
|
||||
#define PAR_STAT_SLCT 0x10
|
||||
#define PAR_STAT_NERR 0x08 // This isn't connected
|
||||
|
||||
#define PAR_CTRL_READ 0x20
|
||||
#define PAR_CTRL_IRQE 0x10
|
||||
#define PAR_CTRL_SLCT_IN 0x08
|
||||
#define PAR_CTRL_NINIT 0x04
|
||||
#define PAR_CTRL_AUTOFEED 0x02
|
||||
#define PAR_CTRL_STROBE 0x01
|
||||
|
||||
#define STATUS_IS_DISCONNECTED(a) \
|
||||
((((a) & (PAR_STAT_PE | PAR_STAT_SLCT)) != PAR_STAT_SLCT) || \
|
||||
(((a) & (PAR_STAT_NBUSY | PAR_STAT_NACK)) == PAR_STAT_NACK))
|
||||
|
||||
//#define STATUS_IS_DISCONNECTED(a) (!((a) & PAR_STAT_SLCT))
|
||||
|
||||
#if DEBUG
|
||||
#define LOG_ENTRY_TYPE_MASK 0xFF00
|
||||
#define LOG_ENTRY_DATA_MASK 0x00FF
|
||||
|
||||
#define LOG_ENTRY_READ ((USHORT)('R' << 8))
|
||||
#define LOG_ENTRY_WRITE ((USHORT)('W' << 8))
|
||||
#define LOG_ENTRY_CONTROL ((USHORT)('C' << 8))
|
||||
#define LOG_ENTRY_STATUS ((USHORT)('S' << 8))
|
||||
#define LOG_ENTRY_DATA ((USHORT)('D' << 8))
|
||||
#define LOG_ENTRY_EXIT ((USHORT)('E' << 8))
|
||||
#define LOG_ENTRY_EVENT ((USHORT)('V' << 8))
|
||||
|
||||
#define LOG_EVENT_SKIP_RECEIVE ((USHORT)0)
|
||||
#define LOG_EVENT_BAD_STATUS ((USHORT)1)
|
||||
#define LOG_EVENT_BAD_DISCONNECT ((USHORT)2)
|
||||
|
||||
#define NUMBER_LOG_EVENTS 3
|
||||
|
||||
TCHAR *EventDescriptions[NUMBER_LOG_EVENTS] =
|
||||
{
|
||||
TEXT("# Skipped Receives"),
|
||||
TEXT("# Bad Status"),
|
||||
TEXT("# Bad Disconnect"),
|
||||
};
|
||||
|
||||
DWORD dwEventCounters[NUMBER_LOG_EVENTS];
|
||||
|
||||
VOID LogEntry(USHORT usEntry);
|
||||
VOID DumpLog(VOID);
|
||||
VOID DumpCounters(VOID);
|
||||
|
||||
#define LOG_ENTRY(a) LogEntry(a)
|
||||
#define DUMP_LOG() DumpLog()
|
||||
#else
|
||||
#define LOG_ENTRY(a)
|
||||
#define DUMP_LOG()
|
||||
#endif
|
||||
|
||||
extern volatile DWORD *PtrCurMSec; /* current millisecond counter */
|
||||
|
||||
#define IoPortBase ((PUCHAR)PAR_PORT_BASE)
|
||||
|
||||
BOOL NoPPFS;
|
||||
BOOL bLastOpWasWrite;
|
||||
|
||||
BOOL __inline VerifyDisconnect(VOID)
|
||||
{
|
||||
int i;
|
||||
USHORT usStatus;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT);
|
||||
|
||||
LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus));
|
||||
|
||||
if (!STATUS_IS_DISCONNECTED(usStatus))
|
||||
{
|
||||
LOG_ENTRY(LOG_ENTRY_EVENT | LOG_EVENT_BAD_STATUS);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
BOOL WaitForStatus(USHORT usMask, USHORT usValue)
|
||||
{
|
||||
USHORT usStatus;
|
||||
DWORD msecStart = *PtrCurMSec;
|
||||
int tries = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if (*PtrCurMSec - msecStart >= 200)
|
||||
{
|
||||
if (++tries > 5)
|
||||
{
|
||||
NoPPFS = TRUE;
|
||||
|
||||
printf("\r\nWaitForStatus: time out (1), status = %2.2X\r\n",
|
||||
usStatus);
|
||||
|
||||
LOG_ENTRY(LOG_ENTRY_EXIT | 2);
|
||||
|
||||
DUMP_LOG();
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
msecStart = *PtrCurMSec;
|
||||
}
|
||||
|
||||
usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT);
|
||||
|
||||
LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus));
|
||||
|
||||
//
|
||||
// Use SELECTIN to identify the existence of ppsh
|
||||
//
|
||||
if (STATUS_IS_DISCONNECTED(usStatus))
|
||||
{
|
||||
if (VerifyDisconnect())
|
||||
{
|
||||
printf("\r\nWaitForStatus: PPSH disconnected\r\n");
|
||||
|
||||
NoPPFS = TRUE;
|
||||
|
||||
LOG_ENTRY(LOG_ENTRY_EXIT | 1);
|
||||
|
||||
DUMP_LOG();
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT);
|
||||
LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus));
|
||||
}
|
||||
}
|
||||
|
||||
if ((usStatus & usMask) == usValue)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
usStatus = READ_PORT_UCHAR(IoPortBase + PAR_PORT_STAT);
|
||||
|
||||
LOG_ENTRY((USHORT)(LOG_ENTRY_STATUS | usStatus));
|
||||
|
||||
if ((usStatus & usMask) != usValue)
|
||||
{
|
||||
LOG_ENTRY(LOG_ENTRY_EVENT | LOG_EVENT_BAD_STATUS);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while ((usStatus & usMask) != usValue);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int OEMParallelPortInit(void)
|
||||
{
|
||||
LOG_ENTRY(LOG_ENTRY_CONTROL | PAR_CTRL_AUTOFEED | PAR_CTRL_STROBE);
|
||||
|
||||
WRITE_PORT_UCHAR(
|
||||
IoPortBase + PAR_PORT_CTRL, PAR_CTRL_AUTOFEED | PAR_CTRL_STROBE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int OEMParallelPortGetByte(void)
|
||||
{
|
||||
BYTE value;
|
||||
|
||||
if (NoPPFS)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
Retry:
|
||||
LOG_ENTRY(LOG_ENTRY_READ);
|
||||
|
||||
LOG_ENTRY(LOG_ENTRY_CONTROL | PAR_CTRL_READ | PAR_CTRL_STROBE);
|
||||
|
||||
WRITE_PORT_UCHAR(IoPortBase + PAR_PORT_CTRL, PAR_CTRL_READ | PAR_CTRL_STROBE);
|
||||
|
||||
if (!WaitForStatus(PAR_STAT_NACK, PAR_STAT_NACK))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
value = READ_PORT_UCHAR(IoPortBase + PAR_PORT_DATA);
|
||||
|
||||
LOG_ENTRY((USHORT)(LOG_ENTRY_DATA | value));
|
||||
|
||||
LOG_ENTRY(LOG_ENTRY_CONTROL | PAR_CTRL_AUTOFEED | PAR_CTRL_STROBE);
|
||||
|
||||
WRITE_PORT_UCHAR(IoPortBase + PAR_PORT_CTRL, PAR_CTRL_AUTOFEED | PAR_CTRL_STROBE);
|
||||
|
||||
if (!WaitForStatus(PAR_STAT_NACK, 0))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
LOG_ENTRY(LOG_ENTRY_EXIT | 0);
|
||||
|
||||
if (bLastOpWasWrite && value == 0x1A)
|
||||
{
|
||||
//
|
||||
// The problem is that periodically the first character we
|
||||
// receive after a write is the last byte sent of the previous write.
|
||||
//
|
||||
// For now we will ignore it
|
||||
//
|
||||
LOG_ENTRY(LOG_ENTRY_EVENT | LOG_EVENT_SKIP_RECEIVE);
|
||||
bLastOpWasWrite = FALSE;
|
||||
goto Retry;
|
||||
}
|
||||
|
||||
bLastOpWasWrite = FALSE;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
VOID OEMParallelPortSendByte(BYTE chData)
|
||||
{
|
||||
if (NoPPFS)
|
||||
return;
|
||||
|
||||
LOG_ENTRY(LOG_ENTRY_WRITE);
|
||||
|
||||
if (!WaitForStatus(PAR_STAT_NBUSY, 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_ENTRY((USHORT)(LOG_ENTRY_DATA | chData));
|
||||
|
||||
WRITE_PORT_UCHAR(IoPortBase + PAR_PORT_CTRL, PAR_CTRL_AUTOFEED | PAR_CTRL_STROBE);
|
||||
|
||||
WRITE_PORT_UCHAR(IoPortBase + PAR_PORT_DATA, chData);
|
||||
|
||||
LOG_ENTRY(LOG_ENTRY_CONTROL | PAR_CTRL_AUTOFEED);
|
||||
|
||||
WRITE_PORT_UCHAR(IoPortBase + PAR_PORT_CTRL, PAR_CTRL_AUTOFEED);
|
||||
|
||||
if (!WaitForStatus(PAR_STAT_NBUSY, PAR_STAT_NBUSY))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_ENTRY(LOG_ENTRY_CONTROL | PAR_CTRL_AUTOFEED | PAR_CTRL_STROBE);
|
||||
|
||||
WRITE_PORT_UCHAR(IoPortBase + PAR_PORT_CTRL, PAR_CTRL_AUTOFEED | PAR_CTRL_STROBE);
|
||||
|
||||
LOG_ENTRY(LOG_ENTRY_EXIT | 0);
|
||||
|
||||
bLastOpWasWrite = TRUE;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
#define LOG_SIZE 0x1000
|
||||
#define RW_STACK_SIZE 10
|
||||
|
||||
WCHAR wcHexDigits[16] =
|
||||
{
|
||||
TEXT('0'), TEXT('1'), TEXT('2'), TEXT('3'),
|
||||
TEXT('4'), TEXT('5'), TEXT('6'), TEXT('7'),
|
||||
TEXT('8'), TEXT('9'), TEXT('A'), TEXT('B'),
|
||||
TEXT('C'), TEXT('D'), TEXT('E'), TEXT('F')
|
||||
};
|
||||
|
||||
USHORT usLogBuffer[LOG_SIZE];
|
||||
int iLogHead = 0;
|
||||
int iLogTail = 0;
|
||||
|
||||
VOID
|
||||
LogEntry(USHORT usEntry)
|
||||
{
|
||||
static USHORT usLastEntry;
|
||||
USHORT usEntryType;
|
||||
USHORT usEntryData;
|
||||
|
||||
usEntryData = usEntry & LOG_ENTRY_DATA_MASK;
|
||||
usEntryType = usEntry & LOG_ENTRY_TYPE_MASK;
|
||||
|
||||
switch (usEntryType)
|
||||
{
|
||||
case LOG_ENTRY_STATUS:
|
||||
if (usLastEntry == usEntry)
|
||||
{
|
||||
//
|
||||
// Don't log duplicate status
|
||||
//
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case LOG_ENTRY_EVENT:
|
||||
if (usEntryData < NUMBER_LOG_EVENTS)
|
||||
{
|
||||
dwEventCounters[usEntryData]++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
usLastEntry = usEntry;
|
||||
|
||||
usLogBuffer[iLogTail++] = usEntry;
|
||||
iLogTail %= LOG_SIZE;
|
||||
|
||||
if (iLogTail == iLogHead)
|
||||
{
|
||||
iLogHead++;
|
||||
iLogHead %= LOG_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
DumpLog(VOID)
|
||||
{
|
||||
// R 00 W 4F
|
||||
TCHAR szPrintLine[100];
|
||||
int iLogCurrent;
|
||||
PTCHAR pCurrentColumn;
|
||||
int nDataItems;
|
||||
USHORT usCurrentOp, usLastOp;
|
||||
int iReadWriteStack[RW_STACK_SIZE];
|
||||
int i;
|
||||
|
||||
pCurrentColumn = szPrintLine;
|
||||
nDataItems = 0;
|
||||
|
||||
usLastOp = 0;
|
||||
|
||||
for (i = 0; i < RW_STACK_SIZE; i++)
|
||||
{
|
||||
iReadWriteStack[i] = iLogTail;
|
||||
}
|
||||
|
||||
for (iLogCurrent = iLogHead; iLogCurrent != iLogTail;
|
||||
iLogCurrent++, iLogCurrent %= LOG_SIZE)
|
||||
{
|
||||
usCurrentOp = usLogBuffer[iLogCurrent] & LOG_ENTRY_TYPE_MASK;
|
||||
switch (usCurrentOp)
|
||||
{
|
||||
case LOG_ENTRY_READ:
|
||||
case LOG_ENTRY_WRITE:
|
||||
if (usLastOp != usCurrentOp)
|
||||
{
|
||||
if (pCurrentColumn != szPrintLine)
|
||||
{
|
||||
memcpy(pCurrentColumn, TEXT("\r\n"), sizeof(TEXT("\r\n")));
|
||||
OutputDebugString(szPrintLine);
|
||||
pCurrentColumn = szPrintLine;
|
||||
}
|
||||
|
||||
*pCurrentColumn++ = (TCHAR)(usLogBuffer[iLogCurrent] >> 8);
|
||||
*pCurrentColumn++ = TEXT(' ');
|
||||
usLastOp = usCurrentOp;
|
||||
nDataItems = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < (RW_STACK_SIZE - 1); i++)
|
||||
{
|
||||
iReadWriteStack[i] = iReadWriteStack[i + 1];
|
||||
}
|
||||
|
||||
iReadWriteStack[RW_STACK_SIZE - 1] = iLogCurrent;
|
||||
break;
|
||||
|
||||
case LOG_ENTRY_EVENT:
|
||||
case LOG_ENTRY_DATA:
|
||||
if (nDataItems == 25)
|
||||
{
|
||||
memcpy(pCurrentColumn, TEXT("\r\n"), sizeof(TEXT("\r\n")));
|
||||
OutputDebugString(szPrintLine);
|
||||
pCurrentColumn = szPrintLine;
|
||||
*pCurrentColumn++ = TEXT(' ');
|
||||
*pCurrentColumn++ = TEXT(' ');
|
||||
nDataItems = 0;
|
||||
}
|
||||
*pCurrentColumn++ = wcHexDigits[(usLogBuffer[iLogCurrent] >> 4) & 0x0F];
|
||||
*pCurrentColumn++ = wcHexDigits[usLogBuffer[iLogCurrent] & 0x0F];
|
||||
*pCurrentColumn++ = usCurrentOp == LOG_ENTRY_DATA ? TEXT(' ') : TEXT('!');
|
||||
nDataItems++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pCurrentColumn != szPrintLine)
|
||||
{
|
||||
memcpy(pCurrentColumn, TEXT("\r\n"), sizeof(TEXT("\r\n")));
|
||||
OutputDebugString(szPrintLine);
|
||||
pCurrentColumn = szPrintLine;
|
||||
}
|
||||
|
||||
nDataItems = 0;
|
||||
|
||||
for (i = 0; i < RW_STACK_SIZE; i++)
|
||||
{
|
||||
if (iReadWriteStack[i] != iLogTail)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
iLogCurrent = (i < RW_STACK_SIZE) ? iReadWriteStack[i] : iLogTail;
|
||||
|
||||
for ( ; iLogCurrent != iLogTail; iLogCurrent++, iLogCurrent %= LOG_SIZE)
|
||||
{
|
||||
if (nDataItems == 16)
|
||||
{
|
||||
memcpy(pCurrentColumn, TEXT("\r\n"), sizeof(TEXT("\r\n")));
|
||||
OutputDebugString(szPrintLine);
|
||||
pCurrentColumn = szPrintLine;
|
||||
nDataItems = 0;
|
||||
}
|
||||
|
||||
*pCurrentColumn++ = (TCHAR)(usLogBuffer[iLogCurrent] >> 8);
|
||||
|
||||
*pCurrentColumn++ = TEXT(' ');
|
||||
|
||||
*pCurrentColumn++ = wcHexDigits[(usLogBuffer[iLogCurrent] >> 4) & 0x0F];
|
||||
|
||||
*pCurrentColumn++ = wcHexDigits[usLogBuffer[iLogCurrent] & 0x0F];
|
||||
|
||||
*pCurrentColumn++ = TEXT(' ');
|
||||
|
||||
nDataItems++;
|
||||
}
|
||||
|
||||
if (pCurrentColumn != szPrintLine)
|
||||
{
|
||||
memcpy(pCurrentColumn, TEXT("\r\n"), sizeof(TEXT("\r\n")));
|
||||
OutputDebugString(szPrintLine);
|
||||
pCurrentColumn = szPrintLine;
|
||||
}
|
||||
|
||||
DumpCounters();
|
||||
}
|
||||
|
||||
VOID
|
||||
DumpCounters(VOID)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUMBER_LOG_EVENTS; i++)
|
||||
{
|
||||
if (dwEventCounters[i] != 0)
|
||||
{
|
||||
NKDbgPrintfW(
|
||||
TEXT("%s = %d\r\n"), EventDescriptions[i], dwEventCounters[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
1138
DOS/LOADCEPC/mdppfs.cod
Normal file
1138
DOS/LOADCEPC/mdppfs.cod
Normal file
File diff suppressed because it is too large
Load Diff
BIN
DOS/LOADCEPC/mdppfs.obj
Normal file
BIN
DOS/LOADCEPC/mdppfs.obj
Normal file
Binary file not shown.
BIN
DOS/LOADCEPC/mdppfs.sbr
Normal file
BIN
DOS/LOADCEPC/mdppfs.sbr
Normal file
Binary file not shown.
12
DOS/LOADCEPC/pc.h
Normal file
12
DOS/LOADCEPC/pc.h
Normal file
@ -0,0 +1,12 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
471
DOS/LOADCEPC/ppfs.c
Normal file
471
DOS/LOADCEPC/ppfs.c
Normal file
@ -0,0 +1,471 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
/*++
|
||||
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|
||||
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
||||
PARTICULAR PURPOSE.
|
||||
|
||||
Module Name:
|
||||
ppfs.c
|
||||
|
||||
Abstract:
|
||||
This file implements the NK kernel ppfs client side interface
|
||||
|
||||
Notes:
|
||||
--*/
|
||||
|
||||
#include "kernel.h"
|
||||
|
||||
/* All strings must be <= 128 bytes including the null termination */
|
||||
|
||||
/* Message format: (assume little endians, lower address first>
|
||||
* -4 0 4 N-1 N N+4
|
||||
* AA5555AA<header><data><checksum>5AA50A1A
|
||||
*
|
||||
* Header format:
|
||||
* 0 2 4
|
||||
* <opcode><length>
|
||||
* lsb msb
|
||||
*
|
||||
* Length is 16 bit value. It includes all fields (== N)
|
||||
* Opcode is 16 bit value. Current values are:
|
||||
* 0x0000 - boot (AA5555AA00000500FA5AA50A1A)
|
||||
* 0x0001 - init (AA5555AA01000500F95AA50A1A)
|
||||
* 0x0002 - open
|
||||
* 0x0003 - close
|
||||
* 0x0004 - read
|
||||
* 0x0005 - write
|
||||
* 0x0006 - seek
|
||||
* 0x0007 - delete
|
||||
* 0x0008 - findfirst
|
||||
* 0x0009 - findnext
|
||||
* 0x000A - rRegGet
|
||||
* 0x000B - rRegOpen
|
||||
* 0x000C - rRegClose
|
||||
* 0x000D - rRegEnum
|
||||
*
|
||||
*
|
||||
* Reply to a message will have the same opcode. Bit15 is set to
|
||||
* indicate transmission failure.
|
||||
*
|
||||
* Data is stream of bytes
|
||||
*
|
||||
* Checksum is ~(sum of preceding N-1 bytes)
|
||||
*
|
||||
* Length of data is <length> - 5
|
||||
*
|
||||
*/
|
||||
|
||||
CRITICAL_SECTION ppfscs;
|
||||
extern int NoPPFS; // parallel port not present flag
|
||||
|
||||
int read_value(int *chksum) {
|
||||
int loop;
|
||||
int result;
|
||||
BYTE ch;
|
||||
for (loop = 0; loop < sizeof(int); loop++ ) {
|
||||
ch = (BYTE)OEMParallelPortGetByte();
|
||||
*chksum += ch;
|
||||
((LPBYTE)&result)[loop] = ch;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void write_value(int val, int *chksum) {
|
||||
int loop;
|
||||
BYTE ch;
|
||||
for (loop = 0; loop < 4; loop++) {
|
||||
ch = ((LPBYTE)&val)[loop];
|
||||
*chksum += ch;
|
||||
OEMParallelPortSendByte(ch);
|
||||
}
|
||||
}
|
||||
|
||||
int read_header(int *chksum) {
|
||||
if (read_value(chksum) != 0xaa5555aa)
|
||||
return -1;
|
||||
*chksum = 0;
|
||||
return read_value(chksum);
|
||||
}
|
||||
|
||||
void write_header(int cmd, int *chksum) {
|
||||
write_value(0xaa5555aa,chksum);
|
||||
*chksum = 0;
|
||||
write_value(cmd,chksum);
|
||||
}
|
||||
|
||||
void read_data(LPBYTE buf, int cnt, int *chksum) {
|
||||
BYTE ch;
|
||||
while (cnt--) {
|
||||
ch = (BYTE)OEMParallelPortGetByte();
|
||||
*chksum += ch;
|
||||
*buf++ = ch;
|
||||
}
|
||||
}
|
||||
|
||||
void write_data(LPBYTE buf, int cnt, int *chksum) {
|
||||
while (cnt--) {
|
||||
*chksum += *buf;
|
||||
OEMParallelPortSendByte(*buf++);
|
||||
}
|
||||
}
|
||||
|
||||
/* returns TRUE if success, FALSE if failure */
|
||||
BOOL read_end(int checksum) {
|
||||
BYTE b;
|
||||
int tmp;
|
||||
b = (BYTE)OEMParallelPortGetByte();
|
||||
if (((checksum & 0xff) != b) ||
|
||||
(read_value(&tmp) != 0x1a0aa55a))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void write_end(int checksum) {
|
||||
int tmp;
|
||||
BYTE ch = (BYTE)((checksum & 0xff) ^ 0xff);
|
||||
OEMParallelPortSendByte(ch);
|
||||
write_value(0x1a0aa55a,&tmp); /* Write out end of message signature */
|
||||
}
|
||||
|
||||
int rlseek(int fd, int off, int mode) {
|
||||
int chksum, result;
|
||||
|
||||
EnterCriticalSection(&ppfscs);
|
||||
if (NoPPFS)
|
||||
{
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return -1;
|
||||
}
|
||||
write_header(0x00110006,&chksum); /* opcode = 0x0006, length = 17 */
|
||||
write_value(fd,&chksum);
|
||||
write_value(off,&chksum);
|
||||
write_value(mode,&chksum);
|
||||
write_end(chksum);
|
||||
if (read_header(&chksum) != 0x00090006) { /* opcode = 0x0006, length = 9 */
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return -1;
|
||||
}
|
||||
result = read_value(&chksum);
|
||||
if (!read_end(chksum)) {
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return -1;
|
||||
}
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return result;
|
||||
}
|
||||
|
||||
int rwriteshort(int fd, char *buf, int cnt) {
|
||||
int chksum, result;
|
||||
|
||||
write_header(0x000d0005+(cnt<<16), &chksum); /* opcode = 0x0005, length = 13 + cnt */
|
||||
write_value(fd,&chksum);
|
||||
write_value(cnt,&chksum);
|
||||
write_data(buf,cnt,&chksum);
|
||||
write_end(chksum);
|
||||
if (read_header(&chksum) != 0x00090005) /* opcode = 0x0005, length = 9 */
|
||||
return -1;
|
||||
result = read_value(&chksum);
|
||||
if (!read_end(chksum))
|
||||
return -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
int rwrite(int fd, char *buf, int cnt) {
|
||||
int csize, fullsize;
|
||||
int result, result2;
|
||||
char *buf2 = buf;
|
||||
if (NoPPFS)
|
||||
return -1;
|
||||
fullsize = cnt;
|
||||
LockPages(buf,fullsize,0,0);
|
||||
EnterCriticalSection(&ppfscs);
|
||||
result2 = 0;
|
||||
while (cnt) {
|
||||
csize = ( cnt > 32*1024L ? 32*1024L : cnt);
|
||||
if ((result = rwriteshort(fd,buf2,csize)) == -1) {
|
||||
result2 = -1;
|
||||
break;
|
||||
}
|
||||
result2 += result;
|
||||
cnt -= csize;
|
||||
buf2 += csize;
|
||||
}
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
UnlockPages(buf,fullsize);
|
||||
return result2;
|
||||
}
|
||||
|
||||
int rreadshort(int fd, char *buf, int cnt) {
|
||||
int chksum, result, size;
|
||||
write_header(0x000d0004, &chksum); /* opcode = 0x0004, length = 13 */
|
||||
write_value(fd, &chksum);
|
||||
write_value(cnt,&chksum);
|
||||
write_end(chksum);
|
||||
result = read_header(&chksum);
|
||||
if ((result & 0xffff) != 0x0004)
|
||||
return -1;
|
||||
size = ((result >> 16) & 0xffff) - 9; /* subtract header & chksum */
|
||||
result = read_value(&chksum);
|
||||
read_data(buf,size,&chksum);
|
||||
if (!read_end(chksum))
|
||||
return -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
int rread(int fd, char *buf, int cnt) {
|
||||
int csize, fullsize;
|
||||
int result, result2;
|
||||
char *buf2 = buf;
|
||||
if (NoPPFS)
|
||||
return -1;
|
||||
fullsize = cnt;
|
||||
LockPages(buf,fullsize,0,LOCKFLAG_WRITE);
|
||||
EnterCriticalSection(&ppfscs);
|
||||
result2 = 0;
|
||||
while (cnt) {
|
||||
csize = ( cnt > 32*1024L ? 32*1024L : cnt);
|
||||
if ((result = rreadshort(fd,buf2,csize)) == -1) {
|
||||
result2 = -1;
|
||||
break;
|
||||
}
|
||||
result2 += result;
|
||||
cnt -= csize;
|
||||
buf2 += csize;
|
||||
}
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
UnlockPages(buf,fullsize);
|
||||
return result2;
|
||||
}
|
||||
|
||||
int rclose(int fd) {
|
||||
int chksum, result;
|
||||
|
||||
EnterCriticalSection(&ppfscs);
|
||||
if (NoPPFS) {
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return -1;
|
||||
}
|
||||
write_header(0x00090003, &chksum); /* opcode = 0x0003, length = 9 */
|
||||
write_value(fd,&chksum);
|
||||
write_end(chksum);
|
||||
if (read_header(&chksum) != 0x00090003) {
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return -1;
|
||||
}
|
||||
result = read_value(&chksum);
|
||||
if (!read_end(chksum)) {
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return -1;
|
||||
}
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return result;
|
||||
}
|
||||
|
||||
#define MAX_FILENAME_LEN 256
|
||||
|
||||
void SC_PPSHRestart(void) {
|
||||
NoPPFS = 0;
|
||||
}
|
||||
|
||||
int ropen(WCHAR *name, int mode) {
|
||||
int chksum, result, len;
|
||||
char fname[MAX_FILENAME_LEN];
|
||||
len = strlenW(name)+1;
|
||||
KUnicodeToAscii(fname,name,MAX_FILENAME_LEN);
|
||||
if (NoPPFS)
|
||||
return -1;
|
||||
EnterCriticalSection(&ppfscs);
|
||||
write_header(0x00090002 + (len<<16), &chksum); /* opcode = 0x0002, length = 9 + strlen + 1 */
|
||||
write_value(mode,&chksum);
|
||||
write_data(fname,len,&chksum);
|
||||
write_end(chksum);
|
||||
if (read_header(&chksum) != 0x00090002) {
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return -1;
|
||||
}
|
||||
result = read_value(&chksum);
|
||||
if (!read_end(chksum)) {
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return -1;
|
||||
}
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return result;
|
||||
}
|
||||
|
||||
int rfindfirst(DWORD hFind, WCHAR *pattern, struct _finddata_t *fd) {
|
||||
int chksum, result, len;
|
||||
char fname[MAX_FILENAME_LEN];
|
||||
|
||||
if (NoPPFS)
|
||||
return -1;
|
||||
if (pattern != NULL) {
|
||||
len = strlenW(pattern)+1;
|
||||
KUnicodeToAscii(fname,pattern,MAX_FILENAME_LEN);
|
||||
} else {
|
||||
len = 0;
|
||||
}
|
||||
EnterCriticalSection(&ppfscs);
|
||||
write_header(0x00090008 + (len<<16), &chksum); /* opcode = 0x0002, length = 9 + strlen + 1 */
|
||||
write_value(hFind,&chksum);
|
||||
if (len != 0) {
|
||||
write_data(fname,len,&chksum);
|
||||
}
|
||||
write_end(chksum);
|
||||
result = read_header(&chksum);
|
||||
if ((result & 0xffff) != 0x0008)
|
||||
return -1;
|
||||
len = ((result >> 16) & 0xffff) - 9; /* subtract header & chksum */
|
||||
result = read_value(&chksum);
|
||||
if (len != 0) {
|
||||
read_data((LPBYTE)fd,len,&chksum);
|
||||
}
|
||||
if (!read_end(chksum)) {
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return -1;
|
||||
}
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return result;
|
||||
}
|
||||
|
||||
int rfindnext(DWORD hFind, struct _finddata_t *fd) {
|
||||
int chksum, result, len;
|
||||
|
||||
if (NoPPFS)
|
||||
return -1;
|
||||
EnterCriticalSection(&ppfscs);
|
||||
write_header(0x00090009, &chksum); /* opcode = 0x0009, length = 9 */
|
||||
write_value(hFind,&chksum);
|
||||
write_end(chksum);
|
||||
result = read_header(&chksum);
|
||||
if ((result & 0xffff) != 0x0009)
|
||||
return -1;
|
||||
len = ((result >> 16) & 0xffff) - 9; /* subtract header & chksum */
|
||||
result = read_value(&chksum);
|
||||
if (len != 0) {
|
||||
read_data((LPBYTE)fd,len,&chksum);
|
||||
}
|
||||
if (!read_end(chksum)) {
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return -1;
|
||||
}
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Registration database access functions for kernel debug support initialization
|
||||
int rRegOpen(DWORD hKey, CHAR *szName, LPDWORD lphKey) {
|
||||
int chksum, len;
|
||||
if (NoPPFS)
|
||||
return -1;
|
||||
len = strlen(szName)+1;
|
||||
EnterCriticalSection(&ppfscs);
|
||||
write_header(0x0009000B + (len<<16), &chksum); /* opcode = 0x000B, length = 9 + strlen + 1 */
|
||||
write_value(hKey,&chksum);
|
||||
write_data(szName,len,&chksum);
|
||||
write_end(chksum);
|
||||
if (read_header(&chksum) != 0x0009000B) {
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return -1;
|
||||
}
|
||||
*lphKey = read_value(&chksum);
|
||||
if (!read_end(chksum)) {
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return -1;
|
||||
}
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rRegClose(DWORD hKey) {
|
||||
int chksum, result;
|
||||
if (NoPPFS)
|
||||
return -1;
|
||||
EnterCriticalSection(&ppfscs);
|
||||
write_header(0x0009000C, &chksum); /* opcode = 0x000C, length = 9 */
|
||||
write_value(hKey,&chksum);
|
||||
write_end(chksum);
|
||||
if (read_header(&chksum) != 0x0009000C) {
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return -1;
|
||||
}
|
||||
result = read_value(&chksum);
|
||||
if (!read_end(chksum)) {
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return -1;
|
||||
}
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return result;
|
||||
}
|
||||
|
||||
int rRegGet(DWORD hKey, CHAR *szName, LPDWORD lpdwType,
|
||||
LPBYTE lpbData, LPDWORD lpdwSize) {
|
||||
int chksum, result, len;
|
||||
if (NoPPFS)
|
||||
return -1;
|
||||
len = strlen(szName)+1;
|
||||
EnterCriticalSection(&ppfscs);
|
||||
write_header(0x0009000A + (len<<16), &chksum); /* opcode = 0x000A, length = 9 + strlen + 1 */
|
||||
write_value(hKey,&chksum);
|
||||
write_data(szName,len,&chksum);
|
||||
write_end(chksum);
|
||||
DEBUGMSG(ZONE_DEBUG,(TEXT("NKDBG: RegGet. hKey=%lu, Name=%a\r\n"), hKey, szName));
|
||||
result = read_header(&chksum);
|
||||
if ((result & 0xffff) != 0x000A)
|
||||
{
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return 0;
|
||||
}
|
||||
len = ((result >> 16) & 0xffff) - 9; /* subtract header & chksum */
|
||||
*lpdwType = read_value(&chksum);
|
||||
*lpdwSize = len;
|
||||
DEBUGMSG(ZONE_DEBUG,(TEXT("NKDBG: RegGet. Type=%lu, Size=%lu\r\n"), *lpdwType, *lpdwSize));
|
||||
read_data(lpbData,len,&chksum);
|
||||
if (!read_end(chksum)) {
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return 0;
|
||||
}
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int rRegEnum(DWORD hKey, DWORD dwIndex, LPBYTE lpbData, LPDWORD lpdwSize) {
|
||||
int chksum, result, len;
|
||||
if (NoPPFS)
|
||||
return -1;
|
||||
EnterCriticalSection(&ppfscs);
|
||||
write_header(0x000D000D, &chksum); /* opcode = 0x000A, length = 13 */
|
||||
write_value(hKey,&chksum);
|
||||
write_value(dwIndex,&chksum);
|
||||
write_end(chksum);
|
||||
DEBUGMSG(ZONE_DEBUG,(TEXT("NKDBG: RegEnum. hKey=%lu, Index=%u\r\n"), hKey, dwIndex));
|
||||
result = read_header(&chksum);
|
||||
if ((result & 0xffff) != 0x000D)
|
||||
{
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return -1;
|
||||
}
|
||||
len = ((result >> 16) & 0xffff) - 9; /* subtract header & chksum */
|
||||
result = read_value(&chksum);
|
||||
*lpdwSize = len;
|
||||
DEBUGMSG(ZONE_DEBUG,(TEXT("NKDBG: RegEnum. Return=%lu, Size=%lu\r\n"), result, *lpdwSize));
|
||||
read_data(lpbData,len,&chksum);
|
||||
if (!read_end(chksum)) {
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return -1;
|
||||
}
|
||||
LeaveCriticalSection(&ppfscs);
|
||||
return result;
|
||||
}
|
||||
|
||||
2143
DOS/LOADCEPC/ppfs.cod
Normal file
2143
DOS/LOADCEPC/ppfs.cod
Normal file
File diff suppressed because it is too large
Load Diff
26
DOS/LOADCEPC/ppfs.h
Normal file
26
DOS/LOADCEPC/ppfs.h
Normal file
@ -0,0 +1,26 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
long rlseek(long fd, long off, long mode);
|
||||
long rwrite(long fd, char *buf, long cnt);
|
||||
long rread(long fd, char *buf, long cnt);
|
||||
long rclose(long fd);
|
||||
long ropen(WCHAR *name, long mode);
|
||||
|
||||
long rRegOpen(DWORD hKey, CHAR *szName, LPDWORD lphKey);
|
||||
long rRegClose(DWORD hKey);
|
||||
long rRegGet(DWORD hKey, CHAR *szName, LPDWORD lpdwType,
|
||||
LPBYTE lpbData, LPDWORD lpdwSize);
|
||||
long rRegEnum(DWORD hKey, DWORD dwIndex, LPBYTE lpbData, LPDWORD lpdwSize);
|
||||
|
||||
long rfindfirst(DWORD hFind, WCHAR *pattern, struct _finddata_t *fd);
|
||||
long rfindnext(DWORD hFind, struct _finddata_t *fd);
|
||||
BIN
DOS/LOADCEPC/ppfs.obj
Normal file
BIN
DOS/LOADCEPC/ppfs.obj
Normal file
Binary file not shown.
556
DOS/LOADCEPC/ppfstool.c
Normal file
556
DOS/LOADCEPC/ppfstool.c
Normal file
@ -0,0 +1,556 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
/*++
|
||||
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|
||||
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
||||
PARTICULAR PURPOSE.
|
||||
|
||||
Module Name:
|
||||
|
||||
Abstract:
|
||||
|
||||
Functions:
|
||||
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#include "windows.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys\stat.h>
|
||||
#include <sys\utime.h>
|
||||
#include <ctype.h>
|
||||
#include <direct.h>
|
||||
#include <dos.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <time.h>
|
||||
#include "ppfs.h"
|
||||
|
||||
#if DEBUG
|
||||
VOID DumpCounters(VOID);
|
||||
#endif
|
||||
|
||||
DWORD CurMSec = 0;
|
||||
DWORD *PtrCurMSec = &CurMSec;
|
||||
|
||||
#define COPY_FLAG_UPDATE_EXISTING 0x0001
|
||||
#define COPY_FLAG_UPDATE_OR_ADD 0x0002
|
||||
|
||||
typedef unsigned long _fsize_t; /* Could be 64 bits for Win32 */
|
||||
|
||||
struct _finddata_t {
|
||||
unsigned long attrib;
|
||||
time_t time_create; /* -1 for FAT file systems */
|
||||
time_t time_access; /* -1 for FAT file systems */
|
||||
time_t time_write;
|
||||
_fsize_t size;
|
||||
char name[260];
|
||||
};
|
||||
|
||||
void
|
||||
usage2(char *pszProgramPath)
|
||||
{
|
||||
char *pszProgramName;
|
||||
|
||||
if ((pszProgramName = strrchr(pszProgramPath, '\\')) == NULL)
|
||||
{
|
||||
pszProgramName = pszProgramPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
pszProgramName++;
|
||||
}
|
||||
|
||||
printf(
|
||||
"%s: Parallel Port FileSystem Tool\n"
|
||||
"usage: %s -d[:]<pattern> -(g|r|u)[[:]<pattern> [<destination>]\n"
|
||||
"-d Display a directory of files matching <pattern>.\n\n"
|
||||
"-g Get files matching <pattern> and copy them to the\n"
|
||||
" optionally specified <destination>. Any existing file with\n"
|
||||
" the same name will be overwritten.\n\n"
|
||||
"-r Refresh files matching <pattern> which already exist in <destination>\n"
|
||||
" and have a timestamp newer than the one in <destination>.\n\n"
|
||||
"-u Update files matching <pattern> which don't already exist in\n"
|
||||
" <destination> or those that have a timestamp newer than those\n"
|
||||
" in <destination>.\n\n"
|
||||
"<pattern> Windows filename path with optional wildcard characters.\n\n"
|
||||
"<destination> If not specified then the current directory is the\n"
|
||||
" default.\n"
|
||||
" If specified and it doesn't exist and the last character is \\,\n"
|
||||
" then the directory is created. Otherwise <destination> is\n"
|
||||
" treated as the name of the file.\n"
|
||||
" It is an error for <pattern> to match multiple files\n"
|
||||
" when <destination> specifies a file.\n",
|
||||
pszProgramName, pszProgramName);
|
||||
}
|
||||
|
||||
VOID
|
||||
DisplayDirectory(char *pszPath)
|
||||
{
|
||||
DWORD hFind;
|
||||
struct _finddata_t fd;
|
||||
struct tm *ptmWrite;
|
||||
|
||||
hFind = rfindfirst(0, pszPath, &fd);
|
||||
|
||||
if (hFind == 0)
|
||||
{
|
||||
printf("%s: No files found\n", pszPath);
|
||||
}
|
||||
else if (hFind != -1)
|
||||
{
|
||||
do
|
||||
{
|
||||
ptmWrite = gmtime(&fd.time_write);
|
||||
|
||||
printf(
|
||||
"%c%c%c%c%c %2.2d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d %-8ld %s\n",
|
||||
fd.attrib & _A_RDONLY ? 'R' : ' ',
|
||||
fd.attrib & _A_HIDDEN ? 'H' : ' ',
|
||||
fd.attrib & _A_SYSTEM ? 'S' : ' ',
|
||||
fd.attrib & _A_SUBDIR ? 'D' : ' ',
|
||||
fd.attrib & _A_ARCH ? 'A' : ' ',
|
||||
ptmWrite->tm_mon + 1, ptmWrite->tm_mday, ptmWrite->tm_year,
|
||||
ptmWrite->tm_hour, ptmWrite->tm_min, ptmWrite->tm_sec,
|
||||
fd.size, fd.name);
|
||||
|
||||
hFind = rfindnext(hFind, &fd);
|
||||
}
|
||||
while (hFind != 0 && hFind != -1);
|
||||
}
|
||||
|
||||
if (hFind == -1)
|
||||
{
|
||||
printf("%s: Error processing directory\n", pszPath);
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
DrawPercent (DWORD CurValue, DWORD MaxValue)
|
||||
{
|
||||
DWORD dwPercent;
|
||||
static DWORD dwOldPercent = 10000;
|
||||
|
||||
if (CurValue == (DWORD)-1) {
|
||||
dwOldPercent = 10000;
|
||||
fprintf(stderr, "%s ", MaxValue);
|
||||
return;
|
||||
}
|
||||
|
||||
dwPercent = (CurValue*100)/MaxValue;
|
||||
if ((dwPercent / 2) != (dwOldPercent / 2))
|
||||
{
|
||||
fprintf(stderr, "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
|
||||
|
||||
for (dwOldPercent=0; dwOldPercent < (dwPercent/2); dwOldPercent++)
|
||||
{
|
||||
fprintf(stderr, "%c", 219);
|
||||
}
|
||||
|
||||
for (; dwOldPercent < 50; dwOldPercent++)
|
||||
{
|
||||
fprintf(stderr, "%c", 176);
|
||||
}
|
||||
|
||||
dwOldPercent = dwPercent;
|
||||
fprintf(stderr, " %2d%%", dwPercent);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "\b\b\b%2d%%", dwPercent);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
GetOneFile(
|
||||
char *pszSourceFile, char *pszDestinationFile,
|
||||
DWORD dwFileSize, time_t tmModify)
|
||||
{
|
||||
int hDestinationFile;
|
||||
DWORD hSourceFile;
|
||||
|
||||
int nReadCount;
|
||||
static char cReadBuffer[16384];
|
||||
|
||||
DWORD dwBytesWritten;
|
||||
|
||||
printf("%s --> %s\n", pszSourceFile, pszDestinationFile);
|
||||
|
||||
hDestinationFile = _open(
|
||||
pszDestinationFile, _O_WRONLY | _O_CREAT | _O_BINARY | _O_TRUNC,
|
||||
_S_IREAD | _S_IWRITE);
|
||||
|
||||
if (hDestinationFile == -1)
|
||||
{
|
||||
printf(
|
||||
"%s: Error opening file for write access, error = %d\n",
|
||||
pszDestinationFile, errno);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
hSourceFile = ropen(pszSourceFile, _O_RDONLY);
|
||||
|
||||
if (hSourceFile == -1)
|
||||
{
|
||||
_close(hDestinationFile);
|
||||
printf("%s: Error opening file for read access\n", pszSourceFile);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Initialize the percent thingie.
|
||||
DrawPercent((DWORD)-1, (DWORD)"");
|
||||
|
||||
dwBytesWritten = 0;
|
||||
|
||||
for ( ; ; )
|
||||
{
|
||||
nReadCount = (int)rread(hSourceFile, &cReadBuffer[0], sizeof(cReadBuffer));
|
||||
|
||||
if (nReadCount <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
_write(hDestinationFile, cReadBuffer, nReadCount);
|
||||
|
||||
dwBytesWritten += nReadCount;
|
||||
|
||||
DrawPercent(dwBytesWritten, dwFileSize);
|
||||
}
|
||||
|
||||
fprintf(stderr, "\r \r");
|
||||
|
||||
rclose(hSourceFile);
|
||||
|
||||
_close(hDestinationFile);
|
||||
|
||||
if (nReadCount == 0)
|
||||
{
|
||||
struct _utimbuf utDestination;
|
||||
time_t tmNow;
|
||||
|
||||
time(&tmNow);
|
||||
|
||||
utDestination.actime = tmNow;
|
||||
utDestination.modtime = tmModify != 0 ? tmModify : tmNow;
|
||||
_utime(pszDestinationFile, &utDestination);
|
||||
}
|
||||
else
|
||||
{
|
||||
_unlink(pszDestinationFile);
|
||||
}
|
||||
|
||||
return nReadCount == 0;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CheckDestination(char *pszDestination, char **ppszDirEnd)
|
||||
{
|
||||
struct _stat stDestination;
|
||||
BOOL bIsDir;
|
||||
|
||||
*ppszDirEnd = strrchr(pszDestination, '\\');
|
||||
|
||||
if (*ppszDirEnd == NULL && pszDestination[1] == ':')
|
||||
{
|
||||
*ppszDirEnd = &pszDestination[1];
|
||||
}
|
||||
|
||||
if (*ppszDirEnd == NULL)
|
||||
{
|
||||
*ppszDirEnd = pszDestination;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*ppszDirEnd)++;
|
||||
}
|
||||
|
||||
bIsDir = FALSE;
|
||||
|
||||
if (pszDestination[strlen(pszDestination)-1] == '\\')
|
||||
{
|
||||
pszDestination[strlen(pszDestination)-1] = '\0';
|
||||
bIsDir = TRUE;
|
||||
}
|
||||
|
||||
if (_stat(pszDestination, &stDestination) == 0)
|
||||
{
|
||||
if (stDestination.st_mode & _S_IFDIR)
|
||||
{
|
||||
bIsDir = TRUE;
|
||||
}
|
||||
}
|
||||
else if (bIsDir)
|
||||
{
|
||||
if (_mkdir(pszDestination) == -1)
|
||||
{
|
||||
printf("%s: Error creating directory, error = %d\n", pszDestination, errno);
|
||||
}
|
||||
}
|
||||
|
||||
if (bIsDir)
|
||||
{
|
||||
*ppszDirEnd = &pszDestination[strlen(pszDestination)];
|
||||
|
||||
if (*ppszDirEnd[-1] != '\\')
|
||||
{
|
||||
*(*ppszDirEnd)++ = '\\';
|
||||
}
|
||||
}
|
||||
|
||||
return bIsDir;
|
||||
}
|
||||
|
||||
VOID
|
||||
GetFile(char *pszSource, char *pszDestination, USHORT usCopyFlags)
|
||||
{
|
||||
DWORD hFind;
|
||||
|
||||
struct _stat stDestination;
|
||||
char szDestinationFile[_MAX_PATH];
|
||||
char *pDestinationDirEnd;
|
||||
|
||||
struct _finddata_t fdSource;
|
||||
char szSourceFile[_MAX_PATH];
|
||||
char *pSourceDirEnd;
|
||||
|
||||
BOOL bDestinationIsDir;
|
||||
|
||||
int nFilesCopied = 0;
|
||||
|
||||
BOOL bDestinationExists;
|
||||
BOOL bDoCopy;
|
||||
|
||||
pSourceDirEnd = strrchr(pszSource, '\\');
|
||||
|
||||
if (pSourceDirEnd == NULL && pszSource[1] == ':')
|
||||
{
|
||||
pSourceDirEnd = &pszSource[1];
|
||||
}
|
||||
|
||||
if (pSourceDirEnd != NULL)
|
||||
{
|
||||
int nDirLength = pSourceDirEnd - pszSource + 1;
|
||||
|
||||
memcpy(szSourceFile, pszSource, nDirLength);
|
||||
pSourceDirEnd = &szSourceFile[nDirLength];
|
||||
}
|
||||
else
|
||||
{
|
||||
pSourceDirEnd = szSourceFile;
|
||||
}
|
||||
|
||||
hFind = rfindfirst(0, pszSource, &fdSource);
|
||||
|
||||
if (hFind == 0 || hFind == -1)
|
||||
{
|
||||
printf("%s: File(s) not found\n", pszSource);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pszDestination != NULL)
|
||||
{
|
||||
strcpy(szDestinationFile, pszDestination);
|
||||
|
||||
bDestinationIsDir = CheckDestination(szDestinationFile, &pDestinationDirEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
pDestinationDirEnd = szDestinationFile;
|
||||
bDestinationIsDir = TRUE;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
strcpy(pSourceDirEnd, fdSource.name);
|
||||
|
||||
if (bDestinationIsDir)
|
||||
{
|
||||
strcpy(pDestinationDirEnd, fdSource.name);
|
||||
}
|
||||
|
||||
bDoCopy = TRUE;
|
||||
|
||||
if (usCopyFlags & (COPY_FLAG_UPDATE_EXISTING | COPY_FLAG_UPDATE_OR_ADD))
|
||||
{
|
||||
bDestinationExists = _stat(szDestinationFile, &stDestination) == 0;
|
||||
|
||||
if (bDestinationExists)
|
||||
{
|
||||
//
|
||||
// Clear lsb of both times so inaccurate FATFS doesn't cause
|
||||
// problems
|
||||
//
|
||||
stDestination.st_mtime &= ~1;
|
||||
fdSource.time_write &= ~1;
|
||||
|
||||
if (stDestination.st_mtime >= fdSource.time_write)
|
||||
{
|
||||
printf("%s: Up to date\n", szDestinationFile);
|
||||
bDoCopy = FALSE;
|
||||
}
|
||||
}
|
||||
else if (!(usCopyFlags & COPY_FLAG_UPDATE_OR_ADD))
|
||||
{
|
||||
printf("%s: Skipping\n", szSourceFile);
|
||||
bDoCopy = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (bDoCopy)
|
||||
{
|
||||
if (GetOneFile(szSourceFile, szDestinationFile, fdSource.size, fdSource.time_write))
|
||||
{
|
||||
nFilesCopied++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
hFind = rfindnext(hFind, &fdSource);
|
||||
|
||||
if (!bDestinationIsDir && hFind != 0 && hFind != -1)
|
||||
{
|
||||
printf(
|
||||
"%s: Destination isn't a directory and multiple files selected\n",
|
||||
szDestinationFile);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (hFind != 0 && hFind != -1);
|
||||
|
||||
if (hFind != 0 && hFind != -1)
|
||||
{
|
||||
rfindfirst(hFind, NULL, NULL);
|
||||
}
|
||||
|
||||
printf("%d files copied\n", nFilesCopied);
|
||||
}
|
||||
|
||||
int
|
||||
main2(int argc, char **argv)
|
||||
{
|
||||
char cOption;
|
||||
int i;
|
||||
int OEMParallelPortInit(void);
|
||||
|
||||
//
|
||||
// Keep timezone conversions from getting in our way. All of the responses
|
||||
// from the host are in local time anyways.
|
||||
//
|
||||
_daylight = 0;
|
||||
_timezone = 0;
|
||||
|
||||
OEMParallelPortInit();
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (argv[i][0] == '-' || argv[i][0] == '/')
|
||||
{
|
||||
cOption = tolower(argv[i][1]);
|
||||
|
||||
switch (cOption)
|
||||
{
|
||||
case '?':
|
||||
case 'h':
|
||||
usage2(argv[0]);
|
||||
break;
|
||||
case 'd':
|
||||
{
|
||||
char *pszPath;
|
||||
|
||||
if (argv[i][2] != '\0')
|
||||
{
|
||||
pszPath = &argv[i][2];
|
||||
if (*pszPath == ':')
|
||||
{
|
||||
pszPath++;
|
||||
}
|
||||
}
|
||||
else if (argc > (i+1) && argv[i+1][0] != '-' && argv[i+1][0] != '/')
|
||||
{
|
||||
pszPath = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
pszPath = "*.*";
|
||||
}
|
||||
DisplayDirectory(pszPath);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
case 'r':
|
||||
case 'u':
|
||||
{
|
||||
char *pszSource;
|
||||
char *pszDestination;
|
||||
|
||||
if (argv[i][2] != '\0')
|
||||
{
|
||||
pszSource = &argv[i][2];
|
||||
if (*pszSource == ':')
|
||||
{
|
||||
pszSource++;
|
||||
}
|
||||
}
|
||||
else if (argc > (i+1) && argv[i+1][0] != '-' && argv[i+1][0] != '/')
|
||||
{
|
||||
pszSource = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error source path missing\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (argc > (i+1) && argv[i+1][0] != '-' && argv[i+1][0] != '/')
|
||||
{
|
||||
pszDestination = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
pszDestination = NULL;
|
||||
}
|
||||
|
||||
GetFile(
|
||||
pszSource, pszDestination,
|
||||
cOption == 'r' ? COPY_FLAG_UPDATE_EXISTING :
|
||||
cOption == 'u' ? COPY_FLAG_UPDATE_OR_ADD :
|
||||
0);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("%s: Unsupported option\n\n", argv[i]);
|
||||
usage2(argv[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
DumpCounters();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
2118
DOS/LOADCEPC/ppfstool.cod
Normal file
2118
DOS/LOADCEPC/ppfstool.cod
Normal file
File diff suppressed because it is too large
Load Diff
BIN
DOS/LOADCEPC/ppfstool.obj
Normal file
BIN
DOS/LOADCEPC/ppfstool.obj
Normal file
Binary file not shown.
BIN
DOS/LOADCEPC/ppfstool.sbr
Normal file
BIN
DOS/LOADCEPC/ppfstool.sbr
Normal file
Binary file not shown.
48
DOS/LOADCEPC/readme.txt
Normal file
48
DOS/LOADCEPC/readme.txt
Normal file
@ -0,0 +1,48 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this source code is subject to the terms of the Microsoft end-user
|
||||
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
|
||||
// If you did not accept the terms of the EULA, you are not authorized to use
|
||||
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
|
||||
// install media.
|
||||
//
|
||||
|
||||
Build instructions for loadcepc.exe
|
||||
-----------------------------------
|
||||
|
||||
The build process for "loadcepc" requires a 16 bit compiler. Because
|
||||
of this, its not built in a Windows CE build window, but rather using
|
||||
a standard cmd.exe window. The location of the compiler is determined
|
||||
by the batch file setupen2.bat. It searches in different locations for the
|
||||
appropriate version. The assembler (ml) for the single asm file is accessed
|
||||
from the _WINCEROOT\sdk\bin\i386 directory. If the compiler cannot be
|
||||
located or _WINCEROOT environment variable is not set, an error is displayed
|
||||
when setting up the environment.
|
||||
|
||||
The procedure to build loadcepc.exe is as follows:
|
||||
|
||||
- Launch a basic cmd window (cmd.exe).
|
||||
|
||||
Execute following commands in this window:
|
||||
|
||||
- Set the _WINCEROOT environment variable:
|
||||
|
||||
X:>set _WINCEROOT=<your wince root here>
|
||||
|
||||
- Execute the batch file setupenv.bat:
|
||||
|
||||
X:>setupenv.bat
|
||||
|
||||
- Execute the make file using nmake:
|
||||
|
||||
x:>nmake /F loadcepc.mak
|
||||
|
||||
This will build a loadcepc.exe in this directory. The warning
|
||||
messages may be safely ignored.
|
||||
|
||||
To remove files used in the build process the "clean" target
|
||||
is available, as follows:
|
||||
|
||||
X:>nmake /F loadcepc.mak clean
|
||||
59
DOS/LOADCEPC/setupen2.bat
Normal file
59
DOS/LOADCEPC/setupen2.bat
Normal file
@ -0,0 +1,59 @@
|
||||
@REM
|
||||
@REM Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
@REM
|
||||
@REM
|
||||
@REM Use of this sample source code is subject to the terms of the Microsoft
|
||||
@REM license agreement under which you licensed this sample source code. If
|
||||
@REM you did not accept the terms of the license agreement, you are not
|
||||
@REM authorized to use this sample source code. For the terms of the license,
|
||||
@REM please see the license agreement between you and Microsoft or, if applicable,
|
||||
@REM see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
@REM THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
@REM
|
||||
|
||||
@ECHO OFF
|
||||
|
||||
@REM Note: Please read the README.TXT in this directory for build instructions
|
||||
@REM for loadcepc.
|
||||
@REM
|
||||
@REM The environment variable WINCEROOT must be set. The assembler
|
||||
@REM "ml" used for TRANSFER.ASM requires this program.
|
||||
|
||||
if "%_WINCEROOT%"=="" goto ERROR2
|
||||
|
||||
PROMPT *** 16-bit dev mode - type exit to return to normal ***$_%prompt%
|
||||
|
||||
@REM Locate the 16 bit dev tools. Try local drive, then Windows CE tree
|
||||
@REM and finally, the \\boneyard share.
|
||||
|
||||
if not exist %HOMEDRIVE%\msvc goto ENLIST_PATH
|
||||
set __MSVCDIR=%HOMEDRIVE%\msvc
|
||||
goto PATH_DONE
|
||||
|
||||
:ENLIST_PATH
|
||||
if not exist %_WINCEROOT%\sdk\vc150.win goto SHARE_PATH
|
||||
set __MSVCDIR=%_WINCEROOT%\sdk\vc150.win
|
||||
goto PATH_DONE
|
||||
|
||||
:SHARE_PATH
|
||||
if not exist \\boneyard\rellang\vc150.win\msvc goto ERROR
|
||||
set __MSVCDIR=\\boneyard\rellang\vc150.win\msvc
|
||||
|
||||
@REM Setup PATH, DevDir, LIB, and INCLUDE locations.
|
||||
|
||||
:PATH_DONE
|
||||
set PATH=%__MSVCDIR%\bin;%PATH%;%_WINCEROOT%\sdk\bin\i386;C:\MASM\BIN
|
||||
set MSDevDir=%__MSVCDIR%
|
||||
set LIB=%__MSVCDIR%\lib
|
||||
set INCLUDE=%__MSVCDIR%\include
|
||||
goto DONE
|
||||
|
||||
:ERROR
|
||||
echo ERROR: vc150.win path NOT found.
|
||||
goto DONE
|
||||
|
||||
:ERROR2
|
||||
echo ERROR: WINCEROOT must be set.
|
||||
|
||||
:DONE
|
||||
command
|
||||
19
DOS/LOADCEPC/setupenv.bat
Normal file
19
DOS/LOADCEPC/setupenv.bat
Normal file
@ -0,0 +1,19 @@
|
||||
@REM
|
||||
@REM Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
@REM
|
||||
@REM
|
||||
@REM Use of this sample source code is subject to the terms of the Microsoft
|
||||
@REM license agreement under which you licensed this sample source code. If
|
||||
@REM you did not accept the terms of the license agreement, you are not
|
||||
@REM authorized to use this sample source code. For the terms of the license,
|
||||
@REM please see the license agreement between you and Microsoft or, if applicable,
|
||||
@REM see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
@REM THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
@REM
|
||||
|
||||
@echo off
|
||||
|
||||
SET _WINCEROOT=C:\WINCE600
|
||||
|
||||
%comspec% /k setupen2.bat
|
||||
|
||||
193
DOS/LOADCEPC/smchw.h
Normal file
193
DOS/LOADCEPC/smchw.h
Normal file
@ -0,0 +1,193 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
/*++
|
||||
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|
||||
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
||||
PARTICULAR PURPOSE.
|
||||
|
||||
Module Name:
|
||||
smchw.h
|
||||
Abstract:
|
||||
Definitions for the SMC9000 registers
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _SMCHW_H
|
||||
#define _SMCHW_H
|
||||
|
||||
|
||||
// These registers are in Bank 0 at the given offsets from the base address
|
||||
// Since they are set up for 32-bit accesses, the offsets are multiplied by 2 from
|
||||
// the numbers given in the SMC91C94 spec.
|
||||
#define TCR_REG 0
|
||||
#define EPHSTATUS_REG 2
|
||||
#define RCR_REG 4
|
||||
#define COUNTER_REG 6
|
||||
#define MIR_REG 8
|
||||
#define MCR_REG 10
|
||||
// The register at offset 24 is reserved
|
||||
// The bank select register is the same for all 4 banks
|
||||
#define BANKSEL_REG 14
|
||||
|
||||
// Bank 1 registers
|
||||
#define CONFIG_REG 0
|
||||
#define BASE_REG 2
|
||||
#define MACADDR_REG0 4
|
||||
#define MACADDR_REG1 6
|
||||
#define MACADDR_REG2 8
|
||||
#define GENERAL_REG 10
|
||||
#define CONTROL_REG 12
|
||||
|
||||
// Bank 2 _REGisters
|
||||
#define MMUCOMMAND_REG 0
|
||||
#define PNR_ARR_REG 2
|
||||
#define FIFOPORTS_REG 4
|
||||
#define POINTER_REG 6
|
||||
#define DATA_REG 8
|
||||
#define AUXDATA_REG 10
|
||||
#define INTERRUPT_REG 12
|
||||
#define INTERRUPT_MASK_REG 13
|
||||
|
||||
// Bank 3 registers
|
||||
#define MULTITAB_REG0 0
|
||||
#define MULTITAB_REG1 2
|
||||
#define MULTITAB_REG2 4
|
||||
#define MULTITAB_REG3 6
|
||||
#define MGMT_REG 8
|
||||
#define REVISION_REG 10
|
||||
#define ERCV_REG 12
|
||||
|
||||
// These values are written to the bank select register to change banks.
|
||||
#define BANK0 0x3300
|
||||
#define BANK1 0x3301
|
||||
#define BANK2 0x3302
|
||||
#define BANK3 0x3303
|
||||
|
||||
// EPH Status reg (also used for TX status word)
|
||||
#define EPH_UNDERRUN 0x8000 // Frame uderrun
|
||||
#define EPH_LINKERROR 0x4000 // 10BASET link error condition
|
||||
#define EPH_RXOVERRUN 0x2000 // Receiver overrun
|
||||
#define EPH_COUNTER 0x1000 // Counter roll over
|
||||
#define EPH_EXDEFER 0x0800 // Excessive deferral
|
||||
#define EPH_CARRIER 0x0400 // Carrier not present
|
||||
#define EPH_LATE 0x0200 // Late collision
|
||||
#define EPH_DEFER 0x0080 // Frame was deferred
|
||||
#define EPH_BCAST 0x0040 // Last frame was broadcast
|
||||
#define EPH_SQET 0x0020 // Signal Quality Error
|
||||
#define EPH_16COL 0x0010 // Too many collisions
|
||||
#define EPH_MCAST 0x0008 // Last frame was multicast
|
||||
#define EPH_MULTICOL 0x0004 // Multiple collisions on last frame
|
||||
#define EPH_1COL 0x0002 // Single collision on last frame
|
||||
#define EPH_TX_OK 0x0001 // Frame successfully transmitted
|
||||
|
||||
|
||||
// MMU Commands
|
||||
#define CMD_NOP 0 // No-Op command
|
||||
#define CMD_ALLOC 0x0020 // Allocate memory
|
||||
#define CMD_RESET 0x0040 // Reset MMU to initial state
|
||||
#define CMD_REM_TOP 0x0060 // Remove frame from top of RX fifo
|
||||
#define CMD_REM_REL_TOP 0x0080 // Remove and release top of RX fifo
|
||||
#define CMD_REL_SPEC 0x00a0 // Release specific packet
|
||||
#define CMD_ENQ_TX 0x00c0 // Enqueue to xmit fifo
|
||||
#define CMD_ENQ_RX 0x00e0 // Reset xmit fifos (should only be done
|
||||
// with transmitter disabled)
|
||||
#define MMU_CMD_BUSY 0x0001 // MMU busy, don't modify PNR
|
||||
|
||||
// Allocation Result Register (low byte of PNR_ARR_REG)
|
||||
#define ARR_FAIL 0x80 // Allocation failed
|
||||
#define ARR_ALLOC_MSK 0x7f // Mask allocated packet number
|
||||
// Actually 1fh but use full mask for
|
||||
// upward compatibility.
|
||||
|
||||
// Pointer Register (POINTER_REG)
|
||||
#define PTR_RCV 0x8000 // Access is to receive area
|
||||
#define PTR_AUTO 0x4000 // Auto-increment on access
|
||||
#define PTR_READ 0x2000 // =1 then read operation
|
||||
// =0 then write operation
|
||||
#define PTR_ETEN 0x1000 // Detect early transmit underrun
|
||||
#define PTR_NOT_EMPTY 0x0800 // Write fifo not empty
|
||||
#define PTR_OFFSET 0x03ff // Mask pointer value
|
||||
|
||||
// Fifo Ports Register (FIFOPORTS_REG)
|
||||
#define FIFO_EMPTY 0x80 // No packet at top of fifo
|
||||
#define FIFO_TX_PKT_MASK 0x7f // Mask top packet number
|
||||
// Actually 1fh but use full mask for
|
||||
// upward compatibility.
|
||||
|
||||
// Interrupt flags that can be set/acknowledged
|
||||
#define ERCV_INT 0x0040
|
||||
#define EPH_INT 0x0020
|
||||
#define RX_OVRN_INT 0x0010
|
||||
#define ALLOC_INT 0x0008
|
||||
#define TXEMPTY_INT 0x0004
|
||||
#define TX_INT 0x0002
|
||||
#define RCV_INT 0x0001
|
||||
|
||||
// Interrupt mask bits, if these are set the interrupt is enabled
|
||||
#define ERCV_INTM 0x4000
|
||||
#define EPH_INTM 0x2000
|
||||
#define RX_OVRN_INTM 0x1000
|
||||
#define ALLOC_INTM 0x0800
|
||||
#define TXEMPTY_INTM 0x0400
|
||||
#define TX_INTM 0x0200
|
||||
#define RCV_INTM 0x0100
|
||||
|
||||
// This value is used to intialize the Control Register (Pg 49 of the SMC91C94 spec):
|
||||
// Bit 14 - RCV_BAD - Don't receive Frames with bad CRC
|
||||
// Bit 13 - PWRDN - Don't go into power down mode
|
||||
// Bit 11 - AUTO RELEASE - Do use the auto memory release feature for successfully transmitted Frames
|
||||
// Bit 7 - LE ENABLE - Don't generate interrupts for link errors (merged through EPH_INT)
|
||||
// Bit 6 - CR ENABLE - Don't generate interrupts for counter roll over (merged through EPH_INT)
|
||||
// Bit 5 - TE ENABLE - Do generate interrupts for transmit errors (merged through EPH_INT)
|
||||
// Bit 2 - EEPROM SELECT - Don't select the EEPROM
|
||||
// Bit 1 - RELOAD - Don't reload EEPROM data
|
||||
// Bit 0 - STORE - Don't store EEPROM data
|
||||
#define CONTROL_REG_INIT 0x0920
|
||||
|
||||
// This value is used to intialize the Transmit Control Register (Pg 35 of the SMC91C94 spec):
|
||||
// Bit 13 - EPH LOOP - Don't do EPH Internal Loopback
|
||||
// Bit 12 - STP SQET - Don't stop transmission on SQET error
|
||||
// DANGER - May need FDUPLX for IPX
|
||||
// Bit 11 - FDUPLX - Don't use full duplex operation so that Frames sourced by this card are not received by it
|
||||
// Bit 10 - MON_CSN - Don't monitor carrier while transmitting. Transmission will continue whether the card senses
|
||||
// it's own carrier after the preamble or not.
|
||||
// Bit 8 - NOCRC - Do insert the CRC at the end of transmitted frames automatically
|
||||
// Bit 7 - PAD_EN - Do pad frames shorter than the minimum of 64 bytes automatically
|
||||
// Bit 2 - FORCOL - Don't force a collision
|
||||
// Bit 1 - LOOP - Don't loop back frames internally without transmitting
|
||||
// Bit 0 - TXENA - Do enable transmission
|
||||
#define TCR_REG_INIT 0x0081
|
||||
|
||||
// This value is used to initialize the Memory Configuration Register (Pg 42 of the SMC91C94 spec):
|
||||
// Bits 7-0 - MEMORY RESERVED FOR TRANSMIT - Reserve memory for transmit purposes only. I need to
|
||||
// reserve enough memory for one maximum sized Frame for transmission purposes. This will prevent
|
||||
// deadlock conditions in which Frames keep coming in, but can't be acknowledged because of a lack of memory.
|
||||
// The amount of memory reserved is calculated as MCR_REG_INIT * 256 * M, where M is 1 for the 91C94
|
||||
// (pg 42 of the SMC91C94 spec.). So, for a 1500 byte frame, I need 1500 / 256 = 6 memory pages.
|
||||
#define MCR_REG_INIT 0x0006
|
||||
|
||||
// This value is used to initialize the Receive Control Register (Pg 39 of the SMC91C94 spec):
|
||||
// Bit 15 - SOFT RST - Don't do a soft reset
|
||||
// Bit 14 - FILT_CAR - Don't filter the carrier signal
|
||||
// Bit 9 - STRIP CRC - Don't strip the CRC from the Frame
|
||||
// Bit 8 - RXEN - Do enable the Frame receiver
|
||||
// Bit 2 - ALMUL - Don't accept all multicast frames
|
||||
// Bit 1 - PRMS - Don't go into promiscuous mode
|
||||
// Bit 0 - RX_ABORT - Write the receive abort flag low
|
||||
// (set by a frame that was longer than 1532 bytes or out of buffer memory error)
|
||||
#define RCR_REG_INIT 0x0100
|
||||
|
||||
|
||||
#endif // _SMCHW_H
|
||||
217
DOS/LOADCEPC/transfer.asm
Normal file
217
DOS/LOADCEPC/transfer.asm
Normal file
@ -0,0 +1,217 @@
|
||||
;
|
||||
; Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
;
|
||||
;
|
||||
; Use of this sample source code is subject to the terms of the Microsoft
|
||||
; license agreement under which you licensed this sample source code. If
|
||||
; you did not accept the terms of the license agreement, you are not
|
||||
; authorized to use this sample source code. For the terms of the license,
|
||||
; please see the license agreement between you and Microsoft or, if applicable,
|
||||
; see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
; THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
;
|
||||
;***********************************************************************************************************
|
||||
;
|
||||
; Init.Asm - Boot Loader initialization code for x86 PC.
|
||||
;
|
||||
; Author: RBN
|
||||
;
|
||||
; Written 5/1/96
|
||||
;
|
||||
;***********************************************************************************************************
|
||||
|
||||
.486p
|
||||
|
||||
OpPrefix MACRO
|
||||
db 66h
|
||||
ENDM
|
||||
|
||||
_TEXT SEGMENT WORD PUBLIC USE16 'CODE'
|
||||
|
||||
FLAT_STACK_SIZE EQU 4000h
|
||||
db FLAT_STACK_SIZE dup ( 0 )
|
||||
FLAT_STACK_START equ $
|
||||
|
||||
;
|
||||
; This static GDT contains 2 selectors - A flat code selector, and a flat data selector.
|
||||
;
|
||||
GDT_Data LABEL DWORD
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0 ; First GDT entry always unused
|
||||
CS_FLAT_SEL EQU ($-GDT_Data)
|
||||
db 0FFh, 0FFh, 00h, 00h, 00h, 10011010b, 11001111b, 00h ; Code
|
||||
DS_FLAT_SEL EQU ($-GDT_Data)
|
||||
db 0FFh, 0FFh, 00h, 00h, 00h, 10010010b, 11001111b, 00h ; Data
|
||||
GDT_TABLE_SIZE = $ - OFFSET GDT_Data
|
||||
|
||||
;
|
||||
; Limit + Pointer to the GDT
|
||||
;
|
||||
GDTPtr LABEL FWORD
|
||||
dw GDT_TABLE_SIZE - 1 ; Limit of 0 = 1 byte
|
||||
dd OFFSET GDT_Data
|
||||
|
||||
PModeEntrySeg dw SEG InPModeNow
|
||||
|
||||
PModeEntryOff dd OFFSET InPModeNow
|
||||
|
||||
|
||||
|
||||
;******************************************************************************
|
||||
;
|
||||
; Launch
|
||||
;
|
||||
; At this point, we are running in a 16-bit code segment.
|
||||
; Since this code is written in a 16-bit code segment, we need to put an
|
||||
; OpPrefix in front of all 32-bit instructions.
|
||||
;
|
||||
; This function jumps to InPModeNow to force CS to be reloaded with a
|
||||
; valid PMode selector.
|
||||
;
|
||||
;******************************************************************************
|
||||
|
||||
Launch PROC NEAR C PUBLIC
|
||||
|
||||
cli ; Make sure we don't get any more interrupts
|
||||
|
||||
mov al, 0FFh ; Disable all PIC interrupts
|
||||
out 021h, al
|
||||
|
||||
if 0
|
||||
mov dx, 003FBh
|
||||
mov al, 080h ; Access Baud Divisor
|
||||
out dx, al
|
||||
|
||||
dec dx ; 3FAh
|
||||
dec dx ; 3F9h
|
||||
|
||||
dec dx ; 3F8h
|
||||
mov al, 002h ; 57600 Baud
|
||||
out dx, al
|
||||
|
||||
inc dx ; 3F9h
|
||||
xor al, al
|
||||
out dx, al
|
||||
|
||||
inc dx ; 3FAh
|
||||
|
||||
inc dx ; 3FBh
|
||||
mov al, 003h ; DLAB = 0, 8 bit, no parity
|
||||
out dx, al
|
||||
|
||||
dec dx ; 3FAh
|
||||
|
||||
dec dx ; 3F9h
|
||||
xor al, al ; No interrupts, polled
|
||||
out dx, al
|
||||
|
||||
inc dx ; 3FAh
|
||||
mov al, 001h ; Enable FIFO if present
|
||||
out dx, al
|
||||
|
||||
inc dx ; 3FBh
|
||||
|
||||
inc dx ; 3FCh
|
||||
mov al, 003h ; Assert DTR, RTS
|
||||
out dx, al
|
||||
|
||||
mov dx, 03FDh
|
||||
@@:
|
||||
in al, dx ; Get Modem status
|
||||
test al, 020h
|
||||
jz @B
|
||||
|
||||
mov al, 'A'
|
||||
mov dx, 03F8h
|
||||
out dx, al
|
||||
endif
|
||||
|
||||
;
|
||||
; Since we were loaded by the DOS 16bit real-mode loader we need to
|
||||
; manually relocate all references to linear addresses before we switch
|
||||
; to protect mode.
|
||||
;
|
||||
|
||||
xor ebx, ebx ; Clear upper word
|
||||
mov bx, cs ; Our segment
|
||||
shl ebx, 4 ; Convert segment to linear address
|
||||
|
||||
mov eax, DWORD PTR [GDTPtr + 2]
|
||||
add eax, ebx
|
||||
mov DWORD PTR [GDTPtr + 2], eax
|
||||
|
||||
xor eax, eax
|
||||
mov ax, [PModeEntrySeg]
|
||||
shl eax, 4
|
||||
add eax, [PModeEntryOff]
|
||||
mov [PModeLbl], eax
|
||||
|
||||
pop ax ; Remove return address from stack
|
||||
pop edx ; Load entry point from arguments
|
||||
pop esi ; Linear address of arguments
|
||||
|
||||
OpPrefix
|
||||
lgdt FWORD PTR [GDTPtr] ; Load the GDTR
|
||||
|
||||
mov ecx, OFFSET FLAT_STACK_START
|
||||
add ecx, ebx
|
||||
|
||||
;
|
||||
; Don't need OpPrefix on mov to/from CR0 -- It's always 32-bit
|
||||
;
|
||||
mov eax, cr0 ; Get the current CR0
|
||||
or al, 1 ; Set the PE bit to enable protected mode
|
||||
mov cr0, eax ; NOW WE'RE IN PMODE!
|
||||
|
||||
OpPrefix
|
||||
db 0EAh ; Far jump forces a selector lookup
|
||||
PModeLbl dd 0
|
||||
dw CS_FLAT_SEL
|
||||
|
||||
Launch ENDP
|
||||
|
||||
_TEXT ENDS
|
||||
|
||||
_TEXT32 SEGMENT WORD PUBLIC USE32 'CODE32'
|
||||
|
||||
;***********************************************************************************************************
|
||||
;
|
||||
; InPModeNow
|
||||
;
|
||||
; This function is responsible for setting up the data selectors and the stack and then jumping to main.
|
||||
;
|
||||
;***********************************************************************************************************
|
||||
|
||||
InPModeNow PROC NEAR
|
||||
|
||||
mov eax, DS_FLAT_SEL
|
||||
mov ds, eax
|
||||
mov es, eax
|
||||
mov fs, eax
|
||||
mov gs, eax
|
||||
mov ss, eax
|
||||
mov esp, ecx
|
||||
|
||||
push edx
|
||||
|
||||
mov edx, 001FFFFCh
|
||||
mov dword ptr [edx], esi ; Save linear ptr to args in known location
|
||||
|
||||
if 0
|
||||
mov dx, 03FDh
|
||||
@@:
|
||||
in al, dx ; Get Modem status
|
||||
test al, 020h
|
||||
jz @B
|
||||
|
||||
mov al, 'B'
|
||||
mov dx, 03F8h
|
||||
out dx, al
|
||||
endif
|
||||
|
||||
ret ; Jump to entry point
|
||||
|
||||
InPModeNow ENDP
|
||||
|
||||
_TEXT32 ENDS
|
||||
|
||||
END
|
||||
565
DOS/LOADCEPC/video.c
Normal file
565
DOS/LOADCEPC/video.c
Normal file
@ -0,0 +1,565 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
|
||||
/*++
|
||||
|
||||
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|
||||
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
||||
PARTICULAR PURPOSE.
|
||||
|
||||
Module Name: video.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Functions:
|
||||
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "loadcepc.h"
|
||||
#include "video.h"
|
||||
#include "bootarg.h"
|
||||
|
||||
extern BOOT_ARGS BootArgs;
|
||||
|
||||
static BOOL bNoModeSet = FALSE;
|
||||
|
||||
|
||||
void mode320x200x256( void )
|
||||
{
|
||||
// Put the display into 320x200x256 colour mode and clear it
|
||||
|
||||
__asm
|
||||
{
|
||||
mov ah, 0 ; Set video mode
|
||||
mov al, 013h ; 320x200x256 and clear screen
|
||||
int 10h ; set mode 13
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int isVesaSupported( void )
|
||||
{
|
||||
VESA_GENERAL_INFO vesaInfo, far *pVesaInfo = &vesaInfo;
|
||||
|
||||
__asm
|
||||
{
|
||||
mov ax, 04F00h ; Get VESA info
|
||||
les di, pVesaInfo ; Pointer to info buffer
|
||||
int 10h ; check for VESA
|
||||
|
||||
cmp ax, 0004Fh ; Was it successful?
|
||||
jne noVesa
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
noVesa:
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
int setVesaMode( int vesaMode, int scanLength )
|
||||
{
|
||||
//printf( "setVesaMode( %d, %d\n", vesaMode, scanLength );
|
||||
|
||||
__asm
|
||||
{
|
||||
mov ax, 04F02h ; VESA Set mode
|
||||
mov bx, vesaMode ; Set given VESA Mode
|
||||
int 10h ;
|
||||
|
||||
cmp ax, 0004Fh ; Was it successful?
|
||||
jne failed ;
|
||||
|
||||
mov cx, scanLength ; Set so banks are an integral number lines
|
||||
jcxz finished ; if no scanLength requested, just exit
|
||||
mov ax, 04F06h ; VESA Set logical scan line length
|
||||
mov bl, 0 ;
|
||||
int 10h ; set VESA scan length
|
||||
|
||||
cmp ax, 0004Fh ; Was it successful?
|
||||
jne failed ;
|
||||
}
|
||||
|
||||
finished:
|
||||
return TRUE;
|
||||
|
||||
failed:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
** SetVideoMode: maps from the user input 0-X to a VESA mode
|
||||
**
|
||||
** User VESA MODE
|
||||
** Input
|
||||
** 0 320x200x256 default mode, should work on any video card with 64K
|
||||
** memory.
|
||||
** 1 480x240x256 non-standard VGA resolution, emulated in a 640x480
|
||||
** window.
|
||||
** 2 640x480x256
|
||||
** 3 800x600x256
|
||||
** 4 1024x768x256
|
||||
** 5 320x240x256 non-standard VGA resolution, emulated in a 640x480
|
||||
** window.
|
||||
** 6 208x240x256
|
||||
*/
|
||||
|
||||
UCHAR SetVideoMode( int desiredMode )
|
||||
{
|
||||
int vesaMode = 0;
|
||||
int scanLength;
|
||||
|
||||
// if user requested to skip the mode set, just pass bootargs
|
||||
|
||||
if( bNoModeSet )
|
||||
{
|
||||
return( 0xFF ); // force caller to leave bootargs vars alone
|
||||
}
|
||||
|
||||
// In the default mode, there is no need to bank switch the card
|
||||
// since only 64K required VESA is NOT required for this mode.
|
||||
|
||||
if( desiredMode == 0 )
|
||||
{
|
||||
mode320x200x256();
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
// If VESA is supported use VESA to put the
|
||||
// video card into the appropriate mode.
|
||||
|
||||
if( isVesaSupported() )
|
||||
{
|
||||
switch( desiredMode )
|
||||
{
|
||||
case 0x01: // 480x240x256 is emulated in a partial 640x480x256 screen
|
||||
case 0x02:
|
||||
case 0x05: // 240x320x256 is emulated in a partial 640x480x256 screen
|
||||
case 0x06: // 208x240x256 is emulated in a partial 640x480x256 screen
|
||||
|
||||
scanLength = VESASCANLENGTH1024; // scan length for this mode
|
||||
vesaMode = VESAMODE640x480x256; // VESA Mode 101 640x480x256
|
||||
break;
|
||||
|
||||
case 0x03:
|
||||
|
||||
scanLength = VESASCANLENGTH1024; // scan length for this mode
|
||||
vesaMode = VESAMODE800x600x256; // VESA Mode 103 800x600x256
|
||||
break;
|
||||
|
||||
case 0x04:
|
||||
|
||||
scanLength = VESASCANLENGTH1024; // scan length for this mode
|
||||
vesaMode = VESAMODE1024x768x256; // VESA Mode 105 1024x768x256
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
// VESA mode value was passed in - use directly
|
||||
|
||||
vesaMode = desiredMode; /* use passed in mode value */
|
||||
vesaMode |= 0x4000; /* ask for linear/flat framebuffer mode */
|
||||
scanLength = 0; /* use mode default scan length */
|
||||
break;
|
||||
}
|
||||
|
||||
// Setup the video card
|
||||
|
||||
if( setVesaMode( vesaMode, scanLength ) )
|
||||
{
|
||||
// Indicate status
|
||||
|
||||
return( (UCHAR)(desiredMode < 0x100 ? desiredMode : 0xFF) );
|
||||
}
|
||||
}
|
||||
|
||||
// Set default mode if we get here
|
||||
|
||||
mode320x200x256();
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
//
|
||||
// FindClosestVESAMode - Finds VESA mode with X and Y size closest to
|
||||
// requested screen size.
|
||||
//
|
||||
// Returns flat framebuffer pointer, flat framebuffer stride, and physical X
|
||||
// and Y size
|
||||
//
|
||||
|
||||
void FindClosestVESAMode( void )
|
||||
{
|
||||
VESA_GENERAL_INFO vesaInfo, far *pVesaInfo = &vesaInfo;
|
||||
VESA_MODE_INFO modeInfo, far *pModeInfo = &modeInfo;
|
||||
DWORD deltaX, deltaY;
|
||||
DWORD currError, error;
|
||||
WORD vesaMode;
|
||||
int index;
|
||||
|
||||
//printf( "FindClosestVESAMode\n\r" );
|
||||
|
||||
vesaInfo.szSignature[0] = 'V';
|
||||
vesaInfo.szSignature[1] = 'B';
|
||||
vesaInfo.szSignature[2] = 'E';
|
||||
vesaInfo.szSignature[3] = '2';
|
||||
|
||||
__asm
|
||||
{
|
||||
push es
|
||||
mov ax, 04F00h ; Get VESA info
|
||||
les di, pVesaInfo ; Pointer to info buffer
|
||||
int 10h ; check for VESA
|
||||
pop es
|
||||
|
||||
cmp ax, 0004Fh ; Was it successful?
|
||||
je itsok
|
||||
jmp noVesa
|
||||
}
|
||||
|
||||
itsok:
|
||||
|
||||
// check for minimum compat version of VBE
|
||||
|
||||
if (vesaInfo.wVersion < 0x0200)
|
||||
{
|
||||
goto noVesa;
|
||||
}
|
||||
|
||||
// Clear mode, set error to large value
|
||||
|
||||
BootArgs.vesaMode = 0;
|
||||
currError = 0xFFFFFFFF;
|
||||
|
||||
// Process the VESA mode list
|
||||
|
||||
for( index=0; vesaInfo.pModeList[index] != -1; index++ )
|
||||
{
|
||||
// Set mode we are checking
|
||||
|
||||
vesaMode = vesaInfo.pModeList[index];
|
||||
|
||||
// Fetch the Mode Info
|
||||
|
||||
__asm
|
||||
{
|
||||
push es
|
||||
mov cx, vesaMode
|
||||
les di, pModeInfo ; Pointer to info buffer
|
||||
mov ax, 04F01h ; Return VBE Mode Information
|
||||
int 10h
|
||||
pop es
|
||||
}
|
||||
|
||||
// Check Mode Info - the following are required:
|
||||
//
|
||||
// - planer mode
|
||||
// - flat frame buffer compat mode
|
||||
// - matching color depth
|
||||
// - same size or bigger than requested
|
||||
|
||||
if( (modeInfo.ucNumberOfPlanes == 1) &&
|
||||
(modeInfo.dwPhysBasePtr != 0) &&
|
||||
(modeInfo.ucBitsPerPixel == BootArgs.bppScreen) &&
|
||||
(modeInfo.wXResolution >= BootArgs.cxDisplayScreen) &&
|
||||
(modeInfo.wYResolution >= BootArgs.cyDisplayScreen) )
|
||||
{
|
||||
// only allow 565 16bpp modes through
|
||||
|
||||
if( (modeInfo.ucBitsPerPixel == 16) &&
|
||||
((modeInfo.ucRedMaskSize != 5) ||
|
||||
(modeInfo.ucGreenMaskSize != 6) ||
|
||||
(modeInfo.ucBlueMaskSize != 5)) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Compute screen resolution error
|
||||
|
||||
deltaX = (DWORD)modeInfo.wXResolution -
|
||||
(DWORD)BootArgs.cxDisplayScreen;
|
||||
deltaY = (DWORD)modeInfo.wYResolution -
|
||||
(DWORD)BootArgs.cyDisplayScreen;
|
||||
|
||||
error = ((deltaX * deltaX) + (deltaY * deltaY));
|
||||
|
||||
// If the error is diminishing save the mode data
|
||||
|
||||
if( error < currError )
|
||||
{
|
||||
// Save the current error for next comparison
|
||||
|
||||
currError = error;
|
||||
|
||||
// Update the boot args with current data
|
||||
|
||||
BootArgs.vesaMode = vesaMode;
|
||||
BootArgs.pvFlatFrameBuffer = modeInfo.dwPhysBasePtr;
|
||||
BootArgs.cxPhysicalScreen = modeInfo.wXResolution;
|
||||
BootArgs.cyPhysicalScreen = modeInfo.wYResolution;
|
||||
BootArgs.cbScanLineLength = modeInfo.wBytesPerScanLine;
|
||||
BootArgs.RedMaskSize = modeInfo.ucRedMaskSize;
|
||||
BootArgs.RedMaskPosition = modeInfo.ucRedFieldPosition;
|
||||
BootArgs.GreenMaskSize = modeInfo.ucGreenMaskSize;
|
||||
BootArgs.GreenMaskPosition = modeInfo.ucGreenFieldPosition;
|
||||
BootArgs.BlueMaskSize = modeInfo.ucBlueMaskSize;
|
||||
BootArgs.BlueMaskPosition = modeInfo.ucBlueFieldPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( BootArgs.vesaMode == 0)
|
||||
{
|
||||
goto noVesa;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
noVesa:
|
||||
|
||||
// no matching VESA mode found, use 320x200x8 video mode as fallback
|
||||
|
||||
BootArgs.vesaMode = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// FindVESAMode - Finds VESA mode which exactly matches requested X and Y size
|
||||
// Returns flat framebuffer pointer and flat framebuffer stride
|
||||
//
|
||||
|
||||
void FindVESAMode( void )
|
||||
{
|
||||
VESA_GENERAL_INFO vesaInfo, far *pVesaInfo = &vesaInfo;
|
||||
VESA_MODE_INFO modeInfo, far *pModeInfo = &modeInfo;
|
||||
WORD vesaMode;
|
||||
int index;
|
||||
|
||||
//printf( "FindVesaMode( void )\n" );
|
||||
|
||||
vesaInfo.szSignature[0] = 'V';
|
||||
vesaInfo.szSignature[1] = 'B';
|
||||
vesaInfo.szSignature[2] = 'E';
|
||||
vesaInfo.szSignature[3] = '2';
|
||||
|
||||
// Fetch the VESA info data
|
||||
|
||||
__asm
|
||||
{
|
||||
push es
|
||||
mov ax, 04F00h ; Get VESA info
|
||||
les di, pVesaInfo ; Pointer to info buffer
|
||||
int 10h ; check for VESA
|
||||
pop es
|
||||
|
||||
cmp ax, 0004Fh ; Was it successful?
|
||||
je itsok
|
||||
jmp noVesa
|
||||
}
|
||||
|
||||
itsok:
|
||||
|
||||
// Validate minimum compatibility version of VBE
|
||||
|
||||
if( vesaInfo.wVersion < 0x0200 )
|
||||
{
|
||||
goto noVesa;
|
||||
}
|
||||
|
||||
// Clear mode
|
||||
|
||||
BootArgs.vesaMode = 0;
|
||||
|
||||
// Process the VESA ModeList
|
||||
|
||||
for( index=0; vesaInfo.pModeList[index] != -1; index++ )
|
||||
{
|
||||
// Set mode we are checking
|
||||
|
||||
vesaMode = vesaInfo.pModeList[index];
|
||||
|
||||
// Fetch the Mode Info
|
||||
|
||||
__asm
|
||||
{
|
||||
push es
|
||||
mov cx, vesaMode
|
||||
les di, pModeInfo ; Pointer to info buffer
|
||||
mov ax, 04F01h ; Return VBE Mode Information
|
||||
int 10h
|
||||
pop es
|
||||
}
|
||||
|
||||
// Check Mode Info - the following are required:
|
||||
//
|
||||
// - planer mode
|
||||
// - flat frame buffer compat mode
|
||||
// - matching color depth
|
||||
// - same size or bigger than requested
|
||||
|
||||
if( (modeInfo.ucNumberOfPlanes == 1) &&
|
||||
(modeInfo.dwPhysBasePtr != 0) &&
|
||||
(modeInfo.ucBitsPerPixel == BootArgs.bppScreen) &&
|
||||
(modeInfo.wXResolution == BootArgs.cxPhysicalScreen) &&
|
||||
(modeInfo.wYResolution == BootArgs.cyPhysicalScreen) )
|
||||
{
|
||||
// Conditions are met. Set BootArgs with Mode data and return.
|
||||
|
||||
BootArgs.vesaMode = vesaMode;
|
||||
BootArgs.pvFlatFrameBuffer = modeInfo.dwPhysBasePtr;
|
||||
BootArgs.cbScanLineLength = modeInfo.wBytesPerScanLine;
|
||||
BootArgs.RedMaskSize = modeInfo.ucRedMaskSize;
|
||||
BootArgs.RedMaskPosition = modeInfo.ucRedFieldPosition;
|
||||
BootArgs.GreenMaskSize = modeInfo.ucGreenMaskSize;
|
||||
BootArgs.GreenMaskPosition = modeInfo.ucGreenFieldPosition;
|
||||
BootArgs.BlueMaskSize = modeInfo.ucBlueMaskSize;
|
||||
BootArgs.BlueMaskPosition = modeInfo.ucBlueFieldPosition;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
noVesa:
|
||||
|
||||
// No matching VESA mode found, use 320x200x8 as fallback
|
||||
|
||||
BootArgs.vesaMode = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// ParseVESAOptions
|
||||
//
|
||||
|
||||
BOOL ParseVESAOptions( char *params )
|
||||
{
|
||||
int cArgs;
|
||||
|
||||
//printf( "ParseVESAOptions( 0x%x )\n", params );
|
||||
|
||||
// Clear mode
|
||||
|
||||
BootArgs.vesaMode = 0;
|
||||
|
||||
// Verify option format is /L:
|
||||
|
||||
if (params[2] != ':')
|
||||
{
|
||||
return( FALSE ); // colon after /L missing, exit
|
||||
}
|
||||
|
||||
// Check for the N format of the option, /L:N:xxx. This
|
||||
// mode skips all the VESA mode processing and the mode set.
|
||||
|
||||
if( (memcmp( ¶ms[3],"N:",2) == 0) || (memcmp( ¶ms[3],"n:",2) == 0) )
|
||||
{
|
||||
bNoModeSet = TRUE;
|
||||
|
||||
cArgs = sscanf( ¶ms[5], "%dx%dx%d:%dx%d",
|
||||
&BootArgs.cxDisplayScreen,
|
||||
&BootArgs.cyDisplayScreen,
|
||||
&BootArgs.bppScreen,
|
||||
&BootArgs.cxPhysicalScreen,
|
||||
&BootArgs.cyPhysicalScreen );
|
||||
if(cArgs == 3)
|
||||
{
|
||||
BootArgs.cxPhysicalScreen = BootArgs.cxDisplayScreen;
|
||||
BootArgs.cyPhysicalScreen = BootArgs.cyDisplayScreen;
|
||||
}
|
||||
else if(cArgs == 5)
|
||||
{
|
||||
if (BootArgs.cxPhysicalScreen < BootArgs.cxDisplayScreen ||
|
||||
BootArgs.cyPhysicalScreen < BootArgs.cyDisplayScreen)
|
||||
{
|
||||
printf
|
||||
(
|
||||
"ERROR: The physical screen dimensions (PX & PY) should be larger than the\n"
|
||||
" display resolution chosen. This option is used to simulate a \n"
|
||||
" smaller drawing area on a larger display.\n"
|
||||
);
|
||||
|
||||
// The physical screen size must be >= display screen size
|
||||
|
||||
return( FALSE );
|
||||
}
|
||||
}
|
||||
BootArgs.vesaMode = 0xffff; // just some really large value
|
||||
}
|
||||
else
|
||||
{
|
||||
// No 'N' present in option. Process and set the VESA mode
|
||||
|
||||
bNoModeSet = FALSE;
|
||||
|
||||
cArgs = sscanf( ¶ms[3], "%dx%dx%d:%dx%d",
|
||||
&BootArgs.cxDisplayScreen,
|
||||
&BootArgs.cyDisplayScreen,
|
||||
&BootArgs.bppScreen,
|
||||
&BootArgs.cxPhysicalScreen,
|
||||
&BootArgs.cyPhysicalScreen );
|
||||
|
||||
// Process according to # of args specified
|
||||
|
||||
switch( cArgs )
|
||||
{
|
||||
case 3:
|
||||
|
||||
// Explicit physical size not specified - find closest one
|
||||
|
||||
FindClosestVESAMode(); // uses and fills in BootArgs values
|
||||
break;
|
||||
|
||||
case 5:
|
||||
|
||||
// Validate specified physical size
|
||||
|
||||
if( BootArgs.cxPhysicalScreen < BootArgs.cxDisplayScreen ||
|
||||
BootArgs.cyPhysicalScreen < BootArgs.cyDisplayScreen )
|
||||
{
|
||||
printf
|
||||
(
|
||||
"ERROR: The physical screen dimensions (PX & PY) should be larger than the\n"
|
||||
" display resolution chosen. This option is used to simulate a \n"
|
||||
" smaller drawing area on a larger display.\n"
|
||||
);
|
||||
|
||||
// The physical screen size must be >= display screen size
|
||||
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
// Find the actual VESA mode
|
||||
|
||||
FindVESAMode(); // uses and fills in BootArgs values
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
// Invalid number of parameters
|
||||
|
||||
return( FALSE );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Indicate success
|
||||
|
||||
return( TRUE );
|
||||
}
|
||||
1524
DOS/LOADCEPC/video.cod
Normal file
1524
DOS/LOADCEPC/video.cod
Normal file
File diff suppressed because it is too large
Load Diff
73
DOS/LOADCEPC/video.h
Normal file
73
DOS/LOADCEPC/video.h
Normal file
@ -0,0 +1,73 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
#define VESAMODE480x200x256 0x101 /* VESA Mode 101 - 480x200x256 emulated in 640x480 */
|
||||
#define VESAMODE640x480x256 0x101 /* VESA Mode 101 - 640x480x256 */
|
||||
#define VESAMODE800x600x256 0x103 /* VESA Mode 103 - 800x600x256 */
|
||||
#define VESAMODE1024x768x256 0x105 /* VESA Mode 105 - 1024x768x256 */
|
||||
|
||||
#define VESASCANLENGTH1024 1024 /* These VESA modes have the same scan length */
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct _VESA_GENERAL_INFO
|
||||
{
|
||||
UCHAR szSignature[4];
|
||||
WORD wVersion;
|
||||
UCHAR far * pszVendor;
|
||||
DWORD dwCapabilities;
|
||||
WORD far * pModeList;
|
||||
WORD wTotalMemory;
|
||||
WORD wOemSoftwareRev;
|
||||
UCHAR far* pszVenderName;
|
||||
UCHAR far* pszProductName;
|
||||
UCHAR far* pszProductRev;
|
||||
UCHAR ucReserved[222];
|
||||
UCHAR ucOemData[256];
|
||||
} VESA_GENERAL_INFO;
|
||||
|
||||
typedef struct _VESA_MODE_INFO
|
||||
{
|
||||
WORD wModeAttributes; /* Mode attributes */
|
||||
UCHAR ucWindowAAttributes; /* Window A attributes */
|
||||
UCHAR ucWindowBAttributes; /* Window B attributes */
|
||||
WORD wWindowGranularity; /* Window granularity in k */
|
||||
WORD wWindowSize; /* Window size in k */
|
||||
WORD wWindowASegment; /* Window A segment */
|
||||
WORD wWindowBSegment; /* Window B segment */
|
||||
DWORD pWindowSchemeFunction; /* Pointer to window function */
|
||||
WORD wBytesPerScanLine; /* Bytes per scanline */
|
||||
WORD wXResolution; /* Horizontal resolution */
|
||||
WORD wYResolution; /* Vertical resolution */
|
||||
UCHAR ucXCharSize; /* Character cell width */
|
||||
UCHAR ucYCharSize; /* Character cell height */
|
||||
UCHAR ucNumberOfPlanes; /* Number of memory planes */
|
||||
UCHAR ucBitsPerPixel; /* Bits per pixel */
|
||||
UCHAR ucNumberOfBanks; /* Number of CGA style banks */
|
||||
UCHAR ucMemoryModel; /* Memory model type */
|
||||
UCHAR ucBankSize; /* Size of CGA style banks */
|
||||
UCHAR ucNumberOfImagePages; /* Number of images pages */
|
||||
UCHAR ucReserved1; /* Reserved */
|
||||
UCHAR ucRedMaskSize; /* Size of direct color red mask */
|
||||
UCHAR ucRedFieldPosition; /* Bit posn of lsb of red mask */
|
||||
UCHAR ucGreenMaskSize; /* Size of direct color green mask */
|
||||
UCHAR ucGreenFieldPosition; /* Bit posn of lsb of green mask */
|
||||
UCHAR ucBlueMaskSize; /* Size of direct color blue mask */
|
||||
UCHAR ucBlueFieldPosition; /* Bit posn of lsb of blue mask */
|
||||
UCHAR ucRsvdMaskSize; /* Size of direct color res mask */
|
||||
UCHAR ucRsvdFieldPosition; /* Bit posn of lsb of res mask */
|
||||
UCHAR ucDirectColorModeInfo; /* Direct color mode attributes */
|
||||
/* VESA 2.0 variables */
|
||||
DWORD dwPhysBasePtr; /* physical address for flat frame buffer */
|
||||
UCHAR ucReserved2[212]; /* Pad to 256 byte block size */
|
||||
} VESA_MODE_INFO;
|
||||
|
||||
#pragma pack()
|
||||
BIN
DOS/LOADCEPC/video.obj
Normal file
BIN
DOS/LOADCEPC/video.obj
Normal file
Binary file not shown.
19
DOS/LOADCEPC/wdm.h
Normal file
19
DOS/LOADCEPC/wdm.h
Normal file
@ -0,0 +1,19 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
int __cdecl _inp(unsigned);
|
||||
int __cdecl _outp(unsigned, int);
|
||||
|
||||
#pragma intrinsic(_inp, _outp)
|
||||
|
||||
#define READ_PORT_UCHAR(a) _inp((unsigned)a)
|
||||
#define WRITE_PORT_UCHAR(a, b) _outp((unsigned)a, (int)b)
|
||||
42
DOS/LOADCEPC/windows.h
Normal file
42
DOS/LOADCEPC/windows.h
Normal file
@ -0,0 +1,42 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct _CRITICAL_SECTION
|
||||
{
|
||||
int iDummy;
|
||||
} CRITICAL_SECTION, *LPCRITICAL_SECTION;
|
||||
|
||||
typedef unsigned long DWORD, *LPDWORD;
|
||||
typedef unsigned long BOOL;
|
||||
typedef char CHAR;
|
||||
typedef unsigned char BYTE, *LPBYTE, UCHAR, *PUCHAR;
|
||||
typedef unsigned short USHORT, *PUSHORT;
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
#define TEXT
|
||||
#define VOID void
|
||||
#define WCHAR char
|
||||
#define TCHAR char
|
||||
#define PTCHAR char *
|
||||
|
||||
#define strlenW strlen
|
||||
|
||||
#define OutputDebugString printf
|
||||
#define NKDbgPrintfW printf
|
||||
|
||||
#define EnterCriticalSection(a)
|
||||
#define LeaveCriticalSection(a)
|
||||
419
DOS/LOADCEPC/xmsapi.c
Normal file
419
DOS/LOADCEPC/xmsapi.c
Normal file
@ -0,0 +1,419 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
/*++
|
||||
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|
||||
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
||||
PARTICULAR PURPOSE.
|
||||
|
||||
Module Name:
|
||||
|
||||
Abstract:
|
||||
|
||||
Functions:
|
||||
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
#include "xmsapi.h"
|
||||
|
||||
#pragma warning(disable:4704)
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct _EXTENDED_MEMORY_MOVE
|
||||
{
|
||||
unsigned long ulLength;
|
||||
unsigned int uiSourceHandle;
|
||||
unsigned long ulSourceOffset;
|
||||
unsigned int uiDestinationHandle;
|
||||
unsigned long ulDestinationOffset;
|
||||
|
||||
} EXTENDED_MEMORY_MOVE, *PEXTENDED_MEMORY_MOVE;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
int (far * XMSControl)() = 0;
|
||||
|
||||
struct
|
||||
{
|
||||
int iErrorCode;
|
||||
char * pszErrorString;
|
||||
}
|
||||
XmsErrorMessages[] =
|
||||
{
|
||||
{ XMS_SUCCESS, "Success" },
|
||||
|
||||
{ XMS_E_NOT_IMPLEMENTED, "Not implemented" },
|
||||
{ XMS_E_VDISK_DETECTED, "VDISK detected" },
|
||||
{ XMS_E_A20_ERROR, "A20 error" },
|
||||
|
||||
{ XMS_W_NO_HMA, "No HMA" },
|
||||
{ XMS_W_HMA_IN_USE, "HMA in use" },
|
||||
{ XMS_W_HMA_DENIED, "HMA denied" },
|
||||
{ XMS_W_HMA_NOT_ALLOCATED, "HMA not allocated" },
|
||||
{ XMS_W_A20_STILL_ENABLED, "A20 still enabled" },
|
||||
|
||||
{ XMS_S_NO_FREE_EXTENDED_MEMORY, "No free extended memory" },
|
||||
{ XMS_S_NO_FREE_HANDLES, "No free handles" },
|
||||
{ XMS_S_INVALID_HANDLE, "Invalid handle" },
|
||||
{ XMS_S_INVALID_SOURCE_HANDLE, "Invalid source handle" },
|
||||
{ XMS_S_INVALID_SOURCE_OFFSET, "Invalid source offset" },
|
||||
{ XMS_S_INVALID_DESTINATION_HANDLE, "Invalid destination handle" },
|
||||
{ XMS_S_INVALID_DESTINATION_OFFSET, "Invalid destination offset" },
|
||||
{ XMS_S_INVALID_LENGTH, "Invalid length" },
|
||||
{ XMS_S_INVALID_OVERLAP, "Invalid overlap" },
|
||||
{ XMS_S_PARITY_ERROR, "Parity error" },
|
||||
{ XMS_S_BLOCK_LOCKED, "Block locked" },
|
||||
{ XMS_S_HANDLE_LOCKED, "Handle locked" },
|
||||
{ XMS_S_LOCK_COUNT_OVERFLOW, "Lock count overflow" },
|
||||
{ XMS_S_LOCK_FAILED, "Lock failed" },
|
||||
|
||||
{ XMS_I_SMALLER_UMB_AVAILABLE, "Smaller UMB available" },
|
||||
{ XMS_I_NO_UMBS_AVAILABLE, "No UMBs available" },
|
||||
{ XMS_I_INVALID_UMB_SEGMENT, "Invalid UMB segment" }
|
||||
};
|
||||
|
||||
#define N_XMS_ERROR_MESSAGES (sizeof(XmsErrorMessages) / sizeof(XmsErrorMessages[0]))
|
||||
|
||||
int
|
||||
XmsIsInstalled()
|
||||
{
|
||||
int bInstalled = 0;
|
||||
|
||||
if (XMSControl != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
_asm
|
||||
{
|
||||
mov ax,4300h ; Check if XMS is present)
|
||||
int 2Fh
|
||||
xor ah,ah
|
||||
cmp al,80h
|
||||
jne done ; Nope - no point in continuing
|
||||
|
||||
mov ax,4310h ; Get XMS entry point
|
||||
int 2Fh
|
||||
mov WORD PTR [XMSControl], bx ; Save entry point
|
||||
mov WORD PTR [XMSControl + 2], es
|
||||
|
||||
inc bInstalled ; Indicate installed
|
||||
}
|
||||
|
||||
done:
|
||||
return bInstalled;
|
||||
}
|
||||
|
||||
int
|
||||
XmsLocalEnableA20()
|
||||
{
|
||||
int xmsError = XMS_SUCCESS;
|
||||
|
||||
if (!XmsIsInstalled())
|
||||
{
|
||||
return XMS_E_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
_asm
|
||||
{
|
||||
mov ah, 05h
|
||||
call [XMSControl]
|
||||
clc
|
||||
rcr al, 1
|
||||
jc done
|
||||
|
||||
xor bh, bh
|
||||
mov xmsError, bx
|
||||
}
|
||||
|
||||
done:
|
||||
return xmsError;
|
||||
}
|
||||
|
||||
int
|
||||
XmsLocalDisableA20()
|
||||
{
|
||||
int xmsError = XMS_SUCCESS;
|
||||
|
||||
if (!XmsIsInstalled())
|
||||
{
|
||||
return XMS_E_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
_asm
|
||||
{
|
||||
mov ah, 06h
|
||||
call [XMSControl]
|
||||
clc
|
||||
rcr al, 1
|
||||
jc done
|
||||
|
||||
xor bh, bh
|
||||
mov xmsError, bx
|
||||
}
|
||||
|
||||
done:
|
||||
return xmsError;
|
||||
}
|
||||
|
||||
int
|
||||
XmsQueryA20(
|
||||
int *pbEnabled)
|
||||
{
|
||||
int xmsError = XMS_SUCCESS;
|
||||
|
||||
if (!XmsIsInstalled())
|
||||
{
|
||||
return XMS_E_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
_asm
|
||||
{
|
||||
mov ah, 07h
|
||||
call [XMSControl]
|
||||
|
||||
push si
|
||||
mov si, pbEnabled
|
||||
mov WORD PTR [si], ax
|
||||
pop si
|
||||
|
||||
xor bh, bh
|
||||
mov xmsError, bx
|
||||
}
|
||||
|
||||
return xmsError;
|
||||
}
|
||||
|
||||
int
|
||||
XmsQueryFreeExtendedMemory(
|
||||
unsigned int *puiLargestFreeBlock,
|
||||
unsigned int *puiTotalFree)
|
||||
{
|
||||
int xmsError = XMS_SUCCESS;
|
||||
|
||||
if (!XmsIsInstalled())
|
||||
{
|
||||
return XMS_E_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
_asm
|
||||
{
|
||||
mov ah, 08h
|
||||
call [XMSControl]
|
||||
|
||||
push si
|
||||
mov si, puiLargestFreeBlock
|
||||
mov WORD PTR [si], ax
|
||||
|
||||
mov si, puiTotalFree
|
||||
mov WORD PTR [si], dx
|
||||
pop si
|
||||
|
||||
xor bh, bh
|
||||
mov xmsError, bx
|
||||
}
|
||||
|
||||
return xmsError;
|
||||
}
|
||||
|
||||
int
|
||||
XmsAllocateExtendedMemory(
|
||||
unsigned int uiBlockSizeK,
|
||||
unsigned int * puiBlockHandle)
|
||||
{
|
||||
int xmsError = XMS_SUCCESS;
|
||||
|
||||
if (!XmsIsInstalled())
|
||||
{
|
||||
return XMS_E_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
_asm
|
||||
{
|
||||
mov ah, 09h
|
||||
mov dx, uiBlockSizeK
|
||||
call [XMSControl]
|
||||
|
||||
push si
|
||||
mov si, puiBlockHandle
|
||||
mov WORD PTR [si], dx
|
||||
pop si
|
||||
|
||||
clc
|
||||
rcr al, 1
|
||||
jc done
|
||||
|
||||
xor bh, bh
|
||||
mov xmsError, bx
|
||||
}
|
||||
|
||||
done:
|
||||
return xmsError;
|
||||
}
|
||||
|
||||
int
|
||||
XmsFreeExtendedMemory(
|
||||
unsigned int uiBlockHandle)
|
||||
{
|
||||
int xmsError = XMS_SUCCESS;
|
||||
|
||||
if (!XmsIsInstalled())
|
||||
{
|
||||
return XMS_E_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
_asm
|
||||
{
|
||||
mov ah, 0Ah
|
||||
mov dx, uiBlockHandle
|
||||
call [XMSControl]
|
||||
|
||||
clc
|
||||
rcr al, 1
|
||||
jc done
|
||||
|
||||
xor bh, bh
|
||||
mov xmsError, bx
|
||||
}
|
||||
|
||||
done:
|
||||
return xmsError;
|
||||
}
|
||||
|
||||
int
|
||||
XmsMoveExtendedMemory(
|
||||
unsigned int uiSourceHandle,
|
||||
unsigned long ulSourceOffset,
|
||||
unsigned int uiDestinationHandle,
|
||||
unsigned long ulDestinationOffset,
|
||||
unsigned long ulLength)
|
||||
{
|
||||
EXTENDED_MEMORY_MOVE moveInfo;
|
||||
|
||||
int xmsError = XMS_SUCCESS;
|
||||
|
||||
if (!XmsIsInstalled())
|
||||
{
|
||||
return XMS_E_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
moveInfo.uiSourceHandle = uiSourceHandle;
|
||||
moveInfo.ulSourceOffset = ulSourceOffset;
|
||||
moveInfo.uiDestinationHandle = uiDestinationHandle;
|
||||
moveInfo.ulDestinationOffset = ulDestinationOffset;
|
||||
moveInfo.ulLength = ulLength;
|
||||
|
||||
_asm
|
||||
{
|
||||
mov ah, 0Bh
|
||||
|
||||
push si
|
||||
lea si, moveInfo
|
||||
call [XMSControl]
|
||||
pop si
|
||||
|
||||
clc
|
||||
rcr al, 1
|
||||
jc done
|
||||
|
||||
xor bh, bh
|
||||
mov xmsError, bx
|
||||
}
|
||||
|
||||
done:
|
||||
return xmsError;
|
||||
}
|
||||
|
||||
int
|
||||
XmsLockExtendedMemory(
|
||||
unsigned int uiBlockHandle,
|
||||
unsigned long * pulLinearAddress)
|
||||
{
|
||||
int xmsError = XMS_SUCCESS;
|
||||
|
||||
if (!XmsIsInstalled())
|
||||
{
|
||||
return XMS_E_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
_asm
|
||||
{
|
||||
mov ah, 0Ch
|
||||
mov dx, uiBlockHandle
|
||||
call [XMSControl]
|
||||
|
||||
push si
|
||||
mov si, pulLinearAddress
|
||||
mov WORD PTR [si], bx
|
||||
mov WORD PTR [si + 2], dx
|
||||
pop si
|
||||
|
||||
clc
|
||||
rcr al, 1
|
||||
jc done
|
||||
|
||||
xor bh, bh
|
||||
mov xmsError, bx
|
||||
}
|
||||
|
||||
done:
|
||||
return xmsError;
|
||||
}
|
||||
|
||||
int
|
||||
XmsUnlockExtendedMemory(
|
||||
unsigned int uiBlockHandle)
|
||||
{
|
||||
int xmsError = XMS_SUCCESS;
|
||||
|
||||
if (!XmsIsInstalled())
|
||||
{
|
||||
return XMS_E_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
_asm
|
||||
{
|
||||
mov ah, 0Dh
|
||||
mov dx, uiBlockHandle
|
||||
call [XMSControl]
|
||||
|
||||
clc
|
||||
rcr al, 1
|
||||
jc done
|
||||
|
||||
xor bh, bh
|
||||
mov xmsError, bx
|
||||
}
|
||||
|
||||
done:
|
||||
return xmsError;
|
||||
}
|
||||
|
||||
char *XmsErrorString(int xmsError)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < N_XMS_ERROR_MESSAGES; i++)
|
||||
{
|
||||
if (XmsErrorMessages[i].iErrorCode == xmsError)
|
||||
{
|
||||
return XmsErrorMessages[i].pszErrorString;
|
||||
}
|
||||
}
|
||||
|
||||
return "Unknown error";
|
||||
}
|
||||
1083
DOS/LOADCEPC/xmsapi.cod
Normal file
1083
DOS/LOADCEPC/xmsapi.cod
Normal file
File diff suppressed because it is too large
Load Diff
74
DOS/LOADCEPC/xmsapi.h
Normal file
74
DOS/LOADCEPC/xmsapi.h
Normal file
@ -0,0 +1,74 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Use of this sample source code is subject to the terms of the Microsoft
|
||||
// license agreement under which you licensed this sample source code. If
|
||||
// you did not accept the terms of the license agreement, you are not
|
||||
// authorized to use this sample source code. For the terms of the license,
|
||||
// please see the license agreement between you and Microsoft or, if applicable,
|
||||
// see the LICENSE.RTF on your install media or the root of your tools installation.
|
||||
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
|
||||
//
|
||||
#define XMS_SUCCESS 0x00
|
||||
|
||||
#define XMS_E_NOT_IMPLEMENTED 0x80
|
||||
#define XMS_E_VDISK_DETECTED 0x81
|
||||
#define XMS_E_A20_ERROR 0x82
|
||||
|
||||
#define XMS_W_NO_HMA 0x90
|
||||
#define XMS_W_HMA_IN_USE 0x91
|
||||
#define XMS_W_HMA_DENIED 0x92
|
||||
#define XMS_W_HMA_NOT_ALLOCATED 0x93
|
||||
#define XMS_W_A20_STILL_ENABLED 0x94
|
||||
|
||||
#define XMS_S_NO_FREE_EXTENDED_MEMORY 0xA0
|
||||
#define XMS_S_NO_FREE_HANDLES 0xA1
|
||||
#define XMS_S_INVALID_HANDLE 0xA2
|
||||
#define XMS_S_INVALID_SOURCE_HANDLE 0xA3
|
||||
#define XMS_S_INVALID_SOURCE_OFFSET 0xA4
|
||||
#define XMS_S_INVALID_DESTINATION_HANDLE 0xA5
|
||||
#define XMS_S_INVALID_DESTINATION_OFFSET 0xA6
|
||||
#define XMS_S_INVALID_LENGTH 0xA7
|
||||
#define XMS_S_INVALID_OVERLAP 0xA8
|
||||
#define XMS_S_PARITY_ERROR 0xA9
|
||||
#define XMS_S_BLOCK_LOCKED 0xAA
|
||||
#define XMS_S_HANDLE_LOCKED 0xAB
|
||||
#define XMS_S_LOCK_COUNT_OVERFLOW 0xAC
|
||||
#define XMS_S_LOCK_FAILED 0xAD
|
||||
|
||||
#define XMS_I_SMALLER_UMB_AVAILABLE 0xB0
|
||||
#define XMS_I_NO_UMBS_AVAILABLE 0xB1
|
||||
#define XMS_I_INVALID_UMB_SEGMENT 0xB2
|
||||
|
||||
int XmsIsInstalled();
|
||||
|
||||
int XmsLocalEnableA20();
|
||||
|
||||
int XmsLocalDisableA20();
|
||||
|
||||
int XmsQueryA20(
|
||||
int *pbEnabled);
|
||||
|
||||
int XmsQueryFreeExtendedMemory(
|
||||
unsigned int *puiLargestFreeBlock, unsigned int *puiTotalFree);
|
||||
|
||||
int XmsAllocateExtendedMemory(
|
||||
unsigned int uiBlockSizeK, unsigned int * puiBlockHandle);
|
||||
|
||||
int XmsFreeExtendedMemory(
|
||||
unsigned int uiBlockHandle);
|
||||
|
||||
int XmsMoveExtendedMemory(
|
||||
unsigned int uiSourceHandle, unsigned long ulSourceOffset,
|
||||
unsigned int uiDestinationHandle, unsigned long ulDestinationOffset,
|
||||
unsigned long ulLength);
|
||||
|
||||
int XmsLockExtendedMemory(
|
||||
unsigned int uiBlockHandle,
|
||||
unsigned long * pulLinearAddress);
|
||||
|
||||
int XmsUnlockExtendedMemory(
|
||||
unsigned int uiBlockHandle);
|
||||
|
||||
char *XmsErrorString();
|
||||
BIN
DOS/LOADCEPC/xmsapi.obj
Normal file
BIN
DOS/LOADCEPC/xmsapi.obj
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Platforms\Win32\PlatformToolsets\v141_xp\Toolset.targets(39,5): warning MSB8051: 面向 Windows XP 的支持已被弃用,将来的 Visual Studio 版本不再提供该支持。请访问 https://go.microsoft.com/fwlink/?linkid=2023588,获取详细信息。
|
||||
正在生成代码
|
||||
0 of 260 functions ( 0.0%) were compiled, the rest were copied from previous compilation.
|
||||
0 of 263 functions ( 0.0%) were compiled, the rest were copied from previous compilation.
|
||||
0 functions were new in current compilation
|
||||
0 functions had inline decision re-evaluated but remain unchanged
|
||||
已完成代码的生成
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -25,6 +25,7 @@ void about::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialogEx::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_STATICVER, m_textver);
|
||||
DDX_Control(pDX, IDC_EDIT1, m_edit1);
|
||||
}
|
||||
|
||||
|
||||
@ -95,7 +96,16 @@ BOOL about::OnInitDialog()
|
||||
|
||||
m_textver.SetWindowText(AsciiToUnicode(buffer));
|
||||
|
||||
|
||||
m_edit1.SetWindowText( L"Name Bilibili ID\r\n"
|
||||
"351 351Workshop\r\n"
|
||||
"Inter -INTER_INIT-\r\n"
|
||||
"WinPad とある科学の手机副屏\r\n"
|
||||
"GoldApple 不务正业的金苹果\r\n"
|
||||
"DZY DZY20070614\r\n"
|
||||
"Zesa LinuxMEMZ\r\n"
|
||||
"XJBLMNP(?");
|
||||
//HWND hWndEdit1 = m_edit1.GetSafeHwnd();
|
||||
//::SendMessage(hWndEdit1, EM_LINESCROLL, 0, 3);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
|
||||
@ -25,4 +25,5 @@ public:
|
||||
virtual BOOL OnInitDialog();
|
||||
CStatic m_textver;
|
||||
afx_msg void OnStnClicked65535();
|
||||
CEdit m_edit1;
|
||||
};
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -218,6 +218,7 @@
|
||||
<ItemGroup>
|
||||
<Image Include="E:\Desktop\background - 副本 (2).bmp" />
|
||||
<Image Include="E:\Desktop\background2.bmp" />
|
||||
<Image Include="res\about.bmp" />
|
||||
<Image Include="res\background.bmp" />
|
||||
<Image Include="res\flag.bmp" />
|
||||
<Image Include="res\info.ico" />
|
||||
|
||||
@ -86,5 +86,8 @@
|
||||
<Image Include="E:\Desktop\background - 副本 (2).bmp">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
<Image Include="res\about.bmp">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@ -41,6 +41,7 @@ BEGIN_MESSAGE_MAP(Cmenu2Dlg, CDialogEx)
|
||||
ON_NOTIFY(NM_CLICK, IDC_SYSLINK1, &Cmenu2Dlg::OnNMClickSyslink1)
|
||||
ON_NOTIFY(NM_CLICK, IDC_SYSLINK2, &Cmenu2Dlg::OnNMClickSyslink2)
|
||||
ON_NOTIFY(NM_CLICK, IDC_SYSLINK3, &Cmenu2Dlg::OnNMClickSyslink3)
|
||||
ON_NOTIFY(NM_DBLCLK, IDC_TREE1, &Cmenu2Dlg::OnNMDblclkTree1)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
@ -222,3 +223,14 @@ void Cmenu2Dlg::OnNMClickSyslink3(NMHDR *pNMHDR, LRESULT *pResult)
|
||||
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Cmenu2Dlg::OnNMDblclkTree1(NMHDR *pNMHDR, LRESULT *pResult)
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
Cmenu2Dlg::OnBnClickedOk();
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
@ -41,4 +41,5 @@ public:
|
||||
afx_msg void OnNMClickSyslink1(NMHDR *pNMHDR, LRESULT *pResult);
|
||||
afx_msg void OnNMClickSyslink2(NMHDR *pNMHDR, LRESULT *pResult);
|
||||
afx_msg void OnNMClickSyslink3(NMHDR *pNMHDR, LRESULT *pResult);
|
||||
afx_msg void OnNMDblclkTree1(NMHDR *pNMHDR, LRESULT *pResult);
|
||||
};
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
BIN
WNT/menu2.exe/res/about_ori.bmp
Normal file
BIN
WNT/menu2.exe/res/about_ori.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
@ -17,6 +17,7 @@
|
||||
#define IDC_BUTTON1 1004
|
||||
#define IDC_STATIC1 1005
|
||||
#define IDC_STATICVER 1006
|
||||
#define IDC_EDIT1 1007
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
@ -24,7 +25,7 @@
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 136
|
||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||
#define _APS_NEXT_CONTROL_VALUE 1007
|
||||
#define _APS_NEXT_CONTROL_VALUE 1008
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user