mirror of
https://github.com/reactos/reactos.git
synced 2024-08-04 02:20:54 +00:00
Sync with trunk head (r48786)
svn path=/branches/reactos-yarotows/; revision=48787
This commit is contained in:
commit
2755820d64
|
@ -7,18 +7,18 @@
|
|||
</xi:fallback>
|
||||
</xi:include>
|
||||
|
||||
<xi:include href="ReactOS-generic.rbuild" />
|
||||
<xi:include href="ReactOS-generic.rbuild" />
|
||||
|
||||
<!-- <define name="_M_ARM" /> Already defined by toolchain -->
|
||||
<!-- <define name="_M_ARM" /> Already defined by toolchain -->
|
||||
<define name="_ARM_" />
|
||||
<define name="__arm__" />
|
||||
<define name="TARGET_arm" host="true" />
|
||||
|
||||
<define name="USE_COMPILER_EXCEPTIONS" />
|
||||
<define name="USE_COMPILER_EXCEPTIONS" />
|
||||
|
||||
<property name="WINEBUILD_FLAGS" value="--kill-at"/>
|
||||
<property name="WINEBUILD_FLAGS" value="--kill-at"/>
|
||||
|
||||
<include>include/reactos/arm</include>
|
||||
<include>include/reactos/arm</include>
|
||||
|
||||
<if property="SARCH" value="versatile">
|
||||
<define name="BOARD_CONFIG_VERSATILE"/>
|
||||
|
@ -29,17 +29,17 @@
|
|||
<compilerflag>-ftracer</compilerflag>
|
||||
</if>
|
||||
<compilerflag>-fms-extensions</compilerflag>
|
||||
<compilerflag>-Wno-attributes</compilerflag>
|
||||
<compilerflag>-U_UNICODE</compilerflag>
|
||||
<compilerflag>-UUNICODE</compilerflag>
|
||||
<compilerflag>-Wno-attributes</compilerflag>
|
||||
<compilerflag>-U_UNICODE</compilerflag>
|
||||
<compilerflag>-UUNICODE</compilerflag>
|
||||
</group>
|
||||
|
||||
|
||||
<define name="__MSVCRT__"/> <!-- DUBIOUS -->
|
||||
|
||||
<group linkerset="ld">
|
||||
<linkerflag>--strip-debug</linkerflag> <!-- INVESTIGATE -->
|
||||
<linkerflag>-static</linkerflag> <!-- INVESTIGATE -->
|
||||
<linkerflag>--strip-debug</linkerflag> <!-- INVESTIGATE -->
|
||||
<linkerflag>-static</linkerflag> <!-- INVESTIGATE -->
|
||||
<linkerflag>-file-alignment=0x1000</linkerflag>
|
||||
<linkerflag>-section-alignment=0x1000</linkerflag>
|
||||
</group>
|
||||
|
@ -53,7 +53,10 @@
|
|||
<directory name="drivers">
|
||||
<directory name="csq">
|
||||
<xi:include href="lib/drivers/csq/csq.rbuild" />
|
||||
</directory>
|
||||
</directory>
|
||||
</directory>
|
||||
<directory name="cportlib">
|
||||
<xi:include href="lib/cportlib/cportlib.rbuild" />
|
||||
</directory>
|
||||
<directory name="debugsup">
|
||||
<xi:include href="lib/debugsup/debugsup.rbuild" />
|
||||
|
@ -152,9 +155,9 @@
|
|||
</directory>
|
||||
<directory name="base">
|
||||
<directory name="system">
|
||||
<directory name="smss">
|
||||
<xi:include href="base/system/smss/smss.rbuild" />
|
||||
</directory>
|
||||
<directory name="smss">
|
||||
<xi:include href="base/system/smss/smss.rbuild" />
|
||||
</directory>
|
||||
</directory>
|
||||
</directory>
|
||||
</project>
|
||||
|
|
|
@ -31,6 +31,75 @@
|
|||
|
||||
#define SECTORSIZE 512
|
||||
|
||||
#include <pshpack1.h>
|
||||
typedef struct _FAT_BOOTSECTOR
|
||||
{
|
||||
UCHAR JumpBoot[3]; // Jump instruction to boot code
|
||||
CHAR OemName[8]; // "MSWIN4.1" for MS formatted volumes
|
||||
USHORT BytesPerSector; // Bytes per sector
|
||||
UCHAR SectorsPerCluster; // Number of sectors in a cluster
|
||||
USHORT ReservedSectors; // Reserved sectors, usually 1 (the bootsector)
|
||||
UCHAR NumberOfFats; // Number of FAT tables
|
||||
USHORT RootDirEntries; // Number of root directory entries (fat12/16)
|
||||
USHORT TotalSectors; // Number of total sectors on the drive, 16-bit
|
||||
UCHAR MediaDescriptor; // Media descriptor byte
|
||||
USHORT SectorsPerFat; // Sectors per FAT table (fat12/16)
|
||||
USHORT SectorsPerTrack; // Number of sectors in a track
|
||||
USHORT NumberOfHeads; // Number of heads on the disk
|
||||
ULONG HiddenSectors; // Hidden sectors (sectors before the partition start like the partition table)
|
||||
ULONG TotalSectorsBig; // This field is the new 32-bit total count of sectors on the volume
|
||||
UCHAR DriveNumber; // Int 0x13 drive number (e.g. 0x80)
|
||||
UCHAR Reserved1; // Reserved (used by Windows NT). Code that formats FAT volumes should always set this byte to 0.
|
||||
UCHAR BootSignature; // Extended boot signature (0x29). This is a signature byte that indicates that the following three fields in the boot sector are present.
|
||||
ULONG VolumeSerialNumber; // Volume serial number
|
||||
CHAR VolumeLabel[11]; // Volume label. This field matches the 11-byte volume label recorded in the root directory
|
||||
CHAR FileSystemType[8]; // One of the strings "FAT12 ", "FAT16 ", or "FAT "
|
||||
|
||||
UCHAR BootCodeAndData[448]; // The remainder of the boot sector
|
||||
|
||||
USHORT BootSectorMagic; // 0xAA55
|
||||
|
||||
} FAT_BOOTSECTOR, *PFAT_BOOTSECTOR;
|
||||
|
||||
typedef struct _FAT32_BOOTSECTOR
|
||||
{
|
||||
UCHAR JumpBoot[3]; // Jump instruction to boot code
|
||||
CHAR OemName[8]; // "MSWIN4.1" for MS formatted volumes
|
||||
USHORT BytesPerSector; // Bytes per sector
|
||||
UCHAR SectorsPerCluster; // Number of sectors in a cluster
|
||||
USHORT ReservedSectors; // Reserved sectors, usually 1 (the bootsector)
|
||||
UCHAR NumberOfFats; // Number of FAT tables
|
||||
USHORT RootDirEntries; // Number of root directory entries (fat12/16)
|
||||
USHORT TotalSectors; // Number of total sectors on the drive, 16-bit
|
||||
UCHAR MediaDescriptor; // Media descriptor byte
|
||||
USHORT SectorsPerFat; // Sectors per FAT table (fat12/16)
|
||||
USHORT SectorsPerTrack; // Number of sectors in a track
|
||||
USHORT NumberOfHeads; // Number of heads on the disk
|
||||
ULONG HiddenSectors; // Hidden sectors (sectors before the partition start like the partition table)
|
||||
ULONG TotalSectorsBig; // This field is the new 32-bit total count of sectors on the volume
|
||||
ULONG SectorsPerFatBig; // This field is the FAT32 32-bit count of sectors occupied by ONE FAT. BPB_FATSz16 must be 0
|
||||
USHORT ExtendedFlags; // Extended flags (fat32)
|
||||
USHORT FileSystemVersion; // File system version (fat32)
|
||||
ULONG RootDirStartCluster; // Starting cluster of the root directory (fat32)
|
||||
USHORT FsInfo; // Sector number of FSINFO structure in the reserved area of the FAT32 volume. Usually 1.
|
||||
USHORT BackupBootSector; // If non-zero, indicates the sector number in the reserved area of the volume of a copy of the boot record. Usually 6.
|
||||
UCHAR Reserved[12]; // Reserved for future expansion
|
||||
UCHAR DriveNumber; // Int 0x13 drive number (e.g. 0x80)
|
||||
UCHAR Reserved1; // Reserved (used by Windows NT). Code that formats FAT volumes should always set this byte to 0.
|
||||
UCHAR BootSignature; // Extended boot signature (0x29). This is a signature byte that indicates that the following three fields in the boot sector are present.
|
||||
ULONG VolumeSerialNumber; // Volume serial number
|
||||
CHAR VolumeLabel[11]; // Volume label. This field matches the 11-byte volume label recorded in the root directory
|
||||
CHAR FileSystemType[8]; // Always set to the string "FAT32 "
|
||||
|
||||
UCHAR BootCodeAndData[420]; // The remainder of the boot sector
|
||||
|
||||
USHORT BootSectorMagic; // 0xAA55
|
||||
|
||||
} FAT32_BOOTSECTOR, *PFAT32_BOOTSECTOR;
|
||||
#include <poppack.h>
|
||||
|
||||
extern PPARTLIST PartitionList;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
||||
|
@ -1094,53 +1163,53 @@ NTSTATUS
|
|||
InstallMbrBootCodeToDisk (PWSTR SrcPath,
|
||||
PWSTR RootPath)
|
||||
{
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
UNICODE_STRING Name;
|
||||
HANDLE FileHandle;
|
||||
NTSTATUS Status;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
UNICODE_STRING Name;
|
||||
HANDLE FileHandle;
|
||||
NTSTATUS Status;
|
||||
PPARTITION_SECTOR OrigBootSector;
|
||||
PPARTITION_SECTOR NewBootSector;
|
||||
|
||||
/* Allocate buffer for original bootsector */
|
||||
/* Allocate buffer for original bootsector */
|
||||
OrigBootSector = (PPARTITION_SECTOR)RtlAllocateHeap(ProcessHeap,
|
||||
0,
|
||||
sizeof(PARTITION_SECTOR));
|
||||
if (OrigBootSector == NULL)
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
|
||||
/* Read current boot sector into buffer */
|
||||
/* Read current boot sector into buffer */
|
||||
RtlInitUnicodeString(&Name,
|
||||
RootPath);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&Name,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&Name,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtOpenFile(&FileHandle,
|
||||
GENERIC_READ,
|
||||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
0,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||
Status = NtOpenFile(&FileHandle,
|
||||
GENERIC_READ,
|
||||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
0,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
Status = NtReadFile(FileHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatusBlock,
|
||||
Status = NtReadFile(FileHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatusBlock,
|
||||
OrigBootSector,
|
||||
SECTORSIZE,
|
||||
NULL,
|
||||
NULL);
|
||||
NtClose(FileHandle);
|
||||
SECTORSIZE,
|
||||
NULL,
|
||||
NULL);
|
||||
NtClose(FileHandle);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
|
||||
|
@ -1256,11 +1325,12 @@ InstallFat16BootCodeToDisk(PWSTR SrcPath,
|
|||
UNICODE_STRING Name;
|
||||
HANDLE FileHandle;
|
||||
NTSTATUS Status;
|
||||
PUCHAR OrigBootSector;
|
||||
PUCHAR NewBootSector;
|
||||
PFAT_BOOTSECTOR OrigBootSector;
|
||||
PFAT_BOOTSECTOR NewBootSector;
|
||||
PARTITION_INFORMATION *PartInfo;
|
||||
|
||||
/* Allocate buffer for original bootsector */
|
||||
OrigBootSector = (PUCHAR)RtlAllocateHeap(ProcessHeap,
|
||||
OrigBootSector = RtlAllocateHeap(ProcessHeap,
|
||||
0,
|
||||
SECTORSIZE);
|
||||
if (OrigBootSector == NULL)
|
||||
|
@ -1306,7 +1376,7 @@ InstallFat16BootCodeToDisk(PWSTR SrcPath,
|
|||
|
||||
|
||||
/* Allocate buffer for new bootsector */
|
||||
NewBootSector = (PUCHAR)RtlAllocateHeap(ProcessHeap,
|
||||
NewBootSector = RtlAllocateHeap(ProcessHeap,
|
||||
0,
|
||||
SECTORSIZE);
|
||||
if (NewBootSector == NULL)
|
||||
|
@ -1356,9 +1426,12 @@ InstallFat16BootCodeToDisk(PWSTR SrcPath,
|
|||
}
|
||||
|
||||
/* Adjust bootsector (copy a part of the FAT16 BPB) */
|
||||
memcpy((NewBootSector + 3),
|
||||
(OrigBootSector + 3),
|
||||
59); /* FAT16 BPB length*/
|
||||
memcpy(&NewBootSector->BytesPerSector,
|
||||
&OrigBootSector->BytesPerSector,
|
||||
51); /* FAT16 BPB length */
|
||||
|
||||
PartInfo = &PartitionList->CurrentPartition->PartInfo[PartitionList->CurrentPartitionNumber];
|
||||
NewBootSector->HiddenSectors = PartInfo->HiddenSectors;
|
||||
|
||||
/* Free the original boot sector */
|
||||
RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
|
||||
|
@ -1416,13 +1489,14 @@ InstallFat32BootCodeToDisk(PWSTR SrcPath,
|
|||
UNICODE_STRING Name;
|
||||
HANDLE FileHandle;
|
||||
NTSTATUS Status;
|
||||
PUCHAR OrigBootSector;
|
||||
PUCHAR NewBootSector;
|
||||
PFAT32_BOOTSECTOR OrigBootSector;
|
||||
PFAT32_BOOTSECTOR NewBootSector;
|
||||
LARGE_INTEGER FileOffset;
|
||||
USHORT BackupBootSector;
|
||||
PARTITION_INFORMATION *PartInfo;
|
||||
|
||||
/* Allocate buffer for original bootsector */
|
||||
OrigBootSector = (PUCHAR)RtlAllocateHeap(ProcessHeap,
|
||||
OrigBootSector = RtlAllocateHeap(ProcessHeap,
|
||||
0,
|
||||
SECTORSIZE);
|
||||
if (OrigBootSector == NULL)
|
||||
|
@ -1468,7 +1542,7 @@ InstallFat32BootCodeToDisk(PWSTR SrcPath,
|
|||
|
||||
|
||||
/* Allocate buffer for new bootsector (2 sectors) */
|
||||
NewBootSector = (PUCHAR)RtlAllocateHeap(ProcessHeap,
|
||||
NewBootSector = RtlAllocateHeap(ProcessHeap,
|
||||
0,
|
||||
2 * SECTORSIZE);
|
||||
if (NewBootSector == NULL)
|
||||
|
@ -1518,12 +1592,15 @@ InstallFat32BootCodeToDisk(PWSTR SrcPath,
|
|||
}
|
||||
|
||||
/* Adjust bootsector (copy a part of the FAT32 BPB) */
|
||||
memcpy((NewBootSector + 3),
|
||||
(OrigBootSector + 3),
|
||||
87); /* FAT32 BPB length */
|
||||
memcpy(&NewBootSector->BytesPerSector,
|
||||
&OrigBootSector->BytesPerSector,
|
||||
79); /* FAT32 BPB length */
|
||||
|
||||
PartInfo = &PartitionList->CurrentPartition->PartInfo[PartitionList->CurrentPartitionNumber];
|
||||
NewBootSector->HiddenSectors = PartInfo->HiddenSectors;
|
||||
|
||||
/* Get the location of the backup boot sector */
|
||||
BackupBootSector = (OrigBootSector[0x33] << 8) + OrigBootSector[0x32];
|
||||
BackupBootSector = OrigBootSector->BackupBootSector;
|
||||
|
||||
/* Free the original boot sector */
|
||||
RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
|
||||
|
@ -1599,7 +1676,7 @@ InstallFat32BootCodeToDisk(PWSTR SrcPath,
|
|||
NULL,
|
||||
NULL,
|
||||
&IoStatusBlock,
|
||||
(NewBootSector + SECTORSIZE),
|
||||
((PUCHAR)NewBootSector + SECTORSIZE),
|
||||
SECTORSIZE,
|
||||
&FileOffset,
|
||||
NULL);
|
||||
|
@ -2156,6 +2233,28 @@ InstallFatBootcodeToPartition(PUNICODE_STRING SystemRootPath,
|
|||
#endif
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
InstallVBRToPartition(PUNICODE_STRING SystemRootPath,
|
||||
PUNICODE_STRING SourceRootPath,
|
||||
PUNICODE_STRING DestinationArcPath,
|
||||
UCHAR PartitionType)
|
||||
{
|
||||
if ((PartitionType == PARTITION_FAT_12) ||
|
||||
(PartitionType == PARTITION_FAT_16) ||
|
||||
(PartitionType == PARTITION_HUGE) ||
|
||||
(PartitionType == PARTITION_XINT13) ||
|
||||
(PartitionType == PARTITION_FAT32) ||
|
||||
(PartitionType == PARTITION_FAT32_XINT13))
|
||||
{
|
||||
return InstallFatBootcodeToPartition(SystemRootPath,
|
||||
SourceRootPath,
|
||||
DestinationArcPath,
|
||||
PartitionType);
|
||||
}
|
||||
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
InstallFatBootcodeToFloppy(PUNICODE_STRING SourceRootPath,
|
||||
|
|
|
@ -78,6 +78,12 @@ InstallFatBootcodeToPartition(PUNICODE_STRING SystemRootPath,
|
|||
PUNICODE_STRING DestinationArcPath,
|
||||
UCHAR PartitionType);
|
||||
|
||||
NTSTATUS
|
||||
InstallVBRToPartition(PUNICODE_STRING SystemRootPath,
|
||||
PUNICODE_STRING SourceRootPath,
|
||||
PUNICODE_STRING DestinationArcPath,
|
||||
UCHAR PartitionType);
|
||||
|
||||
NTSTATUS
|
||||
InstallFatBootcodeToFloppy(PUNICODE_STRING SourceRootPath,
|
||||
PUNICODE_STRING DestinationArcPath);
|
||||
|
|
|
@ -51,11 +51,10 @@ WCHAR DefaultLanguage[20];
|
|||
WCHAR DefaultKBLayout[20];
|
||||
BOOLEAN RepairUpdateFlag = FALSE;
|
||||
HANDLE hPnpThread = INVALID_HANDLE_VALUE;
|
||||
PPARTLIST PartitionList = NULL;
|
||||
|
||||
/* LOCALS *******************************************************************/
|
||||
|
||||
static PPARTLIST PartitionList = NULL;
|
||||
|
||||
static PFILE_SYSTEM_LIST FileSystemList = NULL;
|
||||
|
||||
static UNICODE_STRING InstallPath;
|
||||
|
@ -1402,23 +1401,24 @@ LayoutSettingsPage(PINPUT_RECORD Ir)
|
|||
static BOOL
|
||||
IsDiskSizeValid(PPARTENTRY PartEntry)
|
||||
{
|
||||
ULONGLONG m;
|
||||
ULONGLONG m1, m2;
|
||||
|
||||
/* check for unpartitioned space */
|
||||
m = PartEntry->UnpartitionedLength;
|
||||
m = (m + (1 << 19)) >> 20; /* in MBytes (rounded) */
|
||||
if( m > RequiredPartitionDiskSpace)
|
||||
m1 = PartEntry->UnpartitionedLength;
|
||||
m1 = (m1 + (1 << 19)) >> 20; /* in MBytes (rounded) */
|
||||
|
||||
if( m1 > RequiredPartitionDiskSpace)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* check for partitioned space */
|
||||
m = PartEntry->PartInfo[0].PartitionLength.QuadPart;
|
||||
m = (m + (1 << 19)) >> 20; /* in MBytes (rounded) */
|
||||
if (m < RequiredPartitionDiskSpace)
|
||||
m2 = PartEntry->PartInfo[0].PartitionLength.QuadPart;
|
||||
m2 = (m2 + (1 << 19)) >> 20; /* in MBytes (rounded) */
|
||||
if (m2 < RequiredPartitionDiskSpace)
|
||||
{
|
||||
/* partition is too small so ask for another partion */
|
||||
DPRINT1("Partition is too small, required disk space is %lu MB\n", RequiredPartitionDiskSpace);
|
||||
DPRINT1("Partition is too small(unpartitioned: %I64u MB, partitioned: %I64u MB), required disk space is %lu MB\n", m1, m2, RequiredPartitionDiskSpace);
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
|
@ -2450,29 +2450,6 @@ FormatPartitionPage(PINPUT_RECORD Ir)
|
|||
CheckActiveBootPartition(PartitionList);
|
||||
}
|
||||
|
||||
/* Install MBR if necessary */
|
||||
if (DiskEntry->NoMbr &&
|
||||
DiskEntry->BiosDiskNumber == 0)
|
||||
{
|
||||
wcscpy(PathBuffer, SourceRootPath.Buffer);
|
||||
wcscat(PathBuffer, L"\\loader\\dosmbr.bin");
|
||||
|
||||
DPRINT("Install MBR bootcode: %S ==> %S\n",
|
||||
PathBuffer, DestinationRootPath.Buffer);
|
||||
|
||||
/* Install MBR bootcode */
|
||||
Status = InstallMbrBootCodeToDisk(PathBuffer,
|
||||
DestinationRootPath.Buffer);
|
||||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
|
||||
Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DiskEntry->NoMbr = FALSE;
|
||||
}
|
||||
|
||||
if (wcscmp(FileSystemList->Selected->FileSystem, L"FAT") == 0)
|
||||
{
|
||||
/* FIXME: Install boot code. This is a hack! */
|
||||
|
@ -3503,7 +3480,7 @@ BootLoaderPage(PINPUT_RECORD Ir)
|
|||
/* Unattended install on hdd? */
|
||||
if (IsUnattendedSetup && UnattendMBRInstallType == 2)
|
||||
{
|
||||
return BOOT_LOADER_HARDDISK_PAGE;
|
||||
return BOOT_LOADER_HARDDISK_MBR_PAGE;
|
||||
}
|
||||
|
||||
MUIDisplayPage(BOOT_LOADER_PAGE);
|
||||
|
@ -3520,9 +3497,9 @@ BootLoaderPage(PINPUT_RECORD Ir)
|
|||
|
||||
Line++;
|
||||
if (Line<12)
|
||||
Line=14;
|
||||
Line=15;
|
||||
|
||||
if (Line>14)
|
||||
if (Line>15)
|
||||
Line=12;
|
||||
|
||||
CONSOLE_InvertTextXY(8, Line, 60, 1);
|
||||
|
@ -3534,9 +3511,9 @@ BootLoaderPage(PINPUT_RECORD Ir)
|
|||
|
||||
Line--;
|
||||
if (Line<12)
|
||||
Line=14;
|
||||
Line=15;
|
||||
|
||||
if (Line>14)
|
||||
if (Line>15)
|
||||
Line=12;
|
||||
|
||||
CONSOLE_InvertTextXY(8, Line, 60, 1);
|
||||
|
@ -3553,13 +3530,17 @@ BootLoaderPage(PINPUT_RECORD Ir)
|
|||
{
|
||||
if (Line == 12)
|
||||
{
|
||||
return BOOT_LOADER_HARDDISK_PAGE;
|
||||
return BOOT_LOADER_HARDDISK_MBR_PAGE;
|
||||
}
|
||||
else if (Line == 13)
|
||||
{
|
||||
return BOOT_LOADER_FLOPPY_PAGE;
|
||||
return BOOT_LOADER_HARDDISK_VBR_PAGE;
|
||||
}
|
||||
else if (Line == 14)
|
||||
{
|
||||
return BOOT_LOADER_FLOPPY_PAGE;
|
||||
}
|
||||
else if (Line == 15)
|
||||
{
|
||||
return SUCCESS_PAGE;
|
||||
}
|
||||
|
@ -3615,41 +3596,72 @@ BootLoaderFloppyPage(PINPUT_RECORD Ir)
|
|||
return BOOT_LOADER_FLOPPY_PAGE;
|
||||
}
|
||||
|
||||
|
||||
static PAGE_NUMBER
|
||||
BootLoaderHarddiskPage(PINPUT_RECORD Ir)
|
||||
BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir)
|
||||
{
|
||||
UCHAR PartitionType;
|
||||
NTSTATUS Status;
|
||||
|
||||
PartitionType = PartitionList->ActiveBootPartition->
|
||||
PartInfo[PartitionList->ActiveBootPartitionNumber].PartitionType;
|
||||
|
||||
Status = InstallVBRToPartition(&SystemRootPath,
|
||||
&SourceRootPath,
|
||||
&DestinationArcPath,
|
||||
PartitionType);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
MUIDisplayError(ERROR_WRITE_BOOT, Ir, POPUP_WAIT_ENTER);
|
||||
return QUIT_PAGE;
|
||||
}
|
||||
|
||||
return SUCCESS_PAGE;
|
||||
}
|
||||
|
||||
static PAGE_NUMBER
|
||||
BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir)
|
||||
{
|
||||
UCHAR PartitionType;
|
||||
NTSTATUS Status;
|
||||
WCHAR DestinationDevicePathBuffer[MAX_PATH];
|
||||
WCHAR SourceMbrPathBuffer[MAX_PATH];
|
||||
|
||||
/* Step 1: Write the VBR */
|
||||
PartitionType = PartitionList->ActiveBootPartition->
|
||||
PartInfo[PartitionList->ActiveBootPartitionNumber].PartitionType;
|
||||
if ((PartitionType == PARTITION_FAT_12) ||
|
||||
(PartitionType == PARTITION_FAT_16) ||
|
||||
(PartitionType == PARTITION_HUGE) ||
|
||||
(PartitionType == PARTITION_XINT13) ||
|
||||
(PartitionType == PARTITION_FAT32) ||
|
||||
(PartitionType == PARTITION_FAT32_XINT13))
|
||||
{
|
||||
Status = InstallFatBootcodeToPartition(&SystemRootPath,
|
||||
&SourceRootPath,
|
||||
&DestinationArcPath,
|
||||
PartitionType);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
MUIDisplayError(ERROR_INSTALL_BOOTCODE, Ir, POPUP_WAIT_ENTER);
|
||||
return QUIT_PAGE;
|
||||
}
|
||||
|
||||
return SUCCESS_PAGE;
|
||||
}
|
||||
else
|
||||
Status = InstallVBRToPartition(&SystemRootPath,
|
||||
&SourceRootPath,
|
||||
&DestinationArcPath,
|
||||
PartitionType);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
MUIDisplayError(ERROR_WRITE_BOOT, Ir, POPUP_WAIT_ENTER);
|
||||
return QUIT_PAGE;
|
||||
}
|
||||
|
||||
return BOOT_LOADER_HARDDISK_PAGE;
|
||||
/* Step 2: Write the MBR */
|
||||
swprintf(DestinationDevicePathBuffer,
|
||||
L"\\Device\\Harddisk%d\\Partition0",
|
||||
PartitionList->ActiveBootDisk->DiskNumber);
|
||||
|
||||
wcscpy(SourceMbrPathBuffer, SourceRootPath.Buffer);
|
||||
wcscat(SourceMbrPathBuffer, L"\\loader\\dosmbr.bin");
|
||||
|
||||
DPRINT("Install MBR bootcode: %S ==> %S\n",
|
||||
SourceMbrPathBuffer, DestinationDevicePathBuffer);
|
||||
|
||||
Status = InstallMbrBootCodeToDisk(SourceMbrPathBuffer,
|
||||
DestinationDevicePathBuffer);
|
||||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
|
||||
Status);
|
||||
MUIDisplayError(ERROR_INSTALL_BOOTCODE, Ir, POPUP_WAIT_ENTER);
|
||||
return QUIT_PAGE;
|
||||
}
|
||||
|
||||
return SUCCESS_PAGE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3916,8 +3928,12 @@ RunUSetup(VOID)
|
|||
Page = BootLoaderFloppyPage(&Ir);
|
||||
break;
|
||||
|
||||
case BOOT_LOADER_HARDDISK_PAGE:
|
||||
Page = BootLoaderHarddiskPage(&Ir);
|
||||
case BOOT_LOADER_HARDDISK_MBR_PAGE:
|
||||
Page = BootLoaderHarddiskMbrPage(&Ir);
|
||||
break;
|
||||
|
||||
case BOOT_LOADER_HARDDISK_VBR_PAGE:
|
||||
Page = BootLoaderHarddiskVbrPage(&Ir);
|
||||
break;
|
||||
|
||||
/* Repair pages */
|
||||
|
|
|
@ -995,18 +995,24 @@ static MUI_ENTRY bgBGBootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
"‘« £ ¥ § ०¤ η βΆκΰ¤¨ο ¤¨α<C2A8> (Ά MBR).",
|
||||
"Install bootloader on the harddisk (MBR and VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
"‘« £ ¥ § ०¤ η ¤¨α<C2A8>¥β .",
|
||||
"Install bootloader on the harddisk (VBR only).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
"‘« £ ¥ § ०¤ ç ¤¨áª¥â .",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
"„ ¥ ᥠ᫠£ § ०¤ ç.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
|
|
@ -993,18 +993,24 @@ static MUI_ENTRY csCZBootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
"Nainstalovat zavad؟ na disk (MBR).",
|
||||
"Install bootloader on the harddisk (MBR and VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
"Nainstalovat zavad؟ na disketu.",
|
||||
"Install bootloader on the harddisk (VBR only).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
"Nainstalovat zavad؟ na disketu.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
"PýeskoŸit instalaci zavadØŸe.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
|
|
@ -578,7 +578,7 @@ static MUI_ENTRY deDEFlushPageEntries[] =
|
|||
{
|
||||
10,
|
||||
9,
|
||||
"Der PC wird automatisch neunstarten, wenn der Vorgang beendet ist.",
|
||||
"Der PC wird automatisch neustarten, wenn der Vorgang beendet ist.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
|
@ -986,18 +986,24 @@ static MUI_ENTRY deDEBootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
"Boot-Loader auf der Festplatte installieren (Bootsektor).",
|
||||
"Boot-Loader auf der Festplatte installieren (MBR und VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
"Boot-Loader auf einer Diskette installieren.",
|
||||
"Boot-Loader auf der Festplatte installieren (nur VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
"Boot-Loader auf einer Diskette installieren.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
"Boot-Loader nicht installieren.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
|
|
@ -1009,18 +1009,24 @@ static MUI_ENTRY elGRBootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
"„š¡˜«á©«˜©ž «¦¬ bootloader ©«¦ ©¡¢ž¨æ ›å©¡¦ (MBR).",
|
||||
"Install bootloader on the harddisk (MBR and VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
"„š¡˜«á©«˜©ž «¦¬ bootloader ©œ £ ˜ › ©¡â«˜.",
|
||||
"Install bootloader on the harddisk (VBR only).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
"„š¡˜«á©«˜©ž «¦¬ bootloader ©œ £ ˜ › ©¡â«˜.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
"Œ˜ £ž šå¤œ œš¡˜«á©«˜©ž «¦¬ bootloader.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
|
|
@ -985,18 +985,24 @@ static MUI_ENTRY enUSBootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
"Install bootloader on the harddisk (bootsector).",
|
||||
"Install bootloader on the harddisk (MBR and VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
"Install bootloader on a floppy disk.",
|
||||
"Install bootloader on the harddisk (VBR only).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
"Install bootloader on a floppy disk.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
"Skip install bootloader.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
|
|
@ -992,18 +992,24 @@ static MUI_ENTRY esESBootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
"Instalar cargador de arranque en el disco duro (sector de boot).",
|
||||
"Install bootloader on the harddisk (MBR and VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
"Instalar cargador de inicio en un disquete.",
|
||||
"Install bootloader on the harddisk (VBR only).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
"Instalar cargador de inicio en un disquete.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
"Omitir la instalaci¢n del cargador de arranque.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
|
|
@ -985,18 +985,24 @@ static MUI_ENTRY etEEBootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
"Paigalda alglaadur kävakettale (MBR).",
|
||||
"Install bootloader on the harddisk (MBR and VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
"Paigalda alglaadur flopikettale.",
|
||||
"Install bootloader on the harddisk (VBR only).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
"Paigalda alglaadur flopikettale.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
"Žra paigalda alglaadurit.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
|
|
@ -998,18 +998,24 @@ static MUI_ENTRY frFRBootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
"Installer le chargeur de d‚marrage sur le disque dur (MBR).",
|
||||
"Installer le chargeur de d‚marrage sur le disque (MBR et VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
"Installer le chargeur de d‚marrage sur une disquette.",
|
||||
"Installer le chargeur de d‚marrage sur le disque (VBR seulement).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
"Installer le chargeur de d‚marrage sur une disquette.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
"Ne pas installer le chargeur de d‚marrage.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
@ -1090,7 +1096,7 @@ static MUI_ENTRY frFRLayoutSettingsEntries[] =
|
|||
{
|
||||
6,
|
||||
8,
|
||||
"Please select a layout to be installed by default.",
|
||||
"Veuillez s‚lectionner une disposition … installer par d‚faut.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
|
@ -1481,18 +1487,18 @@ MUI_ERROR frFRErrorEntries[] =
|
|||
},
|
||||
{
|
||||
//ERROR_ADDING_KBLAYOUTS,
|
||||
"Setup failed to add keyboard layouts to registry.\n"
|
||||
"ENTER = Reboot computer"
|
||||
"Setup n'a pas pu ajouter les dispositions de clavier au registre.\n"
|
||||
"ENTER = Red‚marrer l'ordinateur"
|
||||
},
|
||||
{
|
||||
//ERROR_UPDATE_GEOID,
|
||||
"Setup could not set the geo id.\n"
|
||||
"ENTER = Reboot computer"
|
||||
"Setup n'a pas pu d‚finir la geo id.\n"
|
||||
"ENTER = Red‚marrer l'ordinateur"
|
||||
},
|
||||
{
|
||||
//ERROR_INSUFFICIENT_DISKSPACE,
|
||||
"Not enough free space in the selected partition.\n"
|
||||
" * Press any key to continue.",
|
||||
"Pas assez d'espace libre dans la partition s‚lectionn‚e.\n"
|
||||
" * Appuyez sur n'importe quelle touche pour continuer.",
|
||||
NULL
|
||||
},
|
||||
{
|
||||
|
@ -1709,6 +1715,6 @@ MUI_STRING frFRStrings[] =
|
|||
{STRING_GB,
|
||||
"Go"},
|
||||
{STRING_ADDKBLAYOUTS,
|
||||
"Adding keyboard layouts"},
|
||||
"Ajout des dispositions clavier"},
|
||||
{0, 0}
|
||||
};
|
||||
|
|
|
@ -986,18 +986,24 @@ static MUI_ENTRY itITBootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
"Installazione del bootloader sul disco fisso (settore di avvio).",
|
||||
"Install bootloader on the harddisk (MBR and VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
"Installazione del bootloader su un disco floppy.",
|
||||
"Install bootloader on the harddisk (VBR only).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
"Installazione del bootloader su un disco floppy.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
"Salta l'installazione del bootloader.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
|
|
@ -986,18 +986,24 @@ static MUI_ENTRY jaJPBootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
"ブートローダヲ ハードディスク (ブートセクタ)ニ インストール スル。",
|
||||
"Install bootloader on the harddisk (MBR and VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
"ブートローダヲ フロッピー ディスクニ インストール スル。",
|
||||
"Install bootloader on the harddisk (VBR only).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
"ÌÞ°ÄÛ°ÀÞ¦ ÌÛ¯Ëß° ÃÞ¨½¸Æ ²Ý½Ä°Ù ½Ù¡",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
"ÌÞ°ÄÛ°ÀÞÉ ²Ý½Ä°Ù¦ ½·¯Ìß ½Ù¡",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
|
|
@ -995,18 +995,24 @@ static MUI_ENTRY ltLTBootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
"Install bootloader on the harddisk (MBR).",
|
||||
"Install bootloader on the harddisk (MBR and VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
"Install bootloader on a floppy disk.",
|
||||
"Install bootloader on the harddisk (VBR only).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
"Install bootloader on a floppy disk.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
"Skip install bootloader.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
|
|
@ -1012,18 +1012,24 @@ static MUI_ENTRY nlNLBootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
"Installeer de bootloader op de harde schijf (bootsector).",
|
||||
"Install bootloader on the harddisk (MBR and VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
"Installeer de bootloader op een floppy disk.",
|
||||
"Install bootloader on the harddisk (VBR only).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
"Installeer de bootloader op een floppy disk.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
"Installeren bootloader overslaan.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
|
|
@ -994,18 +994,24 @@ static MUI_ENTRY plPLBootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
" Wgraj bootloader na dysk twardy (MBR).",
|
||||
"Wgraj bootloader na dysk twardy (MBR i VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
" Wgraj bootloader na dyskietk©.",
|
||||
"Wgraj bootloader na dysk twardy (tylko VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
" Wgraj bootloader na dyskietk©.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
" Pomiä wgrywanie bootloadera.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
|
|
@ -986,18 +986,24 @@ static MUI_ENTRY ruRUBootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
"“αβ ®Ά<EFBFBD> ¦¥αβ<CEB1>¨© ¤¨α<C2A8> (§ £ΰ㧮ηλ© α¥<CEB1>β®ΰ).",
|
||||
"Install bootloader on the harddisk (MBR and VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
"“αβ ®Ά<EFBFBD> £¨΅<C2A8>¨© ¤¨α<C2A8>.",
|
||||
"Install bootloader on the harddisk (VBR only).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
"“áâ ®¢ª £¨¡ª¨© ¤¨áª.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
"<EFBFBD>¥ ãáâ ¢«¨¢ âì § £àã§ç¨ª.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
|
|
@ -993,18 +993,24 @@ static MUI_ENTRY skSKBootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
"Nainçtalovaś zav dzaź syst‚mu na pevně disk (zav dzacˇ sektor).",
|
||||
"Install bootloader on the harddisk (MBR and VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
"Nainçtalovaś zav dzaź syst‚mu na disketu.",
|
||||
"Install bootloader on the harddisk (VBR only).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
"Nainçtalovaœ zav dzaŸ syst‚mu na disketu.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
"PreskoŸiœ inçtal ciu zav dzaŸa syst‚mu.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
|
|
@ -986,18 +986,24 @@ static MUI_ENTRY svSEBootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
"Install bootloader on the harddisk (MBR).",
|
||||
"Install bootloader on the harddisk (MBR and VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
"Install bootloader on a floppy disk.",
|
||||
"Install bootloader on the harddisk (VBR only).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
"Install bootloader on a floppy disk.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
"Skip install bootloader.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
|
|
@ -991,18 +991,24 @@ static MUI_ENTRY ukUABootLoaderEntries[] =
|
|||
{
|
||||
8,
|
||||
12,
|
||||
"‚áâ ®¢¨â¨ bootloader ¦®àá⪨© ¤¨áª (bootsector).",
|
||||
"Install bootloader on the harddisk (MBR and VBR).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
13,
|
||||
"‚áâ ®¢¨â¨ bootloader ¤¨áª¥âã.",
|
||||
"Install bootloader on the harddisk (VBR only).",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
14,
|
||||
"‚áâ ®¢¨â¨ bootloader ¤¨áª¥âã.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
{
|
||||
8,
|
||||
15,
|
||||
"<EFBFBD>¥ ¢áâ ®¢«î¢ ⨠bootloader.",
|
||||
TEXT_STYLE_NORMAL
|
||||
},
|
||||
|
|
|
@ -701,6 +701,7 @@ AddDiskToList (HANDLE FileHandle,
|
|||
ULONG i;
|
||||
PLIST_ENTRY ListEntry;
|
||||
PBIOSDISKENTRY BiosDiskEntry;
|
||||
ULONG LayoutBufferSize;
|
||||
|
||||
Status = NtDeviceIoControlFile (FileHandle,
|
||||
NULL,
|
||||
|
@ -870,9 +871,15 @@ AddDiskToList (HANDLE FileHandle,
|
|||
|
||||
InsertAscendingList(&List->DiskListHead, DiskEntry, DISKENTRY, ListEntry, BiosDiskNumber);
|
||||
|
||||
/*
|
||||
* Allocate a buffer for 26 logical drives (2 entries each == 52)
|
||||
* plus the main partiton table (4 entries). Total 56 entries.
|
||||
*/
|
||||
LayoutBufferSize = sizeof(DRIVE_LAYOUT_INFORMATION) +
|
||||
((56 - ANYSIZE_ARRAY) * sizeof(PARTITION_INFORMATION));
|
||||
LayoutBuffer = (DRIVE_LAYOUT_INFORMATION*)RtlAllocateHeap (ProcessHeap,
|
||||
0,
|
||||
8192);
|
||||
LayoutBufferSize);
|
||||
if (LayoutBuffer == NULL)
|
||||
{
|
||||
return;
|
||||
|
@ -887,7 +894,7 @@ AddDiskToList (HANDLE FileHandle,
|
|||
NULL,
|
||||
0,
|
||||
LayoutBuffer,
|
||||
8192);
|
||||
LayoutBufferSize);
|
||||
if (NT_SUCCESS (Status))
|
||||
{
|
||||
if (LayoutBuffer->PartitionCount == 0)
|
||||
|
@ -1956,6 +1963,8 @@ CreateNewPartition (PPARTLIST List,
|
|||
PartEntry->FormatState = Unformatted;
|
||||
PartEntry->PartInfo[0].StartingOffset.QuadPart =
|
||||
PartEntry->UnpartitionedOffset + DiskEntry->TrackSize;
|
||||
PartEntry->PartInfo[0].HiddenSectors =
|
||||
PartEntry->PartInfo[0].StartingOffset.QuadPart / DiskEntry->BytesPerSector;
|
||||
PartEntry->PartInfo[0].PartitionLength.QuadPart =
|
||||
PartEntry->UnpartitionedLength - DiskEntry->TrackSize;
|
||||
PartEntry->PartInfo[0].PartitionType = PARTITION_ENTRY_UNUSED;
|
||||
|
@ -1985,6 +1994,8 @@ CreateNewPartition (PPARTLIST List,
|
|||
|
||||
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart =
|
||||
PartEntry->PartInfo[0].StartingOffset.QuadPart - DiskEntry->TrackSize;
|
||||
PrevPartEntry->PartInfo[1].HiddenSectors =
|
||||
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart / DiskEntry->BytesPerSector;
|
||||
|
||||
if (DiskEntry->PartListHead.Flink == &PrevPartEntry->ListEntry)
|
||||
{
|
||||
|
@ -2011,6 +2022,8 @@ CreateNewPartition (PPARTLIST List,
|
|||
|
||||
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart =
|
||||
PartEntry->PartInfo[0].StartingOffset.QuadPart - DiskEntry->TrackSize;
|
||||
PrevPartEntry->PartInfo[1].HiddenSectors =
|
||||
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart / DiskEntry->BytesPerSector;
|
||||
|
||||
if (DiskEntry->PartListHead.Flink == &PrevPartEntry->ListEntry)
|
||||
{
|
||||
|
@ -2066,6 +2079,8 @@ CreateNewPartition (PPARTLIST List,
|
|||
NewPartEntry->FormatState = Unformatted;
|
||||
NewPartEntry->PartInfo[0].StartingOffset.QuadPart =
|
||||
PartEntry->UnpartitionedOffset + DiskEntry->TrackSize;
|
||||
NewPartEntry->PartInfo[0].HiddenSectors =
|
||||
NewPartEntry->PartInfo[0].StartingOffset.QuadPart / DiskEntry->BytesPerSector;
|
||||
NewPartEntry->PartInfo[0].PartitionLength.QuadPart =
|
||||
PartitionSize - DiskEntry->TrackSize;
|
||||
NewPartEntry->PartInfo[0].PartitionType = PARTITION_ENTRY_UNUSED;
|
||||
|
@ -2095,6 +2110,8 @@ CreateNewPartition (PPARTLIST List,
|
|||
|
||||
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart =
|
||||
NewPartEntry->PartInfo[0].StartingOffset.QuadPart - DiskEntry->TrackSize;
|
||||
PrevPartEntry->PartInfo[1].HiddenSectors =
|
||||
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart / DiskEntry->BytesPerSector;
|
||||
|
||||
if (DiskEntry->PartListHead.Flink == &PrevPartEntry->ListEntry)
|
||||
{
|
||||
|
@ -2121,6 +2138,8 @@ CreateNewPartition (PPARTLIST List,
|
|||
|
||||
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart =
|
||||
NewPartEntry->PartInfo[0].StartingOffset.QuadPart - DiskEntry->TrackSize;
|
||||
PrevPartEntry->PartInfo[1].HiddenSectors =
|
||||
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart / DiskEntry->BytesPerSector;
|
||||
|
||||
if (DiskEntry->PartListHead.Flink == &PrevPartEntry->ListEntry)
|
||||
{
|
||||
|
|
|
@ -108,7 +108,8 @@ typedef enum _PAGE_NUMBER
|
|||
REGISTRY_PAGE,
|
||||
BOOT_LOADER_PAGE,
|
||||
BOOT_LOADER_FLOPPY_PAGE,
|
||||
BOOT_LOADER_HARDDISK_PAGE,
|
||||
BOOT_LOADER_HARDDISK_MBR_PAGE,
|
||||
BOOT_LOADER_HARDDISK_VBR_PAGE,
|
||||
|
||||
REPAIR_INTRO_PAGE,
|
||||
|
||||
|
|
|
@ -80,6 +80,42 @@ ScmCreateStartEvent(PHANDLE StartEvent)
|
|||
}
|
||||
|
||||
|
||||
static VOID
|
||||
ScmWaitForLsass(VOID)
|
||||
{
|
||||
HANDLE hEvent;
|
||||
DWORD dwError;
|
||||
|
||||
hEvent = CreateEventW(NULL,
|
||||
TRUE,
|
||||
FALSE,
|
||||
L"LSA_RPC_SERVER_ACTIVE");
|
||||
if (hEvent == NULL)
|
||||
{
|
||||
dwError = GetLastError();
|
||||
DPRINT("Failed to create the notication event (Error %lu)\n", dwError);
|
||||
|
||||
if (dwError == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
hEvent = OpenEventW(SYNCHRONIZE,
|
||||
FALSE,
|
||||
L"LSA_RPC_SERVER_ACTIVE");
|
||||
if (hEvent == NULL)
|
||||
{
|
||||
DPRINT1("Could not open the notification event (Error %lu)\n", GetLastError());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DPRINT("Wait for the LSA server!\n");
|
||||
WaitForSingleObject(hEvent, INFINITE);
|
||||
DPRINT("LSA server running!\n");
|
||||
|
||||
CloseHandle(hEvent);
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
ScmNamedPipeHandleRequest(PVOID Request,
|
||||
DWORD RequestSize,
|
||||
|
@ -304,9 +340,6 @@ wWinMain(HINSTANCE hInstance,
|
|||
|
||||
DPRINT("SERVICES: Service Control Manager\n");
|
||||
|
||||
/* Acquire privileges to load drivers */
|
||||
AcquireLoadDriverPrivilege();
|
||||
|
||||
/* Create start event */
|
||||
if (!ScmCreateStartEvent(&hScmStartEvent))
|
||||
{
|
||||
|
@ -346,6 +379,12 @@ wWinMain(HINSTANCE hInstance,
|
|||
/* Register event handler (used for system shutdown) */
|
||||
SetConsoleCtrlHandler(ShutdownHandlerRoutine, TRUE);
|
||||
|
||||
/* Wait for the LSA server */
|
||||
ScmWaitForLsass();
|
||||
|
||||
/* Acquire privileges to load drivers */
|
||||
AcquireLoadDriverPrivilege();
|
||||
|
||||
/* Start auto-start services */
|
||||
ScmAutoStartServices();
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ StartLsass(VOID)
|
|||
LPCWSTR ServiceString = L"lsass.exe";
|
||||
BOOL res;
|
||||
|
||||
/* Start the service control manager (services.exe) */
|
||||
/* Start the local security authority subsystem (lsass.exe) */
|
||||
ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
|
||||
StartupInfo.cb = sizeof(StartupInfo);
|
||||
StartupInfo.lpReserved = NULL;
|
||||
|
@ -199,6 +199,43 @@ StartLsass(VOID)
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
WaitForLsass(VOID)
|
||||
{
|
||||
HANDLE hEvent;
|
||||
DWORD dwError;
|
||||
|
||||
hEvent = CreateEventW(NULL,
|
||||
TRUE,
|
||||
FALSE,
|
||||
L"LSA_RPC_SERVER_ACTIVE");
|
||||
if (hEvent == NULL)
|
||||
{
|
||||
dwError = GetLastError();
|
||||
TRACE("WL: Failed to create the notication event (Error %lu)\n", dwError);
|
||||
|
||||
if (dwError == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
hEvent = OpenEventW(SYNCHRONIZE,
|
||||
FALSE,
|
||||
L"LSA_RPC_SERVER_ACTIVE");
|
||||
if (hEvent == NULL)
|
||||
{
|
||||
ERR("WL: Could not open the notification event (Error %lu)\n", GetLastError());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TRACE("WL: Wait for the LSA server!\n");
|
||||
WaitForSingleObject(hEvent, INFINITE);
|
||||
TRACE("WL: LSA server running!\n");
|
||||
|
||||
CloseHandle(hEvent);
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
DisplayStatusMessage(
|
||||
IN PWLSESSION Session,
|
||||
|
@ -348,6 +385,10 @@ WinMain(
|
|||
|
||||
DisplayStatusMessage(WLSession, WLSession->WinlogonDesktop, IDS_REACTOSISSTARTINGUP);
|
||||
|
||||
|
||||
/* Wait for the LSA server */
|
||||
WaitForLsass();
|
||||
|
||||
#if 0
|
||||
/* Connect to NetLogon service (lsass.exe) */
|
||||
/* Real winlogon uses "Winlogon" */
|
||||
|
|
|
@ -4,10 +4,13 @@
|
|||
|
||||
.intel_syntax noprefix
|
||||
|
||||
//org 8000h
|
||||
|
||||
.text
|
||||
|
||||
.code16
|
||||
|
||||
|
||||
#define BootSectorStackTop 0x7bf2
|
||||
#define DataAreaStartHigh 0x2
|
||||
#define DataAreaStartLow 0x4
|
||||
|
@ -38,6 +41,8 @@
|
|||
#define VolumeLabel 43
|
||||
#define FileSystem 54
|
||||
|
||||
#define BootPartition 0x7dfd
|
||||
|
||||
|
||||
// This code will be stored in the first 512 bytes
|
||||
// of freeldr.sys. The first 3 bytes will be a jmp
|
||||
|
@ -46,7 +51,6 @@
|
|||
//
|
||||
// This code is loaded at 0000:8000 so we have to
|
||||
// encode a jmp instruction to jump to 0000:8200
|
||||
//.org 0x8000
|
||||
|
||||
.global _mainCRTStartup // For Mingw32 builds where the linker looks for this symbol
|
||||
_mainCRTStartup:
|
||||
|
@ -119,14 +123,14 @@ LoadFile5:
|
|||
jmp LoadFile // Load the next cluster (if any)
|
||||
|
||||
LoadFile_Done:
|
||||
mov dl, [bp+BootDrive] // Load the boot drive into DL
|
||||
mov dh, BootPartition // Load the boot partition into DH
|
||||
push word ptr 0x0000
|
||||
push word ptr 0x8000 // We will do a far return to 0000:8000h
|
||||
|
||||
// retf // Transfer control to ROSLDR
|
||||
.byte 0xcb // == retf
|
||||
mov dl,BYTE PTR [bp+BootDrive] // Load the boot drive into DL
|
||||
mov dh,[BootPartition] // Load the boot partition into DH
|
||||
|
||||
push 0 // push segment (0x0000)
|
||||
mov bx, [0x8000 + 0xA8] // load the RVA of the EntryPoint into eax
|
||||
add bx, 0x8000 // RVA -> VA and skip 3 bytes (jump to fathelper code)
|
||||
push bx // push offset
|
||||
retf // Transfer control to FreeLoader
|
||||
|
||||
// Reads the entire FAT into memory at 7000:0000
|
||||
ReadFatIntoMemory:
|
||||
|
@ -225,15 +229,7 @@ IsFat12_Done:
|
|||
|
||||
|
||||
|
||||
msgLoading:
|
||||
.ascii "Loading FreeLoader..."
|
||||
.byte 0x0d,0x0a,0
|
||||
msgLoading: .asciz "Loading FreeLoader...\r\n"
|
||||
|
||||
// times 510-($-$$) db 0 // Pad to 510 bytes
|
||||
.org 0x1fe
|
||||
.word 0x0aa55 // BootSector signature
|
||||
|
||||
|
||||
// pseudo adresses
|
||||
//.org 0x7dfd
|
||||
BootPartition:
|
||||
.org 0x1fe // Pad to 510 bytes
|
||||
.word 0x0aa55 // BootSector signature
|
||||
|
|
|
@ -1636,7 +1636,6 @@ LoadBootDeviceDriver(VOID)
|
|||
}
|
||||
|
||||
/* Add freeldr.sys to list of loaded executables */
|
||||
RtlZeroMemory(FreeldrDTE, sizeof(LDR_DATA_TABLE_ENTRY));
|
||||
Status = WinLdrAllocateDataTableEntry(&LoaderBlock, "scsiport.sys",
|
||||
"FREELDR.SYS", &ImageDosHeader, &FreeldrDTE);
|
||||
if (!Status)
|
||||
|
|
|
@ -32,5 +32,6 @@
|
|||
<library>cmlib</library>
|
||||
<library>rtl</library>
|
||||
<library>libcntpr</library>
|
||||
<library>cportlib</library>
|
||||
</module>
|
||||
</ifnot>
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
<file>winldr.c</file>
|
||||
<file>wlmemory.c</file>
|
||||
<file>wlregistry.c</file>
|
||||
<file>headless.c</file>
|
||||
</directory>
|
||||
<file>freeldr.c</file>
|
||||
<file>debug.c</file>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<library>setupldr_main</library>
|
||||
<library>rossym</library>
|
||||
<library>cmlib</library>
|
||||
<library>cportlib</library>
|
||||
<library>rtl</library>
|
||||
<library>libcntpr</library>
|
||||
</module>
|
||||
|
|
311
boot/freeldr/freeldr/windows/headless.c
Normal file
311
boot/freeldr/freeldr/windows/headless.c
Normal file
|
@ -0,0 +1,311 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Boot Loader
|
||||
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
||||
* FILE: boot/freeldr/windows/headless.c
|
||||
* PURPOSE: Provides support for Windows Emergency Management Services
|
||||
* PROGRAMMERS: ReactOS Portable Systems Group
|
||||
*/
|
||||
|
||||
/* INCLUDES *******************************************************************/
|
||||
|
||||
#include <freeldr.h>
|
||||
#include <cportlib/cportlib.h>
|
||||
|
||||
/* Note: Move these to some smbios.h header */
|
||||
#define SYSID_TYPE_UUID "_UUID_"
|
||||
#define SYSID_UUID_DATA_SIZE 16
|
||||
#include <pshpack1.h>
|
||||
typedef struct _SYSID_UUID_ENTRY
|
||||
{
|
||||
UCHAR Type[6];
|
||||
UCHAR Checksum;
|
||||
USHORT Length;
|
||||
UCHAR UUID[SYSID_UUID_DATA_SIZE];
|
||||
} SYSID_UUID_ENTRY, *PSYSID_UUID_ENTRY;
|
||||
#include <poppack.h>
|
||||
|
||||
/* GLOBALS ********************************************************************/
|
||||
|
||||
HEADLESS_LOADER_BLOCK LoaderRedirectionInformation;
|
||||
BOOLEAN WinLdrTerminalConnected;
|
||||
ULONG WinLdrTerminalDeviceId;
|
||||
ULONG WinLdrTerminalDelay;
|
||||
|
||||
CPPORT Port[4] =
|
||||
{
|
||||
{NULL, 0, TRUE},
|
||||
{NULL, 0, TRUE},
|
||||
{NULL, 0, TRUE},
|
||||
{NULL, 0, TRUE}
|
||||
};
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
VOID
|
||||
WinLdrLoadGUID(OUT PGUID SystemGuid)
|
||||
{
|
||||
PSYSID_UUID_ENTRY CurrentAddress;
|
||||
|
||||
CurrentAddress = (PSYSID_UUID_ENTRY)0xE0000;
|
||||
while (CurrentAddress < (PSYSID_UUID_ENTRY)0x100000)
|
||||
{
|
||||
if (RtlCompareMemory(&CurrentAddress->Type, SYSID_TYPE_UUID, 6) == 6)
|
||||
{
|
||||
RtlCopyMemory(SystemGuid, &CurrentAddress->UUID, SYSID_UUID_DATA_SIZE);
|
||||
return;
|
||||
}
|
||||
CurrentAddress = (PSYSID_UUID_ENTRY)((ULONG_PTR)CurrentAddress + 1);
|
||||
}
|
||||
|
||||
RtlZeroMemory(SystemGuid, SYSID_UUID_DATA_SIZE);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
WinLdrPortInitialize(IN ULONG BaudRate,
|
||||
IN ULONG PortNumber,
|
||||
IN PUCHAR PortAddress,
|
||||
IN BOOLEAN TerminalConnected,
|
||||
OUT PULONG PortId)
|
||||
{
|
||||
/* Set default baud rate */
|
||||
if (BaudRate == 0) BaudRate = 19200;
|
||||
|
||||
/* Check if port or address given */
|
||||
if (PortNumber)
|
||||
{
|
||||
/* Pick correct address for port */
|
||||
if (!PortAddress)
|
||||
{
|
||||
switch (PortNumber)
|
||||
{
|
||||
case 1:
|
||||
PortAddress = (PUCHAR)0x3F8;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
PortAddress = (PUCHAR)0x2F8;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
PortAddress = (PUCHAR)0x3E8;
|
||||
break;
|
||||
|
||||
default:
|
||||
PortNumber = 4;
|
||||
PortAddress = (PUCHAR)0x2E8;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Pick correct port for address */
|
||||
PortAddress = (PUCHAR)0x2F8;
|
||||
if (CpDoesPortExist(PortAddress))
|
||||
{
|
||||
PortNumber = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
PortAddress = (PUCHAR)0x3F8;
|
||||
if (!CpDoesPortExist(PortAddress)) return FALSE;
|
||||
PortNumber = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Not yet supported */
|
||||
ASSERT(LoaderRedirectionInformation.IsMMIODevice == FALSE);
|
||||
|
||||
/* Check if port exists */
|
||||
if ((CpDoesPortExist(PortAddress)) || (CpDoesPortExist(PortAddress)))
|
||||
{
|
||||
/* Initialize port for first time, or re-initialize if specified */
|
||||
if (((TerminalConnected) && (Port[PortNumber - 1].Address)) ||
|
||||
!(Port[PortNumber - 1].Address))
|
||||
{
|
||||
/* Initialize the port, return it */
|
||||
CpInitialize(&Port[PortNumber - 1], PortAddress, BaudRate);
|
||||
*PortId = PortNumber - 1;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
VOID
|
||||
WinLdrPortPutByte(IN ULONG PortId,
|
||||
IN UCHAR Data)
|
||||
{
|
||||
CpPutByte(&Port[PortId], Data);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
WinLdrPortGetByte(IN ULONG PortId,
|
||||
OUT PUCHAR Data)
|
||||
{
|
||||
return CpGetByte(&Port[PortId], Data, TRUE, FALSE) == CP_GET_SUCCESS;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
WinLdrPortPollOnly(IN ULONG PortId)
|
||||
{
|
||||
UCHAR Dummy;
|
||||
|
||||
return CpGetByte(&Port[PortId], &Dummy, FALSE, TRUE) == CP_GET_SUCCESS;
|
||||
}
|
||||
|
||||
VOID
|
||||
WinLdrEnableFifo(IN ULONG PortId,
|
||||
IN BOOLEAN Enable)
|
||||
{
|
||||
CpEnableFifo(Port[PortId].Address, Enable);
|
||||
}
|
||||
|
||||
VOID
|
||||
WinLdrInitializeHeadlessPort(VOID)
|
||||
{
|
||||
ULONG PortNumber, BaudRate;
|
||||
PUCHAR PortAddress;
|
||||
PCHAR AnsiReset = "\x1B[m";
|
||||
ULONG i;
|
||||
|
||||
PortNumber = LoaderRedirectionInformation.PortNumber;
|
||||
PortAddress = LoaderRedirectionInformation.PortAddress;
|
||||
BaudRate = LoaderRedirectionInformation.BaudRate;
|
||||
|
||||
/* Pick a port address */
|
||||
if (PortNumber)
|
||||
{
|
||||
if (!PortAddress)
|
||||
{
|
||||
switch (PortNumber)
|
||||
{
|
||||
case 2:
|
||||
LoaderRedirectionInformation.PortAddress = (PUCHAR)0x2F8;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
LoaderRedirectionInformation.PortAddress = (PUCHAR)0x3E8;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
LoaderRedirectionInformation.PortAddress = (PUCHAR)0x2E8;
|
||||
break;
|
||||
|
||||
default:
|
||||
LoaderRedirectionInformation.PortAddress = (PUCHAR)0x3F8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No number, so no EMS */
|
||||
WinLdrTerminalConnected = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Call arch code to initialize the port */
|
||||
PortAddress = LoaderRedirectionInformation.PortAddress;
|
||||
WinLdrTerminalConnected = WinLdrPortInitialize(
|
||||
BaudRate,
|
||||
PortNumber,
|
||||
PortAddress,
|
||||
WinLdrTerminalConnected,
|
||||
&WinLdrTerminalDeviceId);
|
||||
|
||||
if (WinLdrTerminalConnected)
|
||||
{
|
||||
/* Port seems usable, set it up and get the BIOS GUID */
|
||||
WinLdrEnableFifo(WinLdrTerminalDeviceId, TRUE);
|
||||
|
||||
WinLdrLoadGUID(&LoaderRedirectionInformation.SystemGUID);
|
||||
|
||||
/* Calculate delay in us based on the baud, assume 9600 if none given */
|
||||
if (!BaudRate)
|
||||
{
|
||||
BaudRate = 9600;
|
||||
LoaderRedirectionInformation.BaudRate = BaudRate;
|
||||
}
|
||||
|
||||
WinLdrTerminalDelay = (10 * 1000 * 1000) / (BaudRate / 10) / 6;
|
||||
|
||||
/* Sent an ANSI reset sequence to get the terminal up and running */
|
||||
for (i = 0; i < strlen(AnsiReset); i++)
|
||||
{
|
||||
WinLdrPortPutByte(WinLdrTerminalDeviceId, AnsiReset[i]);
|
||||
StallExecutionProcessor(WinLdrTerminalDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
WinLdrSetupEms(IN PCHAR BootOptions)
|
||||
{
|
||||
PCHAR RedirectPort;
|
||||
|
||||
/* Start fresh */
|
||||
RtlZeroMemory(&LoaderRedirectionInformation, sizeof(HEADLESS_LOADER_BLOCK));
|
||||
|
||||
/* Use a direction port if one was given, or use ACPI to detect one instead */
|
||||
RedirectPort = strstr(BootOptions, "/redirect=");
|
||||
|
||||
if (RedirectPort)
|
||||
{
|
||||
RedirectPort = strstr(RedirectPort, "com");
|
||||
if (RedirectPort)
|
||||
{
|
||||
RedirectPort += sizeof("com") - 1;
|
||||
LoaderRedirectionInformation.PortNumber = atoi(RedirectPort);
|
||||
}
|
||||
else
|
||||
{
|
||||
RedirectPort = strstr(RedirectPort, "usebiossettings");
|
||||
if (RedirectPort)
|
||||
{
|
||||
UiDrawStatusText("ACPI SRT Table Not Supported...");
|
||||
}
|
||||
else
|
||||
{
|
||||
LoaderRedirectionInformation.PortAddress = (PUCHAR)strtoul(RedirectPort, 0, 16);
|
||||
if (LoaderRedirectionInformation.PortAddress)
|
||||
{
|
||||
LoaderRedirectionInformation.PortNumber = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Use a direction baudrate if one was given */
|
||||
RedirectPort = strstr(BootOptions, "/redirectbaudrate=");
|
||||
if (RedirectPort)
|
||||
{
|
||||
if (strstr(RedirectPort, "115200"))
|
||||
{
|
||||
LoaderRedirectionInformation.BaudRate = 115200;
|
||||
}
|
||||
else if (strstr(RedirectPort, "57600"))
|
||||
{
|
||||
LoaderRedirectionInformation.BaudRate = 57600;
|
||||
}
|
||||
else if (strstr(RedirectPort, "19200"))
|
||||
{
|
||||
LoaderRedirectionInformation.BaudRate = 19200;
|
||||
}
|
||||
else
|
||||
{
|
||||
LoaderRedirectionInformation.BaudRate = 9600;
|
||||
}
|
||||
}
|
||||
|
||||
/* Enable headless support if parameters were found */
|
||||
if (LoaderRedirectionInformation.PortNumber)
|
||||
{
|
||||
if (!LoaderRedirectionInformation.BaudRate)
|
||||
{
|
||||
LoaderRedirectionInformation.BaudRate = 9600;
|
||||
}
|
||||
|
||||
WinLdrInitializeHeadlessPort();
|
||||
}
|
||||
}
|
|
@ -203,6 +203,25 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
|
|||
/* See KiRosFrldrLpbToNtLpb for details */
|
||||
Extension->AcpiTable = (PVOID)1;
|
||||
}
|
||||
|
||||
/* Set headless block pointer */
|
||||
extern HEADLESS_LOADER_BLOCK LoaderRedirectionInformation;
|
||||
extern BOOLEAN WinLdrTerminalConnected;
|
||||
if (WinLdrTerminalConnected)
|
||||
{
|
||||
Extension->HeadlessLoaderBlock = MmHeapAlloc(sizeof(HEADLESS_LOADER_BLOCK));
|
||||
if (Extension->HeadlessLoaderBlock == NULL)
|
||||
{
|
||||
UiMessageBox("Failed to allocate HLB Extension!");
|
||||
while (TRUE);
|
||||
return;
|
||||
}
|
||||
RtlCopyMemory(
|
||||
Extension->HeadlessLoaderBlock,
|
||||
&LoaderRedirectionInformation,
|
||||
sizeof(HEADLESS_LOADER_BLOCK));
|
||||
Extension->HeadlessLoaderBlock = PaToVa(Extension->HeadlessLoaderBlock);
|
||||
}
|
||||
|
||||
/* Load drivers database */
|
||||
strcpy(MiscFiles, BootPath);
|
||||
|
@ -215,6 +234,7 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
|
|||
|
||||
if (LoaderBlock->SetupLdrBlock)
|
||||
LoaderBlock->SetupLdrBlock = PaToVa(LoaderBlock->SetupLdrBlock);
|
||||
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
|
@ -513,6 +533,10 @@ LoadAndBootWindows(PCSTR OperatingSystemName,
|
|||
|
||||
/* Allocate and minimalistic-initialize LPB */
|
||||
AllocateAndInitLPB(&LoaderBlock);
|
||||
|
||||
/* Setup redirection support */
|
||||
extern void WinLdrSetupEms(IN PCHAR BootOptions);
|
||||
WinLdrSetupEms(BootOptions);
|
||||
|
||||
/* Detect hardware */
|
||||
UseRealHeap = TRUE;
|
||||
|
|
|
@ -28,7 +28,7 @@ UpdateControls(HWND hwndDlg, GLOBALS *g)
|
|||
g->ThemeAdv.Effects.bKeyboardCues = (state == BST_CHECKED) ? TRUE : FALSE;
|
||||
state = SendDlgItemMessage(hwndDlg, IDC_EFFAPPEARANCE_DRAGFULLWINDOWS, BM_GETCHECK, 0, 0);
|
||||
g->ThemeAdv.Effects.bDragFullWindows = (state == BST_CHECKED) ? TRUE : FALSE;
|
||||
|
||||
g->bHasChanged = TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,12 +105,12 @@ EffAppearanceDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
{
|
||||
case IDOK:
|
||||
SaveCurrentValues(hwndDlg, g);
|
||||
EndDialog(hwndDlg, 0);
|
||||
EndDialog(hwndDlg, IDOK);
|
||||
break;
|
||||
|
||||
case IDCANCEL:
|
||||
g->ThemeAdv = g->Theme;
|
||||
EndDialog(hwndDlg, 0);
|
||||
EndDialog(hwndDlg, IDCANCEL);
|
||||
break;
|
||||
|
||||
case IDC_EFFAPPEARANCE_ANIMATION:
|
||||
|
|
|
@ -63,6 +63,7 @@ typedef struct _PREVIEW_DATA
|
|||
HFONT hCaptionFont;
|
||||
HFONT hMenuFont;
|
||||
HFONT hMessageFont;
|
||||
HFONT hClientFont;
|
||||
|
||||
HMENU hMenu;
|
||||
|
||||
|
@ -112,6 +113,8 @@ OnCreate(HWND hwnd, PPREVIEW_DATA pPreviewData)
|
|||
{
|
||||
THEME *theme;
|
||||
|
||||
pPreviewData->hClientFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
|
||||
|
||||
/* Load and modify the menu */
|
||||
pPreviewData->hMenu = LoadMenu(hApplet, MAKEINTRESOURCE(IDR_PREVIEW_MENU));
|
||||
EnableMenuItem(pPreviewData->hMenu,
|
||||
|
@ -289,7 +292,7 @@ OnPaint(HWND hwnd, PPREVIEW_DATA pPreviewData)
|
|||
rc.left += 4;
|
||||
rc.top += 2;
|
||||
SetTextColor(hdc, theme->crColor[COLOR_WINDOWTEXT]);
|
||||
hOldFont = SelectObject(hdc, pPreviewData->hCaptionFont); /* FIXME: client text is not caption text */
|
||||
hOldFont = SelectObject(hdc, pPreviewData->hClientFont);
|
||||
DrawText(hdc, pPreviewData->lpWinTxt, -1, &rc, DT_LEFT);
|
||||
SelectObject(hdc, hOldFont);
|
||||
|
||||
|
|
|
@ -124,8 +124,7 @@ VOID LoadCurrentTheme(THEME* theme)
|
|||
theme->Effects.bTooltipFade = theme->Effects.bMenuFade;
|
||||
|
||||
/* show content of windows during dragging */
|
||||
//SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, theme->Effects.bDragFullWindows, NULL, SPIF_SENDCHANGE | SPIF_UPDATEINIFILE);
|
||||
SystemParametersInfoW(SPI_GETDRAGFULLWINDOWS, 0, &theme->Effects.bDragFullWindows, 0);
|
||||
SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, &theme->Effects.bDragFullWindows, 0);
|
||||
|
||||
/* "Hide underlined letters for keyboard navigation until I press the Alt key" */
|
||||
SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &theme->Effects.bKeyboardCues, 0);
|
||||
|
@ -307,7 +306,7 @@ VOID ApplyTheme(THEME* theme, INT ThemeId)
|
|||
*/
|
||||
theme->Effects.bTooltipAnimation = theme->Effects.bMenuAnimation;
|
||||
theme->Effects.bTooltipFade = theme->Effects.bMenuFade;
|
||||
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, theme->Effects.bDragFullWindows, NULL, SPIF_UPDATEINIFILE|SPIF_SENDCHANGE);
|
||||
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, theme->Effects.bDragFullWindows, (PVOID)&theme->Effects.bDragFullWindows, SPIF_SENDCHANGE | SPIF_UPDATEINIFILE);
|
||||
UPDATE_USERPREF(KEYBOARDCUES, &theme->Effects.bKeyboardCues);
|
||||
//UPDATE_USERPREF(ACTIVEWINDOWTRACKING, &theme->Effects.bActiveWindowTracking);
|
||||
//UPDATE_USERPREF(MENUANIMATION, &theme->Effects.bMenuAnimation);
|
||||
|
|
|
@ -38,7 +38,8 @@ DWORD
|
|||
WINAPI
|
||||
BatteryClassCoInstaller(IN DI_FUNCTION InstallFunction,
|
||||
IN HDEVINFO DeviceInfoSet,
|
||||
IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
|
||||
IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
|
||||
IN OUT PCOINSTALLER_CONTEXT_DATA Context)
|
||||
{
|
||||
switch (InstallFunction)
|
||||
{
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
@ stdcall BatteryClassCoInstaller(long ptr ptr)
|
||||
@ stdcall BatteryClassCoInstaller(long ptr ptr ptr)
|
||||
@ stdcall BatteryClassInstall(long ptr ptr)
|
||||
|
||||
|
|
|
@ -86,34 +86,36 @@ GetSystemPaletteEntries(HDC hDC,
|
|||
UINT cEntries,
|
||||
LPPALETTEENTRY ppe)
|
||||
{
|
||||
PALETTEENTRY ippe[256];
|
||||
// Make this work!
|
||||
if ((INT)cEntries < 0 ) return 0;
|
||||
PALETTEENTRY ippe[256];
|
||||
|
||||
if ( GetDeviceCaps(hDC, RASTERCAPS) & RC_PALETTE )
|
||||
return NtGdiDoPalette(hDC, iStartIndex, cEntries, ppe, GdiPalGetSystemEntries, FALSE);
|
||||
else
|
||||
{
|
||||
if (ppe)
|
||||
if ((INT)cEntries >= 0)
|
||||
{
|
||||
if (GetDeviceCaps(hDC, RASTERCAPS) & RC_PALETTE)
|
||||
{
|
||||
RtlZeroMemory( &ippe, sizeof(ippe) );
|
||||
RtlCopyMemory( &ippe, &sys_pal_template, 10 * sizeof(PALETTEENTRY) );
|
||||
RtlCopyMemory( &ippe + 246 , &sys_pal_template + 10 , 10 * sizeof(PALETTEENTRY) );
|
||||
|
||||
if (iStartIndex < 256)
|
||||
{
|
||||
UINT Index = 256 - iStartIndex;
|
||||
|
||||
if ( Index > cEntries ) Index = cEntries;
|
||||
|
||||
RtlCopyMemory( ppe,
|
||||
&ippe[iStartIndex],
|
||||
Index*sizeof(PALETTEENTRY));
|
||||
}
|
||||
return NtGdiDoPalette(hDC,
|
||||
iStartIndex,
|
||||
cEntries,
|
||||
ppe,
|
||||
GdiPalGetSystemEntries,
|
||||
FALSE);
|
||||
}
|
||||
}
|
||||
else if (ppe)
|
||||
{
|
||||
RtlCopyMemory(ippe, sys_pal_template, 10 * sizeof(PALETTEENTRY));
|
||||
RtlCopyMemory(&ippe[246], &sys_pal_template[10], 10 * sizeof(PALETTEENTRY));
|
||||
RtlZeroMemory(&ippe[10], sizeof(ippe) - 20 * sizeof(PALETTEENTRY));
|
||||
|
||||
if (iStartIndex < 256)
|
||||
{
|
||||
RtlCopyMemory(ppe,
|
||||
&ippe[iStartIndex],
|
||||
min(256 - iStartIndex, cEntries) *
|
||||
sizeof(PALETTEENTRY));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#if DBG
|
||||
static ULONG gDebugChannel = kernel32file;
|
||||
#endif
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
|
|
@ -15,7 +15,10 @@
|
|||
#include <k32.h>
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#if DBG
|
||||
static ULONG gDebugChannel = kernel32file;
|
||||
#endif
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
#include <k32.h>
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#if DBG
|
||||
static ULONG gDebugChannel = kernel32file;
|
||||
#endif
|
||||
|
||||
#define SYMLINK_FLAG_RELATIVE 1
|
||||
|
||||
|
|
|
@ -19,7 +19,10 @@
|
|||
#include <k32.h>
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#if DBG
|
||||
static ULONG gDebugChannel = kernel32file;
|
||||
#endif
|
||||
|
||||
/* GLOBAL VARIABLES **********************************************************/
|
||||
|
||||
|
|
|
@ -45,9 +45,10 @@ LsapInitLsa(VOID)
|
|||
hEvent = OpenEventW(GENERIC_WRITE,
|
||||
FALSE,
|
||||
L"LSA_RPC_SERVER_ACTIVE");
|
||||
if (hEvent != NULL)
|
||||
if (hEvent == NULL)
|
||||
{
|
||||
ERR("Could not open the notification event!");
|
||||
ERR("Could not open the notification event (Error %lu)\n", GetLastError());
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,6 +134,7 @@ typedef struct
|
|||
LPWSTR sComponent;
|
||||
volume_info volume;
|
||||
LPWSTR sLinkPath;
|
||||
LPWSTR sCurFile;
|
||||
BOOL bRunAs;
|
||||
BOOL bDirty;
|
||||
INT iIdOpen; /* id of the "Open" entry in the context menu */
|
||||
|
@ -186,6 +187,7 @@ static HRESULT ShellLink_UpdatePath(LPCWSTR sPathRel, LPCWSTR path, LPCWSTR sWor
|
|||
/* strdup on the process heap */
|
||||
static LPWSTR __inline HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str)
|
||||
{
|
||||
assert(str);
|
||||
INT len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
|
||||
LPWSTR p = HeapAlloc( heap, flags, len*sizeof (WCHAR) );
|
||||
if( !p )
|
||||
|
@ -440,12 +442,22 @@ static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFile
|
|||
IStream_Release( stm );
|
||||
|
||||
if( SUCCEEDED( r ) )
|
||||
{
|
||||
{
|
||||
if ( This->sCurFile )
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, This->sCurFile);
|
||||
}
|
||||
This->sCurFile = HeapAlloc(GetProcessHeap(), 0, (wcslen(pszFileName)+1) * sizeof(WCHAR));
|
||||
if ( This->sCurFile )
|
||||
{
|
||||
wcscpy(This->sCurFile, pszFileName);
|
||||
}
|
||||
|
||||
StartLinkProcessor( pszFileName );
|
||||
|
||||
This->bDirty = FALSE;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
DeleteFileW( pszFileName );
|
||||
WARN("Failed to create shortcut %s\n", debugstr_w(pszFileName) );
|
||||
|
@ -464,9 +476,27 @@ static HRESULT WINAPI IPersistFile_fnSaveCompleted(IPersistFile* iface, LPCOLEST
|
|||
|
||||
static HRESULT WINAPI IPersistFile_fnGetCurFile(IPersistFile* iface, LPOLESTR *ppszFileName)
|
||||
{
|
||||
IShellLinkImpl *This = impl_from_IPersistFile(iface);
|
||||
FIXME("(%p)\n",This);
|
||||
return NOERROR;
|
||||
IShellLinkImpl *This = impl_from_IPersistFile(iface);
|
||||
|
||||
*ppszFileName = NULL;
|
||||
|
||||
if ( !This->sCurFile)
|
||||
{
|
||||
/* IPersistFile::GetCurFile called before IPersistFile::Save */
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
*ppszFileName = CoTaskMemAlloc((wcslen(This->sCurFile)+1) * sizeof(WCHAR));
|
||||
if (!*ppszFileName)
|
||||
{
|
||||
/* out of memory */
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
/* copy last saved filename */
|
||||
wcscpy(*ppszFileName, This->sCurFile);
|
||||
|
||||
return NOERROR;
|
||||
}
|
||||
|
||||
static const IPersistFileVtbl pfvt =
|
||||
|
@ -1355,9 +1385,6 @@ static HRESULT WINAPI IShellLinkA_fnGetPath(IShellLinkA * iface, LPSTR pszFile,
|
|||
TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n",
|
||||
This, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(This->sPath));
|
||||
|
||||
if (This->sComponent || This->sProduct)
|
||||
return S_FALSE;
|
||||
|
||||
if (cchMaxPath)
|
||||
pszFile[0] = 0;
|
||||
if (This->sPath)
|
||||
|
@ -1414,10 +1441,13 @@ static HRESULT WINAPI IShellLinkA_fnSetDescription(IShellLinkA * iface, LPCSTR p
|
|||
TRACE("(%p)->(pName=%s)\n", This, pszName);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, This->sDescription);
|
||||
This->sDescription = HEAP_strdupAtoW( GetProcessHeap(), 0, pszName);
|
||||
if ( !This->sDescription )
|
||||
return E_OUTOFMEMORY;
|
||||
This->sDescription = NULL;
|
||||
|
||||
if ( pszName ) {
|
||||
This->sDescription = HEAP_strdupAtoW( GetProcessHeap(), 0, pszName);
|
||||
if ( !This->sDescription )
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
This->bDirty = TRUE;
|
||||
|
||||
return S_OK;
|
||||
|
@ -1445,10 +1475,13 @@ static HRESULT WINAPI IShellLinkA_fnSetWorkingDirectory(IShellLinkA * iface, LPC
|
|||
TRACE("(%p)->(dir=%s)\n",This, pszDir);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, This->sWorkDir);
|
||||
This->sWorkDir = HEAP_strdupAtoW( GetProcessHeap(), 0, pszDir);
|
||||
if ( !This->sWorkDir )
|
||||
return E_OUTOFMEMORY;
|
||||
This->sWorkDir = NULL;
|
||||
|
||||
if ( pszDir ) {
|
||||
This->sWorkDir = HEAP_strdupAtoW( GetProcessHeap(), 0, pszDir);
|
||||
if ( !This->sWorkDir )
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
This->bDirty = TRUE;
|
||||
|
||||
return S_OK;
|
||||
|
@ -1476,9 +1509,13 @@ static HRESULT WINAPI IShellLinkA_fnSetArguments(IShellLinkA * iface, LPCSTR psz
|
|||
TRACE("(%p)->(args=%s)\n",This, pszArgs);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, This->sArgs);
|
||||
This->sArgs = HEAP_strdupAtoW( GetProcessHeap(), 0, pszArgs);
|
||||
if( !This->sArgs )
|
||||
return E_OUTOFMEMORY;
|
||||
This->sArgs = NULL;
|
||||
|
||||
if ( pszArgs ) {
|
||||
This->sArgs = HEAP_strdupAtoW( GetProcessHeap(), 0, pszArgs);
|
||||
if( !This->sArgs )
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
This->bDirty = TRUE;
|
||||
|
||||
|
@ -1611,9 +1648,13 @@ static HRESULT WINAPI IShellLinkA_fnSetIconLocation(IShellLinkA * iface, LPCSTR
|
|||
TRACE("(%p)->(path=%s iicon=%u)\n",This, pszIconPath, iIcon);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, This->sIcoPath);
|
||||
This->sIcoPath = HEAP_strdupAtoW(GetProcessHeap(), 0, pszIconPath);
|
||||
if ( !This->sIcoPath )
|
||||
return E_OUTOFMEMORY;
|
||||
This->sIcoPath = NULL;
|
||||
|
||||
if ( pszIconPath ) {
|
||||
This->sIcoPath = HEAP_strdupAtoW(GetProcessHeap(), 0, pszIconPath);
|
||||
if ( !This->sIcoPath )
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
This->iIcoNdx = iIcon;
|
||||
This->bDirty = TRUE;
|
||||
|
@ -1628,7 +1669,15 @@ static HRESULT WINAPI IShellLinkA_fnSetRelativePath(IShellLinkA * iface, LPCSTR
|
|||
TRACE("(%p)->(path=%s %x)\n",This, pszPathRel, dwReserved);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, This->sPathRel);
|
||||
This->sPathRel = HEAP_strdupAtoW(GetProcessHeap(), 0, pszPathRel);
|
||||
This->sPathRel = NULL;
|
||||
|
||||
if ( pszPathRel ) {
|
||||
This->sPathRel = HEAP_strdupAtoW(GetProcessHeap(), 0, pszPathRel);
|
||||
|
||||
if ( !This->sPathRel )
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
This->bDirty = TRUE;
|
||||
|
||||
return ShellLink_UpdatePath(This->sPathRel, This->sPath, This->sWorkDir, &This->sPath);
|
||||
|
|
|
@ -8,24 +8,28 @@
|
|||
|
||||
/* INCLUDES *******************************************************************/
|
||||
|
||||
#include <ntddk.h>
|
||||
#include <ntifs.h>
|
||||
#include <ntndk.h>
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
PCHAR NmiBegin = "NMI2NMI1";
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
NmiDbgCallback(IN PVOID Context,
|
||||
IN BOOLEAN Handled)
|
||||
{
|
||||
//
|
||||
// Let the user know we are alive
|
||||
//
|
||||
DbgPrint("NMI Callback entered! Letting the system crash...\n");
|
||||
/* Clear the NMI flag */
|
||||
((PCHAR)&KiBugCheckData[4])[3] -= NmiBegin[3];
|
||||
|
||||
//
|
||||
// Do not handle the NMI
|
||||
//
|
||||
return FALSE;
|
||||
/* Get NMI status signature */
|
||||
__indwordstring(0x80, (PULONG)NmiBegin, 1);
|
||||
((void(*)())&KiBugCheckData[4])();
|
||||
|
||||
/* Handle the NMI safely */
|
||||
KiEnableTimerWatchdog = strcmp(NmiBegin, NmiBegin + 4);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
@ -35,14 +39,10 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject,
|
|||
{
|
||||
PAGED_CODE();
|
||||
|
||||
//
|
||||
// Register NMI callback
|
||||
//
|
||||
/* Register NMI callback */
|
||||
KeRegisterNmiCallback(&NmiDbgCallback, NULL);
|
||||
|
||||
//
|
||||
// Return success
|
||||
//
|
||||
/* Return success */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -341,4 +341,60 @@ PciDebugPrintIoResReqList(IN PIO_RESOURCE_REQUIREMENTS_LIST Requirements)
|
|||
DPRINT1("\n");
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
PciDebugPrintPartialResource(IN PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialResource)
|
||||
{
|
||||
/* Dump all the data in the partial */
|
||||
DPRINT1(" Partial Resource Descriptor @0x%x\n", PartialResource);
|
||||
DPRINT1(" Type = %d (%s)\n", PartialResource->Type, PciDebugCmResourceTypeToText(PartialResource->Type));
|
||||
DPRINT1(" ShareDisposition = %d\n", PartialResource->ShareDisposition);
|
||||
DPRINT1(" Flags = 0x%04X\n", PartialResource->Flags);
|
||||
DPRINT1(" Data[%d] = %08x %08x %08x\n",
|
||||
0,
|
||||
PartialResource->u.Generic.Start.LowPart,
|
||||
PartialResource->u.Generic.Start.HighPart,
|
||||
PartialResource->u.Generic.Length);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
PciDebugPrintCmResList(IN PCM_RESOURCE_LIST PartialList)
|
||||
{
|
||||
PCM_FULL_RESOURCE_DESCRIPTOR FullDescriptor;
|
||||
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
|
||||
ULONG Count, i, ListCount;
|
||||
|
||||
/* Make sure there's something to dump */
|
||||
if (!PartialList) return;
|
||||
|
||||
/* Get the full list count */
|
||||
ListCount = PartialList->Count;
|
||||
FullDescriptor = PartialList->List;
|
||||
DPRINT1(" CM_RESOURCE_LIST (PCI Bus Driver) (List Count = %d)\n", PartialList->Count);
|
||||
|
||||
/* Loop full list */
|
||||
for (i = 0; i < ListCount; i++)
|
||||
{
|
||||
/* Loop full descriptor */
|
||||
DPRINT1(" InterfaceType %d\n", FullDescriptor->InterfaceType);
|
||||
DPRINT1(" BusNumber 0x%x\n", FullDescriptor->BusNumber);
|
||||
|
||||
/* Get partial count and loop partials */
|
||||
Count = FullDescriptor->PartialResourceList.Count;
|
||||
for (PartialDescriptor = FullDescriptor->PartialResourceList.PartialDescriptors;
|
||||
Count;
|
||||
PartialDescriptor = PciNextPartialDescriptor(PartialDescriptor))
|
||||
{
|
||||
/* Print each partial */
|
||||
PciDebugPrintPartialResource(PartialDescriptor);
|
||||
Count--;
|
||||
}
|
||||
}
|
||||
|
||||
/* Done printing data */
|
||||
DPRINT1("\n");
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -267,7 +267,8 @@ Device_GetAdditionalResourceDescriptors(IN PPCI_CONFIGURATOR_CONTEXT Context,
|
|||
|
||||
VOID
|
||||
NTAPI
|
||||
Device_ResetDevice(IN PPCI_CONFIGURATOR_CONTEXT Context)
|
||||
Device_ResetDevice(IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PPCI_COMMON_HEADER PciData)
|
||||
{
|
||||
/* Not yet implemented */
|
||||
UNIMPLEMENTED;
|
||||
|
@ -276,7 +277,8 @@ Device_ResetDevice(IN PPCI_CONFIGURATOR_CONTEXT Context)
|
|||
|
||||
VOID
|
||||
NTAPI
|
||||
Device_ChangeResourceSettings(IN PPCI_CONFIGURATOR_CONTEXT Context)
|
||||
Device_ChangeResourceSettings(IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PPCI_COMMON_HEADER PciData)
|
||||
{
|
||||
/* Not yet implemented */
|
||||
UNIMPLEMENTED;
|
||||
|
|
|
@ -49,6 +49,244 @@ PCI_CONFIGURATOR PciConfigurators[] =
|
|||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
PciComputeNewCurrentSettings(IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PCM_RESOURCE_LIST ResourceList)
|
||||
{
|
||||
PCM_PARTIAL_RESOURCE_DESCRIPTOR Partial, InterruptResource;
|
||||
PCM_PARTIAL_RESOURCE_DESCRIPTOR BaseResource, CurrentDescriptor;
|
||||
PCM_PARTIAL_RESOURCE_DESCRIPTOR PreviousDescriptor;
|
||||
CM_PARTIAL_RESOURCE_DESCRIPTOR ResourceArray[7];
|
||||
PCM_FULL_RESOURCE_DESCRIPTOR FullList;
|
||||
BOOLEAN DrainPartial, RangeChange;
|
||||
ULONG i, j;
|
||||
PPCI_FUNCTION_RESOURCES PciResources;
|
||||
PAGED_CODE();
|
||||
|
||||
/* Make sure we have either no resources, or at least one */
|
||||
ASSERT((ResourceList == NULL) || (ResourceList->Count == 1));
|
||||
|
||||
/* Initialize no partial, interrupt descriptor, or range change */
|
||||
Partial = NULL;
|
||||
InterruptResource = NULL;
|
||||
RangeChange = FALSE;
|
||||
|
||||
/* Check if there's not actually any resources */
|
||||
if (!(ResourceList) || !(ResourceList->Count))
|
||||
{
|
||||
/* Then just return the hardware update state */
|
||||
return PdoExtension->UpdateHardware;
|
||||
}
|
||||
|
||||
/* Print the new specified resource list */
|
||||
PciDebugPrintCmResList(ResourceList);
|
||||
|
||||
/* Clear the temporary resource array */
|
||||
for (i = 0; i < 7; i++) ResourceArray[i].Type = CmResourceTypeNull;
|
||||
|
||||
/* Loop the full resource descriptor */
|
||||
FullList = ResourceList->List;
|
||||
for (i = 0; i < ResourceList->Count; i++)
|
||||
{
|
||||
/* Initialize loop variables */
|
||||
DrainPartial = FALSE;
|
||||
BaseResource = NULL;
|
||||
|
||||
/* Loop the partial descriptors */
|
||||
Partial = FullList->PartialResourceList.PartialDescriptors;
|
||||
for (j = 0; j < FullList->PartialResourceList.Count; j++)
|
||||
{
|
||||
/* Check if we were supposed to drain a partial due to device data */
|
||||
if (DrainPartial)
|
||||
{
|
||||
/* Draining complete, move on to the next descriptor then */
|
||||
DrainPartial--;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check what kind of descriptor this was */
|
||||
switch (Partial->Type)
|
||||
{
|
||||
/* Base BAR resources */
|
||||
case CmResourceTypePort:
|
||||
case CmResourceTypeMemory:
|
||||
|
||||
/* Set it as the base */
|
||||
ASSERT(BaseResource == NULL);
|
||||
BaseResource = Partial;
|
||||
break;
|
||||
|
||||
/* Interrupt resource */
|
||||
case CmResourceTypeInterrupt:
|
||||
|
||||
/* Make sure it's a compatible (and the only) PCI interrupt */
|
||||
ASSERT(InterruptResource == NULL);
|
||||
ASSERT(Partial->u.Interrupt.Level == Partial->u.Interrupt.Vector);
|
||||
InterruptResource = Partial;
|
||||
|
||||
/* Only 255 interrupts on x86/x64 hardware */
|
||||
if (Partial->u.Interrupt.Level < 256)
|
||||
{
|
||||
/* Use the passed interrupt line */
|
||||
PdoExtension->AdjustedInterruptLine = Partial->u.Interrupt.Level;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Invalid vector, so ignore it */
|
||||
PdoExtension->AdjustedInterruptLine = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
/* Check for specific device data */
|
||||
case CmResourceTypeDevicePrivate:
|
||||
|
||||
/* Check what kind of data this was */
|
||||
switch (Partial->u.DevicePrivate.Data[0])
|
||||
{
|
||||
/* Not used in the driver yet */
|
||||
case 1:
|
||||
UNIMPLEMENTED;
|
||||
while (TRUE);
|
||||
break;
|
||||
|
||||
/* Not used in the driver yet */
|
||||
case 2:
|
||||
UNIMPLEMENTED;
|
||||
while (TRUE);
|
||||
break;
|
||||
|
||||
/* A drain request */
|
||||
case 3:
|
||||
/* Shouldn't be a base resource, this is a drain */
|
||||
ASSERT(BaseResource == NULL);
|
||||
DrainPartial = Partial->u.DevicePrivate.Data[1];
|
||||
ASSERT(DrainPartial == TRUE);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Move to the next descriptor */
|
||||
Partial = PciNextPartialDescriptor(Partial);
|
||||
}
|
||||
|
||||
/* We should be starting a new list now */
|
||||
ASSERT(BaseResource == NULL);
|
||||
FullList = (PVOID)Partial;
|
||||
}
|
||||
|
||||
/* Check the current assigned PCI resources */
|
||||
PciResources = PdoExtension->Resources;
|
||||
if (!PciResources) return FALSE;
|
||||
|
||||
//if... // MISSING CODE
|
||||
UNIMPLEMENTED;
|
||||
DPRINT1("Missing sanity checking code!\n");
|
||||
|
||||
/* Loop all the PCI function resources */
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
/* Get the current function resource descriptor, and the new one */
|
||||
CurrentDescriptor = &PciResources->Current[i];
|
||||
Partial = &ResourceArray[i];
|
||||
|
||||
/* Previous is current during the first loop iteration */
|
||||
PreviousDescriptor = &PciResources->Current[(i == 0) ? (0) : (i - 1)];
|
||||
|
||||
/* Check if this new descriptor is different than the old one */
|
||||
if (((Partial->Type != CurrentDescriptor->Type) ||
|
||||
(Partial->Type != CmResourceTypeNull)) &&
|
||||
((Partial->u.Generic.Start.QuadPart !=
|
||||
CurrentDescriptor->u.Generic.Start.QuadPart) ||
|
||||
(Partial->u.Generic.Length != CurrentDescriptor->u.Generic.Length)))
|
||||
{
|
||||
/* Record a change */
|
||||
RangeChange = TRUE;
|
||||
|
||||
/* Was there a range before? */
|
||||
if (CurrentDescriptor->Type != CmResourceTypeNull)
|
||||
{
|
||||
/* Print it */
|
||||
DbgPrint(" Old range-\n");
|
||||
PciDebugPrintPartialResource(CurrentDescriptor);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* There was no range */
|
||||
DbgPrint(" Previously unset range\n");
|
||||
}
|
||||
|
||||
/* Print new one */
|
||||
DbgPrint(" changed to\n");
|
||||
PciDebugPrintPartialResource(Partial);
|
||||
|
||||
/* Update to new range */
|
||||
CurrentDescriptor->Type = Partial->Type;
|
||||
PreviousDescriptor->u.Generic.Start = Partial->u.Generic.Start;
|
||||
PreviousDescriptor->u.Generic.Length = Partial->u.Generic.Length;
|
||||
CurrentDescriptor = PreviousDescriptor;
|
||||
}
|
||||
}
|
||||
|
||||
/* Either the hardware was updated, or a resource range changed */
|
||||
return ((RangeChange) || (PdoExtension->UpdateHardware));
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
PcipUpdateHardware(IN PVOID Context,
|
||||
IN PVOID Context2)
|
||||
{
|
||||
PPCI_PDO_EXTENSION PdoExtension = Context;
|
||||
PPCI_COMMON_HEADER PciData = Context2;
|
||||
|
||||
/* Check if we're allowed to disable decodes */
|
||||
PciData->Command = PdoExtension->CommandEnables;
|
||||
if (!(PdoExtension->HackFlags & PCI_HACK_PRESERVE_COMMAND))
|
||||
{
|
||||
/* Disable all decodes */
|
||||
PciData->Command &= ~(PCI_ENABLE_IO_SPACE |
|
||||
PCI_ENABLE_MEMORY_SPACE |
|
||||
PCI_ENABLE_BUS_MASTER |
|
||||
PCI_ENABLE_WRITE_AND_INVALIDATE);
|
||||
}
|
||||
|
||||
/* Update the device configuration */
|
||||
PciData->Status = 0;
|
||||
PciWriteDeviceConfig(PdoExtension, PciData, 0, PCI_COMMON_HDR_LENGTH);
|
||||
|
||||
/* Turn decodes back on */
|
||||
PciDecodeEnable(PdoExtension, TRUE, &PdoExtension->CommandEnables);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
PciUpdateHardware(IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PPCI_COMMON_HEADER PciData)
|
||||
{
|
||||
PCI_IPI_CONTEXT Context;
|
||||
|
||||
/* Check for critical devices and PCI Debugging devices */
|
||||
if ((PdoExtension->HackFlags & PCI_HACK_CRITICAL_DEVICE) ||
|
||||
(PdoExtension->OnDebugPath))
|
||||
{
|
||||
/* Build the context and send an IPI */
|
||||
Context.RunCount = 1;
|
||||
Context.Barrier = 1;
|
||||
Context.Context = PciData;
|
||||
Context.Function = PcipUpdateHardware;
|
||||
Context.DeviceExtension = PdoExtension;
|
||||
KeIpiGenericCall(PciExecuteCriticalSystemRoutine, (ULONG_PTR)&Context);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Just to the update inline */
|
||||
PcipUpdateHardware(PdoExtension, PciData);
|
||||
}
|
||||
}
|
||||
|
||||
PIO_RESOURCE_REQUIREMENTS_LIST
|
||||
NTAPI
|
||||
PciAllocateIoRequirementsList(IN ULONG Count,
|
||||
|
@ -666,8 +904,8 @@ PciApplyHacks(IN PPCI_FDO_EXTENSION DeviceExtension,
|
|||
* Controller to Native Mode" in the Storage section of the
|
||||
* Windows Driver Kit for more details.
|
||||
*/
|
||||
PdoExtension->SwitchedIDEToNativeMode =
|
||||
PciConfigureIdeController(PdoExtension, PciData, 1);
|
||||
PdoExtension->IDEInNativeMode =
|
||||
PciConfigureIdeController(PdoExtension, PciData, TRUE);
|
||||
}
|
||||
|
||||
/* Is native mode enabled after all? */
|
||||
|
@ -1044,8 +1282,9 @@ PciGetEnhancedCapabilities(IN PPCI_PDO_EXTENSION PdoExtension,
|
|||
VOID
|
||||
NTAPI
|
||||
PciWriteLimitsAndRestoreCurrent(IN PVOID Reserved,
|
||||
IN PPCI_CONFIGURATOR_CONTEXT Context)
|
||||
IN PVOID Context2)
|
||||
{
|
||||
PPCI_CONFIGURATOR_CONTEXT Context = Context2;
|
||||
PPCI_COMMON_HEADER PciData, Current;
|
||||
PPCI_PDO_EXTENSION PdoExtension;
|
||||
|
||||
|
@ -1140,7 +1379,7 @@ PcipGetFunctionLimits(IN PPCI_CONFIGURATOR_CONTEXT Context)
|
|||
/* For these devices, an IPI must be sent to force high-IRQL discovery */
|
||||
IpiContext.Barrier = 1;
|
||||
IpiContext.RunCount = 1;
|
||||
IpiContext.PdoExtension = PdoExtension;
|
||||
IpiContext.DeviceExtension = PdoExtension;
|
||||
IpiContext.Function = PciWriteLimitsAndRestoreCurrent;
|
||||
IpiContext.Context = Context;
|
||||
KeIpiGenericCall(PciExecuteCriticalSystemRoutine, (ULONG_PTR)&IpiContext);
|
||||
|
@ -1886,4 +2125,122 @@ PciQueryDeviceRelations(IN PPCI_FDO_EXTENSION DeviceExtension,
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
PciSetResources(IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN BOOLEAN DoReset,
|
||||
IN BOOLEAN SomethingSomethingDarkSide)
|
||||
{
|
||||
PPCI_FDO_EXTENSION FdoExtension;
|
||||
UCHAR NewCacheLineSize, NewLatencyTimer;
|
||||
PCI_COMMON_HEADER PciData;
|
||||
BOOLEAN Native;
|
||||
PPCI_CONFIGURATOR Configurator;
|
||||
|
||||
/* Get the FDO and read the configuration data */
|
||||
FdoExtension = PdoExtension->ParentFdoExtension;
|
||||
PciReadDeviceConfig(PdoExtension, &PciData, 0, PCI_COMMON_HDR_LENGTH);
|
||||
|
||||
/* Make sure this is still the same device */
|
||||
if (!PcipIsSameDevice(PdoExtension, &PciData))
|
||||
{
|
||||
/* Fail */
|
||||
ASSERTMSG(FALSE, "PCI Set resources - not same device");
|
||||
return STATUS_DEVICE_DOES_NOT_EXIST;
|
||||
}
|
||||
|
||||
/* Nothing to set for a host bridge */
|
||||
if ((PdoExtension->BaseClass == PCI_CLASS_BRIDGE_DEV) &&
|
||||
(PdoExtension->SubClass == PCI_SUBCLASS_BR_HOST))
|
||||
{
|
||||
/* Fake success */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* Check if an IDE controller is being reset */
|
||||
if ((DoReset) &&
|
||||
(PdoExtension->BaseClass == PCI_CLASS_MASS_STORAGE_CTLR) &&
|
||||
(PdoExtension->SubClass == PCI_SUBCLASS_MSC_IDE_CTLR))
|
||||
{
|
||||
/* Turn off native mode */
|
||||
Native = PciConfigureIdeController(PdoExtension, &PciData, FALSE);
|
||||
ASSERT(Native == PdoExtension->IDEInNativeMode);
|
||||
}
|
||||
|
||||
/* Check for update of a hotplug device, or first configuration of one */
|
||||
if ((PdoExtension->NeedsHotPlugConfiguration) &&
|
||||
(FdoExtension->HotPlugParameters.Acquired))
|
||||
{
|
||||
/* Don't have hotplug devices to test with yet, QEMU 0.14 should */
|
||||
UNIMPLEMENTED;
|
||||
while (TRUE);
|
||||
}
|
||||
|
||||
/* Locate the correct resource configurator for this type of device */
|
||||
Configurator = &PciConfigurators[PdoExtension->HeaderType];
|
||||
|
||||
/* Apply the settings change */
|
||||
Configurator->ChangeResourceSettings(PdoExtension, &PciData);
|
||||
|
||||
/* Assume no update needed */
|
||||
PdoExtension->UpdateHardware = FALSE;
|
||||
|
||||
/* Check if a reset is needed */
|
||||
if (DoReset)
|
||||
{
|
||||
/* Reset resources */
|
||||
Configurator->ResetDevice(PdoExtension, &PciData);
|
||||
PciData.u.type0.InterruptLine = PdoExtension->RawInterruptLine;
|
||||
}
|
||||
|
||||
/* Check if the latency timer changed */
|
||||
NewLatencyTimer = PdoExtension->SavedLatencyTimer;
|
||||
if (PciData.LatencyTimer != NewLatencyTimer)
|
||||
{
|
||||
/* Debug notification */
|
||||
DPRINT1("PCI (pdox %08x) changing latency from %02x to %02x.\n",
|
||||
PdoExtension,
|
||||
PciData.LatencyTimer,
|
||||
NewLatencyTimer);
|
||||
}
|
||||
|
||||
/* Check if the cache line changed */
|
||||
NewCacheLineSize = PdoExtension->SavedCacheLineSize;
|
||||
if (PciData.CacheLineSize != NewCacheLineSize)
|
||||
{
|
||||
/* Debug notification */
|
||||
DPRINT1("PCI (pdox %08x) changing cache line size from %02x to %02x.\n",
|
||||
PdoExtension,
|
||||
PciData.CacheLineSize,
|
||||
NewCacheLineSize);
|
||||
}
|
||||
|
||||
/* Inherit data from PDO extension */
|
||||
PciData.LatencyTimer = PdoExtension->SavedLatencyTimer;
|
||||
PciData.CacheLineSize = PdoExtension->SavedCacheLineSize;
|
||||
PciData.u.type0.InterruptLine = PdoExtension->RawInterruptLine;
|
||||
|
||||
/* Apply any resource hacks required */
|
||||
PciApplyHacks(FdoExtension,
|
||||
&PciData,
|
||||
PdoExtension->Slot,
|
||||
PCI_HACK_FIXUP_BEFORE_UPDATE,
|
||||
PdoExtension);
|
||||
|
||||
/* Check if I/O space was disabled by administrator or driver */
|
||||
if (PdoExtension->IoSpaceNotRequired)
|
||||
{
|
||||
/* Don't turn on the decode */
|
||||
PdoExtension->CommandEnables &= ~PCI_ENABLE_IO_SPACE;
|
||||
}
|
||||
|
||||
/* Update the device with the new settings */
|
||||
PciUpdateHardware(PdoExtension, &PciData);
|
||||
|
||||
/* Update complete */
|
||||
PdoExtension->RawInterruptLine = PciData.u.type0.InterruptLine;
|
||||
PdoExtension->NeedsHotPlugConfiguration = FALSE;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -298,10 +298,10 @@ PciFdoIrpQueryCapabilities(IN PIRP Irp,
|
|||
PDEVICE_CAPABILITIES Capabilities;
|
||||
PAGED_CODE();
|
||||
ASSERT_FDO(DeviceExtension);
|
||||
|
||||
|
||||
/* Get the capabilities */
|
||||
Capabilities = IoStackLocation->Parameters.DeviceCapabilities.Capabilities;
|
||||
|
||||
|
||||
/* Inherit wake levels and power mappings from the higher-up capabilities */
|
||||
DeviceExtension->PowerState.SystemWakeLevel = Capabilities->SystemWake;
|
||||
DeviceExtension->PowerState.DeviceWakeLevel = Capabilities->DeviceWake;
|
||||
|
|
|
@ -73,7 +73,8 @@ Cardbus_GetAdditionalResourceDescriptors(IN PPCI_CONFIGURATOR_CONTEXT Context,
|
|||
|
||||
VOID
|
||||
NTAPI
|
||||
Cardbus_ResetDevice(IN PPCI_CONFIGURATOR_CONTEXT Context)
|
||||
Cardbus_ResetDevice(IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PPCI_COMMON_HEADER PciData)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
while (TRUE);
|
||||
|
@ -81,7 +82,8 @@ Cardbus_ResetDevice(IN PPCI_CONFIGURATOR_CONTEXT Context)
|
|||
|
||||
VOID
|
||||
NTAPI
|
||||
Cardbus_ChangeResourceSettings(IN PPCI_CONFIGURATOR_CONTEXT Context)
|
||||
Cardbus_ChangeResourceSettings(IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PPCI_COMMON_HEADER PciData)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
while (TRUE);
|
||||
|
|
|
@ -298,10 +298,11 @@ typedef struct _PCI_PDO_EXTENSION
|
|||
BOOLEAN MovedDevice;
|
||||
BOOLEAN DisablePowerDown;
|
||||
BOOLEAN NeedsHotPlugConfiguration;
|
||||
BOOLEAN SwitchedIDEToNativeMode;
|
||||
BOOLEAN IDEInNativeMode;
|
||||
BOOLEAN BIOSAllowsIDESwitchToNativeMode;
|
||||
BOOLEAN IoSpaceUnderNativeIdeControl;
|
||||
BOOLEAN OnDebugPath;
|
||||
BOOLEAN IoSpaceNotRequired;
|
||||
PCI_POWER_STATE PowerState;
|
||||
PCI_HEADER_TYPE_DEPENDENT Dependent;
|
||||
ULONGLONG HackFlags;
|
||||
|
@ -450,7 +451,8 @@ typedef VOID (NTAPI *PCI_CONFIGURATOR_SAVE_CURRENT_SETTINGS)(
|
|||
);
|
||||
|
||||
typedef VOID (NTAPI *PCI_CONFIGURATOR_CHANGE_RESOURCE_SETTINGS)(
|
||||
IN struct _PCI_CONFIGURATOR_CONTEXT* Context
|
||||
IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PPCI_COMMON_HEADER PciData
|
||||
);
|
||||
|
||||
typedef VOID (NTAPI *PCI_CONFIGURATOR_GET_ADDITIONAL_RESOURCE_DESCRIPTORS)(
|
||||
|
@ -460,7 +462,8 @@ typedef VOID (NTAPI *PCI_CONFIGURATOR_GET_ADDITIONAL_RESOURCE_DESCRIPTORS)(
|
|||
);
|
||||
|
||||
typedef VOID (NTAPI *PCI_CONFIGURATOR_RESET_DEVICE)(
|
||||
IN struct _PCI_CONFIGURATOR_CONTEXT* Context
|
||||
IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PPCI_COMMON_HEADER PciData
|
||||
);
|
||||
|
||||
//
|
||||
|
@ -496,7 +499,7 @@ typedef struct _PCI_CONFIGURATOR_CONTEXT
|
|||
//
|
||||
typedef VOID (NTAPI *PCI_IPI_FUNCTION)(
|
||||
IN PVOID Reserved,
|
||||
IN PPCI_CONFIGURATOR_CONTEXT Context
|
||||
IN PVOID Context
|
||||
);
|
||||
|
||||
//
|
||||
|
@ -506,7 +509,7 @@ typedef struct _PCI_IPI_CONTEXT
|
|||
{
|
||||
LONG RunCount;
|
||||
ULONG Barrier;
|
||||
PPCI_PDO_EXTENSION PdoExtension;
|
||||
PVOID DeviceExtension;
|
||||
PCI_IPI_FUNCTION Function;
|
||||
PVOID Context;
|
||||
} PCI_IPI_CONTEXT, *PPCI_IPI_CONTEXT;
|
||||
|
@ -1143,6 +1146,12 @@ PciQueryCapabilities(
|
|||
IN OUT PDEVICE_CAPABILITIES DeviceCapability
|
||||
);
|
||||
|
||||
PCM_PARTIAL_RESOURCE_DESCRIPTOR
|
||||
NTAPI
|
||||
PciNextPartialDescriptor(
|
||||
PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor
|
||||
);
|
||||
|
||||
//
|
||||
// Configuration Routines
|
||||
//
|
||||
|
@ -1261,6 +1270,18 @@ PciDebugPrintIoResReqList(
|
|||
IN PIO_RESOURCE_REQUIREMENTS_LIST Requirements
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
PciDebugPrintCmResList(
|
||||
IN PCM_RESOURCE_LIST ResourceList
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
PciDebugPrintPartialResource(
|
||||
IN PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialResource
|
||||
);
|
||||
|
||||
//
|
||||
// Interface Support
|
||||
//
|
||||
|
@ -1524,6 +1545,21 @@ PciQueryRequirements(
|
|||
IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *RequirementsList
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
PciComputeNewCurrentSettings(
|
||||
IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PCM_RESOURCE_LIST ResourceList
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
PciSetResources(
|
||||
IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN BOOLEAN DoReset,
|
||||
IN BOOLEAN SomethingSomethingDarkSide
|
||||
);
|
||||
|
||||
//
|
||||
// Identification Functions
|
||||
//
|
||||
|
@ -1589,13 +1625,15 @@ Cardbus_GetAdditionalResourceDescriptors(
|
|||
VOID
|
||||
NTAPI
|
||||
Cardbus_ResetDevice(
|
||||
IN PPCI_CONFIGURATOR_CONTEXT Context
|
||||
IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PPCI_COMMON_HEADER PciData
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
Cardbus_ChangeResourceSettings(
|
||||
IN PPCI_CONFIGURATOR_CONTEXT Context
|
||||
IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PPCI_COMMON_HEADER PciData
|
||||
);
|
||||
|
||||
//
|
||||
|
@ -1636,13 +1674,15 @@ Device_GetAdditionalResourceDescriptors(
|
|||
VOID
|
||||
NTAPI
|
||||
Device_ResetDevice(
|
||||
IN PPCI_CONFIGURATOR_CONTEXT Context
|
||||
IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PPCI_COMMON_HEADER PciData
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
Device_ChangeResourceSettings(
|
||||
IN PPCI_CONFIGURATOR_CONTEXT Context
|
||||
IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PPCI_COMMON_HEADER PciData
|
||||
);
|
||||
|
||||
//
|
||||
|
@ -1683,13 +1723,15 @@ PPBridge_GetAdditionalResourceDescriptors(
|
|||
VOID
|
||||
NTAPI
|
||||
PPBridge_ResetDevice(
|
||||
IN PPCI_CONFIGURATOR_CONTEXT Context
|
||||
IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PPCI_COMMON_HEADER PciData
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
PPBridge_ChangeResourceSettings(
|
||||
IN PPCI_CONFIGURATOR_CONTEXT Context
|
||||
IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PPCI_COMMON_HEADER PciData
|
||||
);
|
||||
|
||||
//
|
||||
|
|
|
@ -668,7 +668,8 @@ PPBridge_GetAdditionalResourceDescriptors(IN PPCI_CONFIGURATOR_CONTEXT Context,
|
|||
|
||||
VOID
|
||||
NTAPI
|
||||
PPBridge_ResetDevice(IN PPCI_CONFIGURATOR_CONTEXT Context)
|
||||
PPBridge_ResetDevice(IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PPCI_COMMON_HEADER PciData)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
while (TRUE);
|
||||
|
@ -676,7 +677,8 @@ PPBridge_ResetDevice(IN PPCI_CONFIGURATOR_CONTEXT Context)
|
|||
|
||||
VOID
|
||||
NTAPI
|
||||
PPBridge_ChangeResourceSettings(IN PPCI_CONFIGURATOR_CONTEXT Context)
|
||||
PPBridge_ChangeResourceSettings(IN PPCI_PDO_EXTENSION PdoExtension,
|
||||
IN PPCI_COMMON_HEADER PciData)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
while (TRUE);
|
||||
|
|
|
@ -112,9 +112,95 @@ PciPdoIrpStartDevice(IN PIRP Irp,
|
|||
IN PIO_STACK_LOCATION IoStackLocation,
|
||||
IN PPCI_PDO_EXTENSION DeviceExtension)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
while (TRUE);
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
NTSTATUS Status;
|
||||
BOOLEAN Changed, DoReset;
|
||||
POWER_STATE PowerState;
|
||||
PAGED_CODE();
|
||||
|
||||
DoReset = FALSE;
|
||||
|
||||
/* Begin entering the start phase */
|
||||
Status = PciBeginStateTransition((PVOID)DeviceExtension, PciStarted);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
/* Check if this is a VGA device */
|
||||
if (((DeviceExtension->BaseClass == PCI_CLASS_PRE_20) &&
|
||||
(DeviceExtension->SubClass == PCI_SUBCLASS_PRE_20_VGA)) ||
|
||||
((DeviceExtension->BaseClass == PCI_CLASS_DISPLAY_CTLR) &&
|
||||
(DeviceExtension->SubClass == PCI_SUBCLASS_VID_VGA_CTLR)))
|
||||
{
|
||||
/* Always force it on */
|
||||
DeviceExtension->CommandEnables |= (PCI_ENABLE_IO_SPACE |
|
||||
PCI_ENABLE_MEMORY_SPACE);
|
||||
}
|
||||
|
||||
/* Check if native IDE is enabled and it owns the I/O ports */
|
||||
if (DeviceExtension->IoSpaceUnderNativeIdeControl)
|
||||
{
|
||||
/* Then don't allow I/O access */
|
||||
DeviceExtension->CommandEnables &= ~PCI_ENABLE_IO_SPACE;
|
||||
}
|
||||
|
||||
/* Always enable bus mastering */
|
||||
DeviceExtension->CommandEnables |= PCI_ENABLE_BUS_MASTER;
|
||||
|
||||
/* Check if the OS assigned resources differ from the PCI configuration */
|
||||
Changed = PciComputeNewCurrentSettings(DeviceExtension,
|
||||
IoStackLocation->Parameters.
|
||||
StartDevice.AllocatedResources);
|
||||
if (Changed)
|
||||
{
|
||||
/* Remember this for later */
|
||||
DeviceExtension->MovedDevice = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* All good */
|
||||
DPRINT1("PCI - START not changing resource settings.\n");
|
||||
}
|
||||
|
||||
/* Check if the device was sleeping */
|
||||
if (DeviceExtension->PowerState.CurrentDeviceState != PowerDeviceD0)
|
||||
{
|
||||
/* Power it up */
|
||||
Status = PciSetPowerManagedDevicePowerState(DeviceExtension,
|
||||
PowerDeviceD0,
|
||||
FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Powerup fail, fail the request */
|
||||
PciCancelStateTransition((PVOID)DeviceExtension, PciStarted);
|
||||
return STATUS_DEVICE_POWER_FAILURE;
|
||||
}
|
||||
|
||||
/* Tell the power manager that the device is powered up */
|
||||
PowerState.DeviceState = PowerDeviceD0;
|
||||
PoSetPowerState(DeviceExtension->PhysicalDeviceObject,
|
||||
DevicePowerState,
|
||||
PowerState);
|
||||
|
||||
/* Update internal state */
|
||||
DeviceExtension->PowerState.CurrentDeviceState = PowerDeviceD0;
|
||||
|
||||
/* This device's resources and decodes will need to be reset */
|
||||
DoReset = TRUE;
|
||||
}
|
||||
|
||||
/* Update resource information now that the device is powered up and active */
|
||||
Status = PciSetResources(DeviceExtension, DoReset, TRUE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* That failed, so cancel the transition */
|
||||
PciCancelStateTransition((PVOID)DeviceExtension, PciStarted);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Fully commit, as the device is now started up and ready to go */
|
||||
PciCommitStateTransition((PVOID)DeviceExtension, PciStarted);
|
||||
}
|
||||
|
||||
/* Return the result of the start request */
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
|
|
@ -1069,7 +1069,7 @@ PciExecuteCriticalSystemRoutine(IN ULONG_PTR IpiContext)
|
|||
if (!InterlockedDecrement(&Context->RunCount))
|
||||
{
|
||||
/* Nope, this is the first instance, so execute the IPI function */
|
||||
Context->Function(Context->PdoExtension, Context->Context);
|
||||
Context->Function(Context->DeviceExtension, Context->Context);
|
||||
|
||||
/* Notify anyone that was spinning that they can stop now */
|
||||
Context->Barrier = 0;
|
||||
|
@ -1757,4 +1757,25 @@ PciQueryCapabilities(IN PPCI_PDO_EXTENSION PdoExtension,
|
|||
return Status;
|
||||
}
|
||||
|
||||
PCM_PARTIAL_RESOURCE_DESCRIPTOR
|
||||
NTAPI
|
||||
PciNextPartialDescriptor(PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
|
||||
{
|
||||
PCM_PARTIAL_RESOURCE_DESCRIPTOR NextDescriptor;
|
||||
|
||||
/* Assume the descriptors are the fixed size ones */
|
||||
NextDescriptor = CmDescriptor + 1;
|
||||
|
||||
/* But check if this is actually a variable-sized descriptor */
|
||||
if (CmDescriptor->Type == CmResourceTypeDeviceSpecific)
|
||||
{
|
||||
/* Add the size of the variable section as well */
|
||||
NextDescriptor = (PVOID)((ULONG_PTR)NextDescriptor +
|
||||
CmDescriptor->u.DeviceSpecificData.DataSize);
|
||||
}
|
||||
|
||||
/* Now the correct pointer has been computed, return it */
|
||||
return NextDescriptor;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -247,16 +247,21 @@ NdisMSetPeriodicTimer(
|
|||
|
||||
/* relative delays are negative, absolute are positive; resolution is 100ns */
|
||||
Timeout.QuadPart = Int32x32To64(MillisecondsPeriod, -10000);
|
||||
|
||||
|
||||
/* Lock the miniport block */
|
||||
KeAcquireSpinLock(&Timer->Miniport->Lock, &OldIrql);
|
||||
/* If KeSetTimer(Ex) returns FALSE then the timer is not in the system's queue (and not in ours either) */
|
||||
if (!KeSetTimerEx(&Timer->Timer, Timeout, MillisecondsPeriod, &Timer->Dpc))
|
||||
{
|
||||
/* Add the timer at the head of the timer queue */
|
||||
Timer->NextDeferredTimer = Timer->Miniport->TimerQueue;
|
||||
Timer->Miniport->TimerQueue = Timer;
|
||||
}
|
||||
|
||||
/* Attempt to dequeue the timer */
|
||||
DequeueMiniportTimer(Timer);
|
||||
|
||||
/* Add the timer at the head of the timer queue */
|
||||
Timer->NextDeferredTimer = Timer->Miniport->TimerQueue;
|
||||
Timer->Miniport->TimerQueue = Timer;
|
||||
|
||||
/* Unlock the miniport block */
|
||||
KeReleaseSpinLock(&Timer->Miniport->Lock, OldIrql);
|
||||
|
||||
KeSetTimerEx(&Timer->Timer, Timeout, MillisecondsPeriod, &Timer->Dpc);
|
||||
}
|
||||
|
||||
|
||||
|
@ -288,15 +293,20 @@ NdisMSetTimer(
|
|||
/* relative delays are negative, absolute are positive; resolution is 100ns */
|
||||
Timeout.QuadPart = Int32x32To64(MillisecondsToDelay, -10000);
|
||||
|
||||
/* Lock the miniport block */
|
||||
KeAcquireSpinLock(&Timer->Miniport->Lock, &OldIrql);
|
||||
/* If KeSetTimer(Ex) returns FALSE then the timer is not in the system's queue (and not in ours either) */
|
||||
if (!KeSetTimer(&Timer->Timer, Timeout, &Timer->Dpc))
|
||||
{
|
||||
/* Add the timer at the head of the timer queue */
|
||||
Timer->NextDeferredTimer = Timer->Miniport->TimerQueue;
|
||||
Timer->Miniport->TimerQueue = Timer;
|
||||
}
|
||||
|
||||
/* Attempt to dequeue the timer */
|
||||
DequeueMiniportTimer(Timer);
|
||||
|
||||
/* Add the timer at the head of the timer queue */
|
||||
Timer->NextDeferredTimer = Timer->Miniport->TimerQueue;
|
||||
Timer->Miniport->TimerQueue = Timer;
|
||||
|
||||
/* Unlock the miniport block */
|
||||
KeReleaseSpinLock(&Timer->Miniport->Lock, OldIrql);
|
||||
|
||||
KeSetTimer(&Timer->Timer, Timeout, &Timer->Dpc);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1994,7 +1994,10 @@ ScsiPortNotification(IN SCSI_NOTIFICATION_TYPE NotificationType,
|
|||
break;
|
||||
|
||||
case RequestTimerCall:
|
||||
DPRINT1("UNIMPLEMENTED SCSI Notification called: RequestTimerCall!\n");
|
||||
DPRINT("Notify: RequestTimerCall\n");
|
||||
DeviceExtension->InterruptData.Flags |= SCSI_PORT_TIMER_NEEDED;
|
||||
DeviceExtension->InterruptData.HwScsiTimer = (PHW_TIMER)va_arg(ap, PHW_TIMER);
|
||||
DeviceExtension->InterruptData.MiniportTimerValue = (ULONG)va_arg(ap, ULONG);
|
||||
break;
|
||||
|
||||
case BusChangeDetected:
|
||||
|
@ -4802,6 +4805,7 @@ ScsiPortDpcForIsr(IN PKDPC Dpc,
|
|||
PSCSI_PORT_LUN_EXTENSION LunExtension;
|
||||
BOOLEAN NeedToStartIo;
|
||||
PSCSI_REQUEST_BLOCK_INFO SrbInfo;
|
||||
LARGE_INTEGER TimerValue;
|
||||
|
||||
DPRINT("ScsiPortDpcForIsr(Dpc %p DpcDeviceObject %p DpcIrp %p DpcContext %p)\n",
|
||||
Dpc, DpcDeviceObject, DpcIrp, DpcContext);
|
||||
|
@ -4842,10 +4846,26 @@ TryAgain:
|
|||
}
|
||||
|
||||
/* Check if timer is needed */
|
||||
if (InterruptData.Flags & SCIS_PORT_TIMER_NEEDED)
|
||||
if (InterruptData.Flags & SCSI_PORT_TIMER_NEEDED)
|
||||
{
|
||||
/* TODO: Implement */
|
||||
ASSERT(FALSE);
|
||||
/* Save the timer routine */
|
||||
DeviceExtension->HwScsiTimer = InterruptData.HwScsiTimer;
|
||||
|
||||
if (InterruptData.MiniportTimerValue == 0)
|
||||
{
|
||||
/* Cancel the timer */
|
||||
KeCancelTimer(&DeviceExtension->MiniportTimer);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Convert timer value */
|
||||
TimerValue.QuadPart = Int32x32To64(InterruptData.MiniportTimerValue, -10);
|
||||
|
||||
/* Set the timer */
|
||||
KeSetTimer(&DeviceExtension->MiniportTimer,
|
||||
TimerValue,
|
||||
&DeviceExtension->MiniportTimerDpc);
|
||||
}
|
||||
}
|
||||
|
||||
/* If it's ready for the next request */
|
||||
|
@ -5599,8 +5619,31 @@ SpiMiniportTimerDpc(IN struct _KDPC *Dpc,
|
|||
IN PVOID SystemArgument1,
|
||||
IN PVOID SystemArgument2)
|
||||
{
|
||||
DPRINT1("Miniport timer DPC\n");
|
||||
ASSERT(FALSE);
|
||||
PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
|
||||
|
||||
DPRINT("Miniport timer DPC\n");
|
||||
|
||||
DeviceExtension = ((PDEVICE_OBJECT)DeviceObject)->DeviceExtension;
|
||||
|
||||
/* Acquire the spinlock */
|
||||
KeAcquireSpinLockAtDpcLevel(&DeviceExtension->SpinLock);
|
||||
|
||||
/* Call the timer routine */
|
||||
if (DeviceExtension->HwScsiTimer != NULL)
|
||||
{
|
||||
DeviceExtension->HwScsiTimer(&DeviceExtension->MiniPortDeviceExtension);
|
||||
}
|
||||
|
||||
/* Release the spinlock */
|
||||
KeReleaseSpinLockFromDpcLevel(&DeviceExtension->SpinLock);
|
||||
|
||||
if (DeviceExtension->InterruptData.Flags & SCSI_PORT_NOTIFICATION_NEEDED)
|
||||
{
|
||||
ScsiPortDpcForIsr(NULL,
|
||||
DeviceExtension->DeviceObject,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#define SCSI_PORT_DISABLE_INT_REQUESET 0x2000
|
||||
#define SCSI_PORT_DISABLE_INTERRUPTS 0x4000
|
||||
#define SCSI_PORT_ENABLE_INT_REQUEST 0x8000
|
||||
#define SCIS_PORT_TIMER_NEEDED 0x10000
|
||||
#define SCSI_PORT_TIMER_NEEDED 0x10000
|
||||
|
||||
/* LUN Extension flags*/
|
||||
#define LUNEX_FROZEN_QUEUE 0x0001
|
||||
|
@ -182,6 +182,8 @@ typedef struct _SCSI_PORT_INTERRUPT_DATA
|
|||
PSCSI_REQUEST_BLOCK_INFO CompletedRequests; /* Linked list of Srb info data */
|
||||
PSCSI_PORT_LUN_EXTENSION CompletedAbort;
|
||||
PSCSI_PORT_LUN_EXTENSION ReadyLun;
|
||||
PHW_TIMER HwScsiTimer;
|
||||
ULONG MiniportTimerValue;
|
||||
} SCSI_PORT_INTERRUPT_DATA, *PSCSI_PORT_INTERRUPT_DATA;
|
||||
|
||||
|
||||
|
@ -257,6 +259,7 @@ typedef struct _SCSI_PORT_DEVICE_EXTENSION
|
|||
PHW_INTERRUPT HwInterrupt;
|
||||
PHW_RESET_BUS HwResetBus;
|
||||
PHW_DMA_STARTED HwDmaStarted;
|
||||
PHW_TIMER HwScsiTimer;
|
||||
|
||||
PSCSI_REQUEST_BLOCK OriginalSrb;
|
||||
SCSI_REQUEST_BLOCK InternalSrb;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* FILE: drivers/usb/usbehci/common.c
|
||||
* PURPOSE: Common operations in FDO/PDO.
|
||||
* PROGRAMMERS:
|
||||
* Michael Martin (mjmartin@reactos.org)
|
||||
* Michael Martin (michael.martin@reactos.org)
|
||||
*/
|
||||
|
||||
#define INITGUID
|
||||
|
|
|
@ -4,34 +4,68 @@
|
|||
* FILE: drivers/usb/usbehci/fdo.c
|
||||
* PURPOSE: USB EHCI device driver.
|
||||
* PROGRAMMERS:
|
||||
* Michael Martin (mjmartin@reactos.org)
|
||||
* Michael Martin (michael.martin@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES *******************************************************************/
|
||||
#include "usbehci.h"
|
||||
#include <stdio.h>
|
||||
|
||||
VOID NTAPI
|
||||
TimerDefferedRoutine(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
|
||||
{
|
||||
PFDO_DEVICE_EXTENSION FdoDeviceExtension;
|
||||
PPDO_DEVICE_EXTENSION PdoDeviceExtension;
|
||||
ULONG tmp;
|
||||
ULONG Base;
|
||||
LONG i;
|
||||
|
||||
FdoDeviceExtension = (PFDO_DEVICE_EXTENSION) DeferredContext;
|
||||
PdoDeviceExtension = (PPDO_DEVICE_EXTENSION) FdoDeviceExtension->Pdo->DeviceExtension;
|
||||
|
||||
Base = (ULONG)FdoDeviceExtension->ResourceMemory;
|
||||
|
||||
for (i = 0; i < FdoDeviceExtension->ECHICaps.HCSParams.PortCount; i++)
|
||||
{
|
||||
tmp = READ_REGISTER_ULONG((PULONG) ((Base + EHCI_PORTSC) + (4 * i)));
|
||||
|
||||
if ((tmp & 0x04) && (!(PdoDeviceExtension->Ports[i].PortChange & USB_PORT_STATUS_RESET)))
|
||||
{
|
||||
DPRINT("Port %x is enabled\n", i);
|
||||
PdoDeviceExtension->Ports[i].PortChange |= USB_PORT_STATUS_RESET;
|
||||
CompletePendingURBRequest(PdoDeviceExtension);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID NTAPI
|
||||
EhciDefferedRoutine(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
|
||||
{
|
||||
PFDO_DEVICE_EXTENSION FdoDeviceExtension;
|
||||
PPDO_DEVICE_EXTENSION PdoDeviceExtension;
|
||||
ULONG CStatus;
|
||||
ULONG tmp;
|
||||
ULONG Base;
|
||||
LONG i;
|
||||
|
||||
FdoDeviceExtension = (PFDO_DEVICE_EXTENSION) DeferredContext;
|
||||
|
||||
if (!FdoDeviceExtension->Pdo)
|
||||
{
|
||||
DPRINT1("PDO not set yet!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
PdoDeviceExtension = (PPDO_DEVICE_EXTENSION) FdoDeviceExtension->Pdo->DeviceExtension;
|
||||
|
||||
Base = (ULONG)FdoDeviceExtension->ResourceMemory;
|
||||
|
||||
CStatus = (ULONG) SystemArgument2;
|
||||
|
||||
/* Port Change */
|
||||
if (CStatus & EHCI_STS_PCD)
|
||||
{
|
||||
LONG i;
|
||||
ULONG tmp;
|
||||
ULONG Base;
|
||||
|
||||
Base = (ULONG)FdoDeviceExtension->ResourceMemory;
|
||||
|
||||
/* Loop through the ports */
|
||||
for (i = 0; i < FdoDeviceExtension->ECHICaps.HCSParams.PortCount; i++)
|
||||
{
|
||||
|
@ -69,22 +103,22 @@ EhciDefferedRoutine(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVO
|
|||
KeStallExecutionProcessor(30);
|
||||
|
||||
/* As per USB 2.0 Specs, 9.1.2. Reset the port and clear the status change */
|
||||
tmp |= 0x100 | 0x02;
|
||||
//tmp |= 0x100 | 0x02;
|
||||
/* Sanity, Disable port */
|
||||
tmp &= ~0x04;
|
||||
//tmp &= ~0x04;
|
||||
|
||||
WRITE_REGISTER_ULONG((PULONG) ((Base + EHCI_PORTSC) + (4 * i)), tmp);
|
||||
//WRITE_REGISTER_ULONG((PULONG) ((Base + EHCI_PORTSC) + (4 * i)), tmp);
|
||||
|
||||
KeStallExecutionProcessor(20);
|
||||
//KeStallExecutionProcessor(20);
|
||||
|
||||
tmp = READ_REGISTER_ULONG((PULONG)((Base + EHCI_PORTSC) + (4 * i)));
|
||||
|
||||
PdoDeviceExtension->ChildDeviceCount++;
|
||||
PdoDeviceExtension->Ports[i].PortStatus |= USB_PORT_STATUS_HIGH_SPEED | USB_PORT_STATUS_CONNECT;
|
||||
PdoDeviceExtension->Ports[i].PortStatus &= ~0x8000;
|
||||
PdoDeviceExtension->Ports[i].PortStatus |= USB_PORT_STATUS_CONNECT;
|
||||
PdoDeviceExtension->Ports[i].PortChange |= USB_PORT_STATUS_CONNECT;
|
||||
|
||||
PdoDeviceExtension->HaltQueue = FALSE;
|
||||
KeSetEvent(&PdoDeviceExtension->QueueDrainedEvent, 0, FALSE);
|
||||
CompletePendingURBRequest(PdoDeviceExtension);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -156,10 +190,23 @@ InterruptService(PKINTERRUPT Interrupt, PVOID ServiceContext)
|
|||
}
|
||||
|
||||
BOOLEAN
|
||||
ResetPort(PDEVICE_OBJECT DeviceObject)
|
||||
ResetPort(PFDO_DEVICE_EXTENSION FdoDeviceExtension, UCHAR Port)
|
||||
{
|
||||
/*FIXME: Implement me */
|
||||
ULONG Base;
|
||||
ULONG tmp;
|
||||
LARGE_INTEGER DueTime;
|
||||
|
||||
DPRINT("Reset Port %x\n", Port);
|
||||
|
||||
Base = (ULONG)FdoDeviceExtension->ResourceMemory;
|
||||
|
||||
tmp = READ_REGISTER_ULONG((PULONG) ((Base + EHCI_PORTSC) + (4 * Port)));
|
||||
tmp |= 0x100;
|
||||
WRITE_REGISTER_ULONG((PULONG) ((Base + EHCI_PORTSC) + (4 * Port)), tmp);
|
||||
|
||||
DueTime.QuadPart = -100;
|
||||
|
||||
KeSetTimerEx(&FdoDeviceExtension->UpdateTimer, DueTime, 0, &FdoDeviceExtension->TimerDpcObject);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -171,7 +218,7 @@ StopEhci(PDEVICE_OBJECT DeviceObject)
|
|||
ULONG base;
|
||||
LONG tmp;
|
||||
|
||||
DPRINT1("Stopping Ehci controller\n");
|
||||
DPRINT("Stopping Ehci controller\n");
|
||||
FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
base = (ULONG)FdoDeviceExtension->ResourceMemory;
|
||||
|
||||
|
@ -194,7 +241,7 @@ StartEhci(PDEVICE_OBJECT DeviceObject)
|
|||
LONG tmp2;
|
||||
ULONG base;
|
||||
|
||||
DPRINT1("Starting Ehci controller\n");
|
||||
DPRINT("Starting Ehci controller\n");
|
||||
FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
base = (ULONG)FdoDeviceExtension->ResourceMemory;
|
||||
|
||||
|
@ -267,6 +314,11 @@ StartEhci(PDEVICE_OBJECT DeviceObject)
|
|||
EhciDefferedRoutine,
|
||||
FdoDeviceExtension);
|
||||
|
||||
KeInitializeDpc(&FdoDeviceExtension->TimerDpcObject,
|
||||
TimerDefferedRoutine,
|
||||
FdoDeviceExtension);
|
||||
|
||||
|
||||
Status = IoConnectInterrupt(&FdoDeviceExtension->EhciInterrupt,
|
||||
InterruptService,
|
||||
FdoDeviceExtension->DeviceObject,
|
||||
|
@ -353,7 +405,7 @@ GetCapabilities(PFDO_DEVICE_EXTENSION DeviceExtension, ULONG Base)
|
|||
PHCS = (PEHCI_HCS_CONTENT)&DeviceExtension->ECHICaps.HCSParams;
|
||||
if (PHCS->PortRouteRules)
|
||||
{
|
||||
for (i = 0; i < 8; i++)
|
||||
for (i = 0; i < PCap->HCSParams.PortCount; i++)
|
||||
{
|
||||
PCap->PortRoute[i] = READ_REGISTER_UCHAR((PUCHAR) (Base + 12 + i));
|
||||
}
|
||||
|
@ -408,6 +460,8 @@ StartDevice(PDEVICE_OBJECT DeviceObject, PCM_PARTIAL_RESOURCE_LIST raw, PCM_PART
|
|||
/* Zeroize it */
|
||||
RtlZeroMemory(FdoDeviceExtension->PeriodicFramList, sizeof(ULONG) * 1024);
|
||||
|
||||
ExInitializeFastMutex(&FdoDeviceExtension->FrameListMutex);
|
||||
|
||||
/* Allocate Common Buffer for Async List Head Queue */
|
||||
FdoDeviceExtension->AsyncListQueueHeadPtr =
|
||||
FdoDeviceExtension->pDmaAdapter->DmaOperations->AllocateCommonBuffer(FdoDeviceExtension->pDmaAdapter,
|
||||
|
@ -427,6 +481,8 @@ StartDevice(PDEVICE_OBJECT DeviceObject, PCM_PARTIAL_RESOURCE_LIST raw, PCM_PART
|
|||
/* FIXME: Same as FIXME above */
|
||||
20800);
|
||||
|
||||
ExInitializeFastMutex(&FdoDeviceExtension->AsyncListMutex);
|
||||
|
||||
Status = IoGetDeviceProperty(FdoDeviceExtension->LowerDevice,
|
||||
DevicePropertyAddress,
|
||||
sizeof(ULONG),
|
||||
|
@ -540,6 +596,8 @@ FdoQueryBusRelations(
|
|||
|
||||
DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
|
||||
DPRINT1("Ehci: QueryBusRelations\n");
|
||||
|
||||
/* Create the PDO with the next available number */
|
||||
while (TRUE)
|
||||
{
|
||||
|
@ -581,6 +639,7 @@ FdoQueryBusRelations(
|
|||
|
||||
PdoDeviceExtension->ControllerFdo = DeviceObject;
|
||||
PdoDeviceExtension->DeviceObject = Pdo;
|
||||
PdoDeviceExtension->NumberOfPorts = DeviceExtension->ECHICaps.HCSParams.PortCount;
|
||||
|
||||
InitializeListHead(&PdoDeviceExtension->IrpQueue);
|
||||
KeInitializeSpinLock(&PdoDeviceExtension->IrpQueueLock);
|
||||
|
@ -623,7 +682,7 @@ FdoDispatchPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
|
|||
{
|
||||
case IRP_MN_START_DEVICE:
|
||||
{
|
||||
DPRINT1("START_DEVICE\n");
|
||||
DPRINT1("Ehci: START_DEVICE\n");
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
Status = ForwardAndWait(DeviceObject, Irp);
|
||||
|
||||
|
@ -634,20 +693,20 @@ FdoDispatchPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
|
|||
}
|
||||
case IRP_MN_QUERY_DEVICE_RELATIONS:
|
||||
{
|
||||
DPRINT1("IRP_MN_QUERY_DEVICE_RELATIONS\n");
|
||||
DPRINT1("Ehci: IRP_MN_QUERY_DEVICE_RELATIONS\n");
|
||||
switch(Stack->Parameters.QueryDeviceRelations.Type)
|
||||
{
|
||||
case BusRelations:
|
||||
{
|
||||
PDEVICE_RELATIONS DeviceRelations = NULL;
|
||||
DPRINT("BusRelations\n");
|
||||
DPRINT1("Ehci: BusRelations\n");
|
||||
Status = FdoQueryBusRelations(DeviceObject, &DeviceRelations);
|
||||
Information = (ULONG_PTR)DeviceRelations;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT("Unknown query device relations type\n");
|
||||
DPRINT1("Ehci: Unknown query device relations type\n");
|
||||
Status = STATUS_NOT_IMPLEMENTED;
|
||||
break;
|
||||
}
|
||||
|
@ -656,16 +715,17 @@ FdoDispatchPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
|
|||
}
|
||||
case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
|
||||
{
|
||||
DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
|
||||
DPRINT1("Ehci: IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
|
||||
return ForwardIrpAndForget(DeviceObject, Irp);
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
|
||||
{
|
||||
DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
|
||||
DPRINT1("Ehci: IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
|
||||
}
|
||||
case IRP_MN_QUERY_INTERFACE:
|
||||
{
|
||||
DPRINT1("Ehci: IRP_MN_QUERY_INTERFACE\n");
|
||||
Status = STATUS_SUCCESS;
|
||||
Information = 0;
|
||||
Status = ForwardIrpAndForget(DeviceObject, Irp);
|
||||
|
@ -674,7 +734,7 @@ FdoDispatchPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
|
|||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("IRP_MJ_PNP / Unhandled minor function 0x%lx\n", Stack->MinorFunction);
|
||||
DPRINT1("Ehci: IRP_MJ_PNP / Unhandled minor function 0x%lx\n", Stack->MinorFunction);
|
||||
return ForwardIrpAndForget(DeviceObject, Irp);
|
||||
}
|
||||
}
|
||||
|
@ -701,7 +761,7 @@ AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT Pdo)
|
|||
|
||||
PFDO_DEVICE_EXTENSION FdoDeviceExtension;
|
||||
|
||||
DPRINT("Ehci AddDevice\n");
|
||||
DPRINT1("Ehci: AddDevice\n");
|
||||
|
||||
/* Create the FDO with next available number */
|
||||
while (TRUE)
|
||||
|
@ -750,6 +810,8 @@ AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT Pdo)
|
|||
FdoDeviceExtension = (PFDO_DEVICE_EXTENSION) Fdo->DeviceExtension;
|
||||
RtlZeroMemory(FdoDeviceExtension, sizeof(PFDO_DEVICE_EXTENSION));
|
||||
|
||||
KeInitializeTimerEx(&FdoDeviceExtension->UpdateTimer, SynchronizationTimer);
|
||||
|
||||
FdoDeviceExtension->Common.IsFdo = TRUE;
|
||||
FdoDeviceExtension->DeviceObject = Fdo;
|
||||
|
||||
|
@ -818,14 +880,14 @@ AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT Pdo)
|
|||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Unable to register device interface!\n");
|
||||
ASSERT(FALSE);
|
||||
return Status;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = IoSetDeviceInterfaceState(&InterfaceSymLinkName, TRUE);
|
||||
DPRINT1("SetInterfaceState %x\n", Status);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ASSERT(FALSE);
|
||||
return Status;
|
||||
}
|
||||
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||
|
||||
|
@ -836,13 +898,17 @@ NTSTATUS NTAPI
|
|||
FdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
PFDO_DEVICE_EXTENSION FdoDeviceExtension;
|
||||
PPDO_DEVICE_EXTENSION PdoDeviceExtension;
|
||||
PIO_STACK_LOCATION Stack = NULL;
|
||||
NTSTATUS Status = STATUS_UNSUCCESSFUL;
|
||||
ULONG_PTR Information = 0;
|
||||
PUSB_DEVICE UsbDevice = NULL;
|
||||
URB *Urb;
|
||||
|
||||
/*FIXME: This should never be called by a miniport as the miniport should only be dealing with the pdo */
|
||||
|
||||
FdoDeviceExtension = (PFDO_DEVICE_EXTENSION) DeviceObject->DeviceExtension;
|
||||
PdoDeviceExtension = (PPDO_DEVICE_EXTENSION) FdoDeviceExtension->Pdo->DeviceExtension;
|
||||
|
||||
ASSERT(FdoDeviceExtension->Common.IsFdo == TRUE);
|
||||
|
||||
|
@ -854,56 +920,84 @@ FdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
DPRINT("Header Length %d\n", Urb->UrbHeader.Length);
|
||||
DPRINT("Header Function %d\n", Urb->UrbHeader.Function);
|
||||
|
||||
UsbDevice = Urb->UrbHeader.UsbdDeviceHandle;
|
||||
UsbDevice = DeviceHandleToUsbDevice(PdoDeviceExtension, Urb->UrbHeader.UsbdDeviceHandle);
|
||||
|
||||
if (!UsbDevice)
|
||||
{
|
||||
DPRINT1("Invalid DeviceHandle or device not connected\n");
|
||||
return STATUS_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
switch (Urb->UrbHeader.Function)
|
||||
{
|
||||
case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
|
||||
{
|
||||
DPRINT1("URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:\n");
|
||||
DPRINT1("Ehci: URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:\n");
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_GET_STATUS_FROM_DEVICE:
|
||||
{
|
||||
DPRINT1("URB_FUNCTION_GET_STATUS_FROM_DEVICE\n");
|
||||
DPRINT1("Ehci: URB_FUNCTION_GET_STATUS_FROM_DEVICE\n");
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE:
|
||||
{
|
||||
DPRINT1("Ehci: URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE\n");
|
||||
switch(Urb->UrbControlDescriptorRequest.DescriptorType)
|
||||
{
|
||||
case USB_DEVICE_DESCRIPTOR_TYPE:
|
||||
{
|
||||
/* FIXNME: This probably not used for FDO and should be removed? */
|
||||
/* FIXME: This probably not used for FDO and should be removed? */
|
||||
DPRINT1("USB DEVICE DESC\n");
|
||||
break;
|
||||
}
|
||||
case USB_CONFIGURATION_DESCRIPTOR_TYPE:
|
||||
DPRINT1("USB CONFIG DESC\n");
|
||||
//break;
|
||||
case USB_STRING_DESCRIPTOR_TYPE:
|
||||
DPRINT1("Usb String Descriptor\n");
|
||||
{
|
||||
USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
|
||||
PUSB_STRING_DESCRIPTOR UsbString;
|
||||
BOOLEAN ResultOk;
|
||||
|
||||
CtrlSetup.bmRequestType._BM.Recipient = BMREQUEST_TO_DEVICE;
|
||||
CtrlSetup.bmRequestType._BM.Type = BMREQUEST_STANDARD;
|
||||
CtrlSetup.bmRequestType._BM.Reserved = 0;
|
||||
CtrlSetup.bmRequestType._BM.Dir = BMREQUEST_DEVICE_TO_HOST;
|
||||
CtrlSetup.bRequest = USB_REQUEST_GET_DESCRIPTOR;
|
||||
CtrlSetup.wValue.LowByte = Urb->UrbControlDescriptorRequest.Index;
|
||||
CtrlSetup.wValue.HiByte = Urb->UrbControlDescriptorRequest.DescriptorType;
|
||||
|
||||
if (Urb->UrbControlDescriptorRequest.DescriptorType == USB_STRING_DESCRIPTOR_TYPE)
|
||||
{
|
||||
CtrlSetup.wIndex.W = Urb->UrbControlDescriptorRequest.LanguageId;
|
||||
RtlZeroMemory(Urb->UrbControlDescriptorRequest.TransferBuffer, Urb->UrbControlDescriptorRequest.TransferBufferLength-1);
|
||||
}
|
||||
else
|
||||
CtrlSetup.wIndex.W = 0;
|
||||
|
||||
CtrlSetup.wLength = Urb->UrbControlDescriptorRequest.TransferBufferLength;
|
||||
|
||||
ResultOk = ExecuteControlRequest(FdoDeviceExtension, &CtrlSetup, UsbDevice->Address, UsbDevice->Port,
|
||||
Urb->UrbControlDescriptorRequest.TransferBuffer, Urb->UrbControlDescriptorRequest.TransferBufferLength);
|
||||
|
||||
if (Urb->UrbControlDescriptorRequest.DescriptorType == USB_STRING_DESCRIPTOR_TYPE)
|
||||
{
|
||||
UsbString = Urb->UrbControlDescriptorRequest.TransferBuffer;
|
||||
DPRINT1("Index %x\n", Urb->UrbControlDescriptorRequest.Index);
|
||||
DPRINT1("BufferLength %x\n", Urb->UrbControlDescriptorRequest.TransferBufferLength);
|
||||
DPRINT1("Length %x\n", UsbString->bLength);
|
||||
if (Urb->UrbControlDescriptorRequest.Index == 0)
|
||||
{
|
||||
DPRINT1("%x\n", (ULONG)Urb->UrbControlDescriptorRequest.TransferBuffer);
|
||||
}
|
||||
else
|
||||
DPRINT1("String %S\n", &UsbString->bString);
|
||||
}
|
||||
UsbString = Urb->UrbControlDescriptorRequest.TransferBuffer;
|
||||
Urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
Information = UsbString->bLength;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -915,12 +1009,13 @@ FdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
}
|
||||
case URB_FUNCTION_SELECT_CONFIGURATION:
|
||||
{
|
||||
DPRINT1("Selecting Configuration\n");
|
||||
DPRINT1("Ehci: URB_FUNCTION_SELECT_CONFIGURATION\n");
|
||||
DPRINT1("Urb->UrbSelectConfiguration.ConfigurationHandle %x\n",Urb->UrbSelectConfiguration.ConfigurationHandle);
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_CLASS_DEVICE:
|
||||
{
|
||||
DPRINT1("Ehci: URB_FUNCTION_CLASS_DEVICE %x\n",Urb->UrbControlVendorClassRequest.Request);
|
||||
switch (Urb->UrbControlVendorClassRequest.Request)
|
||||
{
|
||||
case USB_REQUEST_GET_DESCRIPTOR:
|
||||
|
@ -999,6 +1094,7 @@ FdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
}
|
||||
case URB_FUNCTION_CLASS_OTHER:
|
||||
{
|
||||
DPRINT1("Ehci: URB_FUNCTION_CLASS_OTHER\n");
|
||||
switch (Urb->UrbControlVendorClassRequest.Request)
|
||||
{
|
||||
case USB_REQUEST_GET_STATUS:
|
||||
|
@ -1099,7 +1195,7 @@ FdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("Unhandled URB %x\n", Urb->UrbHeader.Function);
|
||||
DPRINT1("Ehci: Unhandled URB %x\n", Urb->UrbHeader.Function);
|
||||
//Urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,18 +4,23 @@
|
|||
* FILE: drivers/usb/usbehci/irp.c
|
||||
* PURPOSE: IRP Handling.
|
||||
* PROGRAMMERS:
|
||||
* Michael Martin
|
||||
* Michael Martin (michael.martin@reactos.org)
|
||||
*/
|
||||
|
||||
#include "usbehci.h"
|
||||
|
||||
VOID
|
||||
RequestURBCancel (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
RemoveUrbRequest(PPDO_DEVICE_EXTENSION DeviceExtension, PIRP Irp)
|
||||
{
|
||||
PPDO_DEVICE_EXTENSION PdoDeviceExtension;
|
||||
|
||||
PdoDeviceExtension = (PPDO_DEVICE_EXTENSION) DeviceObject->DeviceExtension;
|
||||
KIRQL OldIrql;
|
||||
KeAcquireSpinLock(&DeviceExtension->IrpQueueLock, &OldIrql);
|
||||
RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
|
||||
KeReleaseSpinLock(&DeviceExtension->IrpQueueLock, OldIrql);
|
||||
}
|
||||
|
||||
VOID
|
||||
RequestURBCancel (PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp)
|
||||
{
|
||||
KIRQL OldIrql = Irp->CancelIrql;
|
||||
IoReleaseCancelSpinLock(DISPATCH_LEVEL);
|
||||
|
||||
|
@ -48,17 +53,483 @@ QueueURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension, PIRP Irp)
|
|||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension)
|
||||
NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp)
|
||||
{
|
||||
PLIST_ENTRY NextIrp = NULL;
|
||||
NTSTATUS Status = STATUS_UNSUCCESSFUL;
|
||||
ULONG_PTR Information = 0;
|
||||
PIO_STACK_LOCATION Stack;
|
||||
PUSB_DEVICE UsbDevice = NULL;
|
||||
URB *Urb;
|
||||
PFDO_DEVICE_EXTENSION FdoDeviceExtension;
|
||||
FdoDeviceExtension = (PFDO_DEVICE_EXTENSION) PdoDeviceExtension->ControllerFdo->DeviceExtension;
|
||||
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
ASSERT(Stack);
|
||||
|
||||
Urb = (PURB) Stack->Parameters.Others.Argument1;
|
||||
|
||||
ASSERT(Urb);
|
||||
|
||||
Information = 0;
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
DPRINT("TransferBuffer %x\n", Urb->UrbControlDescriptorRequest.TransferBuffer);
|
||||
DPRINT("TransferBufferLength %x\n", Urb->UrbControlDescriptorRequest.TransferBufferLength);
|
||||
DPRINT("UsbdDeviceHandle = %x\n", Urb->UrbHeader.UsbdDeviceHandle);
|
||||
|
||||
UsbDevice = Urb->UrbHeader.UsbdDeviceHandle;
|
||||
|
||||
/* UsbdDeviceHandle of 0 is root hub */
|
||||
if (UsbDevice == NULL)
|
||||
UsbDevice = PdoDeviceExtension->UsbDevices[0];
|
||||
|
||||
/* Assume URB success */
|
||||
Urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
|
||||
/* Set the DeviceHandle to the Internal Device */
|
||||
Urb->UrbHeader.UsbdDeviceHandle = UsbDevice;
|
||||
|
||||
switch (Urb->UrbHeader.Function)
|
||||
{
|
||||
case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
|
||||
{
|
||||
if (&UsbDevice->ActiveInterface->EndPoints[0]->EndPointDescriptor != Urb->UrbBulkOrInterruptTransfer.PipeHandle)
|
||||
{
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
ASSERT(Urb->UrbBulkOrInterruptTransfer.TransferBuffer != NULL);
|
||||
RtlZeroMemory(Urb->UrbBulkOrInterruptTransfer.TransferBuffer, Urb->UrbBulkOrInterruptTransfer.TransferBufferLength);
|
||||
|
||||
if (UsbDevice == PdoDeviceExtension->UsbDevices[0])
|
||||
{
|
||||
if (Urb->UrbBulkOrInterruptTransfer.TransferFlags & (USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK))
|
||||
{
|
||||
LONG i;
|
||||
for (i = 0; i < PdoDeviceExtension->NumberOfPorts; i++)
|
||||
{
|
||||
if (PdoDeviceExtension->Ports[i].PortChange)
|
||||
{
|
||||
DPRINT1("Inform hub driver that port %d has changed\n", i+1);
|
||||
((PUCHAR)Urb->UrbBulkOrInterruptTransfer.TransferBuffer)[0] = 1 << ((i + 1) & 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Urb->UrbHeader.Status = USBD_STATUS_INVALID_PARAMETER;
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
DPRINT1("Invalid transfer flags for SCE\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
DPRINT("Interrupt Transfer not for hub\n");
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_GET_STATUS_FROM_DEVICE:
|
||||
{
|
||||
if (Urb->UrbControlGetStatusRequest.Index == 0)
|
||||
{
|
||||
ASSERT(Urb->UrbBulkOrInterruptTransfer.TransferBuffer != NULL);
|
||||
*(PUSHORT)Urb->UrbControlGetStatusRequest.TransferBuffer = USB_PORT_STATUS_CONNECT | USB_PORT_STATUS_ENABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("Uknown identifier\n");
|
||||
Urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE:
|
||||
{
|
||||
switch(Urb->UrbControlDescriptorRequest.DescriptorType)
|
||||
{
|
||||
case USB_DEVICE_DESCRIPTOR_TYPE:
|
||||
{
|
||||
if (Urb->UrbControlDescriptorRequest.TransferBufferLength >= sizeof(USB_DEVICE_DESCRIPTOR))
|
||||
{
|
||||
Urb->UrbControlDescriptorRequest.TransferBufferLength = sizeof(USB_DEVICE_DESCRIPTOR);
|
||||
}
|
||||
ASSERT(Urb->UrbControlDescriptorRequest.TransferBuffer != NULL);
|
||||
RtlCopyMemory(Urb->UrbControlDescriptorRequest.TransferBuffer,
|
||||
&UsbDevice->DeviceDescriptor,
|
||||
Urb->UrbControlDescriptorRequest.TransferBufferLength);
|
||||
break;
|
||||
}
|
||||
case USB_CONFIGURATION_DESCRIPTOR_TYPE:
|
||||
{
|
||||
PUCHAR BufPtr;
|
||||
LONG i, j;
|
||||
|
||||
if (Urb->UrbControlDescriptorRequest.TransferBufferLength >= UsbDevice->ActiveConfig->ConfigurationDescriptor.wTotalLength)
|
||||
{
|
||||
Urb->UrbControlDescriptorRequest.TransferBufferLength = UsbDevice->ActiveConfig->ConfigurationDescriptor.wTotalLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("TransferBufferLenth %x is too small!!!\n", Urb->UrbControlDescriptorRequest.TransferBufferLength);
|
||||
if (Urb->UrbControlDescriptorRequest.TransferBufferLength < sizeof(USB_CONFIGURATION_DESCRIPTOR))
|
||||
{
|
||||
DPRINT("Configuration Descriptor cannot fit into given buffer!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT(Urb->UrbControlDescriptorRequest.TransferBuffer);
|
||||
BufPtr = (PUCHAR)Urb->UrbControlDescriptorRequest.TransferBuffer;
|
||||
|
||||
/* Copy the Configuration Descriptor */
|
||||
RtlCopyMemory(BufPtr, &UsbDevice->ActiveConfig->ConfigurationDescriptor, sizeof(USB_CONFIGURATION_DESCRIPTOR));
|
||||
|
||||
/* If there is no room for all the configs then bail */
|
||||
if (!(Urb->UrbControlDescriptorRequest.TransferBufferLength > sizeof(USB_CONFIGURATION_DESCRIPTOR)))
|
||||
{
|
||||
DPRINT("All Descriptors cannot fit into given buffer! Only USB_CONFIGURATION_DESCRIPTOR given\n");
|
||||
break;
|
||||
}
|
||||
|
||||
BufPtr += sizeof(USB_CONFIGURATION_DESCRIPTOR);
|
||||
for (i = 0; i < UsbDevice->ActiveConfig->ConfigurationDescriptor.bNumInterfaces; i++)
|
||||
{
|
||||
/* Copy the Interface Descriptor */
|
||||
RtlCopyMemory(BufPtr, &UsbDevice->ActiveConfig->Interfaces[i]->InterfaceDescriptor, sizeof(USB_INTERFACE_DESCRIPTOR));
|
||||
BufPtr += sizeof(USB_INTERFACE_DESCRIPTOR);
|
||||
for (j = 0; j < UsbDevice->ActiveConfig->Interfaces[i]->InterfaceDescriptor.bNumEndpoints; j++)
|
||||
{
|
||||
/* Copy the EndPoint Descriptor */
|
||||
RtlCopyMemory(BufPtr, &UsbDevice->ActiveConfig->Interfaces[i]->EndPoints[j]->EndPointDescriptor, sizeof(USB_ENDPOINT_DESCRIPTOR));
|
||||
BufPtr += sizeof(USB_ENDPOINT_DESCRIPTOR);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case USB_STRING_DESCRIPTOR_TYPE:
|
||||
{
|
||||
USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
|
||||
PUSB_STRING_DESCRIPTOR StringDesc;
|
||||
BOOLEAN ResultOk;
|
||||
|
||||
StringDesc = (PUSB_STRING_DESCRIPTOR) Urb->UrbControlDescriptorRequest.TransferBuffer;
|
||||
|
||||
if (Urb->UrbControlDescriptorRequest.Index == 0)
|
||||
DPRINT("Requesting LANGID's\n");
|
||||
|
||||
|
||||
RtlZeroMemory(Urb->UrbControlDescriptorRequest.TransferBuffer, Urb->UrbControlDescriptorRequest.TransferBufferLength-1);
|
||||
|
||||
CtrlSetup.bmRequestType._BM.Recipient = BMREQUEST_TO_DEVICE;
|
||||
CtrlSetup.bmRequestType._BM.Type = BMREQUEST_STANDARD;
|
||||
CtrlSetup.bmRequestType._BM.Reserved = 0;
|
||||
CtrlSetup.bmRequestType._BM.Dir = BMREQUEST_DEVICE_TO_HOST;
|
||||
CtrlSetup.bRequest = USB_REQUEST_GET_DESCRIPTOR;
|
||||
CtrlSetup.wValue.LowByte = Urb->UrbControlDescriptorRequest.Index;
|
||||
CtrlSetup.wValue.HiByte = Urb->UrbControlDescriptorRequest.DescriptorType;
|
||||
CtrlSetup.wIndex.W = Urb->UrbControlDescriptorRequest.LanguageId;
|
||||
CtrlSetup.wLength = Urb->UrbControlDescriptorRequest.TransferBufferLength;
|
||||
|
||||
ResultOk = ExecuteControlRequest(FdoDeviceExtension, &CtrlSetup, UsbDevice->Address, UsbDevice->Port,
|
||||
Urb->UrbControlDescriptorRequest.TransferBuffer, Urb->UrbControlDescriptorRequest.TransferBufferLength);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("Descriptor Type %x not supported!\n", Urb->UrbControlDescriptorRequest.DescriptorType);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_SELECT_CONFIGURATION:
|
||||
{
|
||||
PUSBD_INTERFACE_INFORMATION InterfaceInfo;
|
||||
LONG iCount, pCount;
|
||||
|
||||
DPRINT("Selecting Configuration\n");
|
||||
DPRINT("Urb->UrbSelectConfiguration.ConfigurationHandle %x\n",Urb->UrbSelectConfiguration.ConfigurationHandle);
|
||||
|
||||
if (Urb->UrbSelectConfiguration.ConfigurationDescriptor)
|
||||
{
|
||||
Urb->UrbSelectConfiguration.ConfigurationHandle = (PVOID)&PdoDeviceExtension->UsbDevices[0]->ActiveConfig->ConfigurationDescriptor;
|
||||
DPRINT("ConfigHandle %x\n", Urb->UrbSelectConfiguration.ConfigurationHandle);
|
||||
InterfaceInfo = &Urb->UrbSelectConfiguration.Interface;
|
||||
|
||||
for (iCount = 0; iCount < Urb->UrbSelectConfiguration.ConfigurationDescriptor->bNumInterfaces; iCount++)
|
||||
{
|
||||
InterfaceInfo->InterfaceHandle = (PVOID)&UsbDevice->ActiveInterface->InterfaceDescriptor;
|
||||
InterfaceInfo->Class = UsbDevice->ActiveInterface->InterfaceDescriptor.bInterfaceClass;
|
||||
InterfaceInfo->SubClass = UsbDevice->ActiveInterface->InterfaceDescriptor.bInterfaceSubClass;
|
||||
InterfaceInfo->Protocol = UsbDevice->ActiveInterface->InterfaceDescriptor.bInterfaceProtocol;
|
||||
InterfaceInfo->Reserved = 0;
|
||||
|
||||
for (pCount = 0; pCount < InterfaceInfo->NumberOfPipes; pCount++)
|
||||
{
|
||||
InterfaceInfo->Pipes[pCount].MaximumPacketSize = UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor.wMaxPacketSize;
|
||||
InterfaceInfo->Pipes[pCount].EndpointAddress = UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor.bEndpointAddress;
|
||||
InterfaceInfo->Pipes[pCount].Interval = UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor.bInterval;
|
||||
InterfaceInfo->Pipes[pCount].PipeType = UsbdPipeTypeInterrupt;
|
||||
InterfaceInfo->Pipes[pCount].PipeHandle = (PVOID)&UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor;
|
||||
if (InterfaceInfo->Pipes[pCount].MaximumTransferSize == 0)
|
||||
InterfaceInfo->Pipes[pCount].MaximumTransferSize = 4096;
|
||||
/* InterfaceInfo->Pipes[j].PipeFlags = 0; */
|
||||
}
|
||||
InterfaceInfo = (PUSBD_INTERFACE_INFORMATION)((PUCHAR)InterfaceInfo + InterfaceInfo->Length);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME: Set device to unconfigured state */
|
||||
}
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_CLASS_DEVICE:
|
||||
{
|
||||
switch (Urb->UrbControlVendorClassRequest.Request)
|
||||
{
|
||||
case USB_REQUEST_GET_DESCRIPTOR:
|
||||
{
|
||||
switch (Urb->UrbControlVendorClassRequest.Value >> 8)
|
||||
{
|
||||
case USB_DEVICE_CLASS_AUDIO:
|
||||
{
|
||||
DPRINT1("USB_DEVICE_CLASS_AUDIO not implemented\n");
|
||||
break;
|
||||
}
|
||||
case USB_DEVICE_CLASS_COMMUNICATIONS:
|
||||
{
|
||||
DPRINT1("USB_DEVICE_CLASS_COMMUNICATIONS not implemented\n");
|
||||
break;
|
||||
}
|
||||
case USB_DEVICE_CLASS_HUMAN_INTERFACE:
|
||||
{
|
||||
DPRINT1("USB_DEVICE_CLASS_HUMAN_INTERFACE not implemented\n");
|
||||
break;
|
||||
}
|
||||
case USB_DEVICE_CLASS_MONITOR:
|
||||
{
|
||||
DPRINT1("USB_DEVICE_CLASS_MONITOR not implemented\n");
|
||||
break;
|
||||
}
|
||||
case USB_DEVICE_CLASS_PHYSICAL_INTERFACE:
|
||||
{
|
||||
DPRINT1("USB_DEVICE_CLASS_PHYSICAL_INTERFACE not implemented\n");
|
||||
break;
|
||||
}
|
||||
case USB_DEVICE_CLASS_POWER:
|
||||
{
|
||||
DPRINT1("USB_DEVICE_CLASS_POWER not implemented\n");
|
||||
break;
|
||||
}
|
||||
case USB_DEVICE_CLASS_PRINTER:
|
||||
{
|
||||
DPRINT1("USB_DEVICE_CLASS_PRINTER not implemented\n");
|
||||
break;
|
||||
}
|
||||
case USB_DEVICE_CLASS_STORAGE:
|
||||
{
|
||||
DPRINT1("USB_DEVICE_CLASS_STORAGE not implemented\n");
|
||||
break;
|
||||
}
|
||||
case USB_DEVICE_CLASS_RESERVED:
|
||||
DPRINT1("Reserved!!!\n");
|
||||
case USB_DEVICE_CLASS_HUB:
|
||||
{
|
||||
PUSB_HUB_DESCRIPTOR UsbHubDescr = Urb->UrbControlVendorClassRequest.TransferBuffer;
|
||||
|
||||
DPRINT1("Length %x\n", Urb->UrbControlVendorClassRequest.TransferBufferLength);
|
||||
ASSERT(Urb->UrbControlVendorClassRequest.TransferBuffer != 0);
|
||||
/* FIXME: Handle more than root hub? */
|
||||
if(Urb->UrbControlVendorClassRequest.TransferBufferLength >= sizeof(USB_HUB_DESCRIPTOR))
|
||||
{
|
||||
Urb->UrbControlVendorClassRequest.TransferBufferLength = sizeof(USB_HUB_DESCRIPTOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME: Handle this correctly */
|
||||
UsbHubDescr->bDescriptorLength = sizeof(USB_HUB_DESCRIPTOR);
|
||||
UsbHubDescr->bDescriptorType = 0x29;
|
||||
break;
|
||||
}
|
||||
DPRINT1("USB_DEVICE_CLASS_HUB request\n");
|
||||
UsbHubDescr->bDescriptorLength = sizeof(USB_HUB_DESCRIPTOR);
|
||||
UsbHubDescr->bDescriptorType = 0x29;
|
||||
UsbHubDescr->bNumberOfPorts = 0x08;
|
||||
UsbHubDescr->wHubCharacteristics = 0x0012;
|
||||
UsbHubDescr->bPowerOnToPowerGood = 0x01;
|
||||
UsbHubDescr->bHubControlCurrent = 0x00;
|
||||
UsbHubDescr->bRemoveAndPowerMask[0] = 0x00;
|
||||
UsbHubDescr->bRemoveAndPowerMask[1] = 0x00;
|
||||
UsbHubDescr->bRemoveAndPowerMask[2] = 0xff;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("Unknown UrbControlVendorClassRequest Value\n");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_GET_STATUS:
|
||||
{
|
||||
DPRINT1("DEVICE: USB_REQUEST_GET_STATUS for port %d\n", Urb->UrbControlVendorClassRequest.Index);
|
||||
if (Urb->UrbControlVendorClassRequest.Index == 1)
|
||||
{
|
||||
ASSERT(Urb->UrbControlVendorClassRequest.TransferBuffer != 0);
|
||||
((PULONG)Urb->UrbControlVendorClassRequest.TransferBuffer)[0] = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("Unhandled URB request for class device\n");
|
||||
Urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_CLASS_OTHER:
|
||||
{
|
||||
DPRINT("URB_FUNCTION_CLASS_OTHER\n");
|
||||
/* FIXME: Each one of these needs to make sure that the index value is a valid for the number of ports and return STATUS_UNSUCCESSFUL is not */
|
||||
|
||||
switch (Urb->UrbControlVendorClassRequest.Request)
|
||||
{
|
||||
case USB_REQUEST_GET_STATUS:
|
||||
{
|
||||
DPRINT("USB_REQUEST_GET_STATUS Port %d\n", Urb->UrbControlVendorClassRequest.Index);
|
||||
|
||||
ASSERT(Urb->UrbControlVendorClassRequest.TransferBuffer != 0);
|
||||
DPRINT("PortStatus %x\n", PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortStatus);
|
||||
DPRINT("PortChange %x\n", PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange);
|
||||
((PUSHORT)Urb->UrbControlVendorClassRequest.TransferBuffer)[0] = PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortStatus;
|
||||
((PUSHORT)Urb->UrbControlVendorClassRequest.TransferBuffer)[1] = PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange;
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_CLEAR_FEATURE:
|
||||
{
|
||||
DPRINT("USB_REQUEST_CLEAR_FEATURE Port %d, value %x\n", Urb->UrbControlVendorClassRequest.Index,
|
||||
Urb->UrbControlVendorClassRequest.Value);
|
||||
switch (Urb->UrbControlVendorClassRequest.Value)
|
||||
{
|
||||
case C_PORT_CONNECTION:
|
||||
PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange &= ~USB_PORT_STATUS_CONNECT;
|
||||
break;
|
||||
case C_PORT_RESET:
|
||||
PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange &= ~USB_PORT_STATUS_RESET;
|
||||
break;
|
||||
default:
|
||||
DPRINT1("Unknown Value for Clear Feature %x \n", Urb->UrbControlVendorClassRequest.Value);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_SET_FEATURE:
|
||||
{
|
||||
DPRINT("USB_REQUEST_SET_FEATURE Port %d, value %x\n", Urb->UrbControlVendorClassRequest.Index,
|
||||
Urb->UrbControlVendorClassRequest.Value);
|
||||
|
||||
switch(Urb->UrbControlVendorClassRequest.Value)
|
||||
{
|
||||
case PORT_RESET:
|
||||
{
|
||||
PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortStatus |= USB_PORT_STATUS_ENABLE;
|
||||
ResetPort(FdoDeviceExtension, Urb->UrbControlVendorClassRequest.Index-1);
|
||||
|
||||
break;
|
||||
}
|
||||
case PORT_ENABLE:
|
||||
{
|
||||
DPRINT1("PORT_ENABLE not implemented\n");
|
||||
break;
|
||||
}
|
||||
case PORT_POWER:
|
||||
{
|
||||
DPRINT1("PORT_POWER not implemented\n");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("Unknown Set Feature!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_SET_ADDRESS:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_SET_ADDRESS\n");
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_GET_DESCRIPTOR:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_GET_DESCRIPTOR\n");
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_SET_DESCRIPTOR:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_SET_DESCRIPTOR\n");
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_GET_CONFIGURATION:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_GET_CONFIGURATION\n");
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_SET_CONFIGURATION:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_SET_CONFIGURATION\n");
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_GET_INTERFACE:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_GET_INTERFACE\n");
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_SET_INTERFACE:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_SET_INTERFACE\n");
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_SYNC_FRAME:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_SYNC_FRAME\n");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("Unknown Function Class Unknown request\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("Unhandled URB %x\n", Urb->UrbHeader.Function);
|
||||
Urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = Information;
|
||||
|
||||
if (Urb->UrbHeader.Status == USBD_STATUS_SUCCESS)
|
||||
{
|
||||
/* Fake a successful Control Transfer */
|
||||
Urb->UrbHeader.Function = 0x08;
|
||||
Urb->UrbHeader.UsbdFlags = 0;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
VOID
|
||||
CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension)
|
||||
{
|
||||
PLIST_ENTRY NextIrp = NULL;
|
||||
KIRQL oldIrql;
|
||||
PIRP Irp = NULL;
|
||||
URB *Urb;
|
||||
|
||||
KeAcquireSpinLock(&DeviceExtension->IrpQueueLock, &oldIrql);
|
||||
|
||||
|
@ -69,467 +540,13 @@ CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension)
|
|||
|
||||
if (!Irp)
|
||||
break;
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
ASSERT(Stack);
|
||||
|
||||
Urb = (PURB) Stack->Parameters.Others.Argument1;
|
||||
|
||||
ASSERT(Urb);
|
||||
|
||||
Information = 0;
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
DPRINT("TransferBuffer %x\n", Urb->UrbControlDescriptorRequest.TransferBuffer);
|
||||
DPRINT("TransferBufferLength %x\n", Urb->UrbControlDescriptorRequest.TransferBufferLength);
|
||||
DPRINT("UsbdDeviceHandle = %x\n", Urb->UrbHeader.UsbdDeviceHandle);
|
||||
|
||||
UsbDevice = Urb->UrbHeader.UsbdDeviceHandle;
|
||||
/* UsbdDeviceHandle of 0 is root hub */
|
||||
if (UsbDevice == NULL)
|
||||
UsbDevice = DeviceExtension->UsbDevices[0];
|
||||
|
||||
/* Assume URB success */
|
||||
Urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
|
||||
/* Set the DeviceHandle to the Internal Device */
|
||||
Urb->UrbHeader.UsbdDeviceHandle = UsbDevice;
|
||||
|
||||
switch (Urb->UrbHeader.Function)
|
||||
{
|
||||
case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
|
||||
{
|
||||
DPRINT("URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:\n");
|
||||
DPRINT("--->TransferBufferLength %x\n",Urb->UrbBulkOrInterruptTransfer.TransferBufferLength);
|
||||
DPRINT("--->TransferBuffer %x\n",Urb->UrbBulkOrInterruptTransfer.TransferBuffer);
|
||||
DPRINT("--->PipeHandle %x\n",Urb->UrbBulkOrInterruptTransfer.PipeHandle);
|
||||
DPRINT("---->(PVOID)&UsbDevice->EndPointDescriptor %x\n", (PVOID)&UsbDevice->ActiveInterface->EndPoints[0]->EndPointDescriptor);
|
||||
DPRINT("--->TransferFlags %x\n", Urb->UrbBulkOrInterruptTransfer.TransferFlags);
|
||||
ASSERT(Urb->UrbBulkOrInterruptTransfer.TransferBuffer != NULL);
|
||||
RtlZeroMemory(Urb->UrbBulkOrInterruptTransfer.TransferBuffer, Urb->UrbBulkOrInterruptTransfer.TransferBufferLength);
|
||||
|
||||
if (UsbDevice == DeviceExtension->UsbDevices[0])
|
||||
{
|
||||
if (Urb->UrbBulkOrInterruptTransfer.TransferFlags & (USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK))
|
||||
{
|
||||
LONG i;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if (i == 0){
|
||||
DPRINT("PortStatus %x\n", DeviceExtension->Ports[i].PortStatus);
|
||||
DPRINT("PortChange %x\n", DeviceExtension->Ports[i].PortChange);}
|
||||
if (DeviceExtension->Ports[i].PortChange)
|
||||
{
|
||||
DPRINT1("Inform hub driver that port %d has changed\n", i+1);
|
||||
((PUCHAR)Urb->UrbBulkOrInterruptTransfer.TransferBuffer)[0] = 1 << ((i + 1) & 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Urb->UrbHeader.Status = USBD_STATUS_INVALID_PARAMETER;
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
DPRINT1("Invalid transfer flags for SCE\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
DPRINT1("Interrupt Transfer not for hub\n");
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_GET_STATUS_FROM_DEVICE:
|
||||
{
|
||||
DPRINT("Get Status from Device\n");
|
||||
DPRINT("Index : %d\n", Urb->UrbControlGetStatusRequest.Index);
|
||||
|
||||
if (Urb->UrbControlGetStatusRequest.Index == 0)
|
||||
{
|
||||
ASSERT(Urb->UrbBulkOrInterruptTransfer.TransferBuffer != NULL);
|
||||
*(PUSHORT)Urb->UrbControlGetStatusRequest.TransferBuffer = USB_PORT_STATUS_CONNECT | USB_PORT_STATUS_ENABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("Uknown identifier\n");
|
||||
Urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE:
|
||||
{
|
||||
switch(Urb->UrbControlDescriptorRequest.DescriptorType)
|
||||
{
|
||||
case USB_DEVICE_DESCRIPTOR_TYPE:
|
||||
{
|
||||
DPRINT1("USB DEVICE DESC\n");
|
||||
if (Urb->UrbControlDescriptorRequest.TransferBufferLength >= sizeof(USB_DEVICE_DESCRIPTOR))
|
||||
{
|
||||
Urb->UrbControlDescriptorRequest.TransferBufferLength = sizeof(USB_DEVICE_DESCRIPTOR);
|
||||
}
|
||||
ASSERT(Urb->UrbControlDescriptorRequest.TransferBuffer != NULL);
|
||||
RtlCopyMemory(Urb->UrbControlDescriptorRequest.TransferBuffer,
|
||||
&UsbDevice->DeviceDescriptor,
|
||||
Urb->UrbControlDescriptorRequest.TransferBufferLength);
|
||||
break;
|
||||
}
|
||||
case USB_CONFIGURATION_DESCRIPTOR_TYPE:
|
||||
{
|
||||
PUCHAR BufPtr;
|
||||
LONG i, j;
|
||||
|
||||
DPRINT1("USB CONFIG DESC\n");
|
||||
|
||||
if (Urb->UrbControlDescriptorRequest.TransferBufferLength >= UsbDevice->ActiveConfig->ConfigurationDescriptor.wTotalLength)
|
||||
{
|
||||
Urb->UrbControlDescriptorRequest.TransferBufferLength = UsbDevice->ActiveConfig->ConfigurationDescriptor.wTotalLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("Buffer to small!!!\n");
|
||||
//ASSERT(FALSE);
|
||||
}
|
||||
|
||||
ASSERT(Urb->UrbControlDescriptorRequest.TransferBuffer);
|
||||
BufPtr = (PUCHAR)Urb->UrbControlDescriptorRequest.TransferBuffer;
|
||||
|
||||
/* Copy the Configuration Descriptor */
|
||||
RtlCopyMemory(BufPtr, &UsbDevice->ActiveConfig->ConfigurationDescriptor, sizeof(USB_CONFIGURATION_DESCRIPTOR));
|
||||
BufPtr += sizeof(USB_CONFIGURATION_DESCRIPTOR);
|
||||
for (i = 0; i < UsbDevice->ActiveConfig->ConfigurationDescriptor.bNumInterfaces; i++)
|
||||
{
|
||||
/* Copy the Interface Descriptor */
|
||||
RtlCopyMemory(BufPtr, &UsbDevice->ActiveConfig->Interfaces[i]->InterfaceDescriptor, sizeof(USB_INTERFACE_DESCRIPTOR));
|
||||
BufPtr += sizeof(USB_INTERFACE_DESCRIPTOR);
|
||||
for (j = 0; j < UsbDevice->ActiveConfig->Interfaces[i]->InterfaceDescriptor.bNumEndpoints; j++)
|
||||
{
|
||||
/* Copy the EndPoint Descriptor */
|
||||
RtlCopyMemory(BufPtr, &UsbDevice->ActiveConfig->Interfaces[i]->EndPoints[j]->EndPointDescriptor, sizeof(USB_ENDPOINT_DESCRIPTOR));
|
||||
BufPtr += sizeof(USB_ENDPOINT_DESCRIPTOR);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case USB_STRING_DESCRIPTOR_TYPE:
|
||||
{
|
||||
DPRINT1("Usb String Descriptor not implemented\n");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("Descriptor Type %x not supported!\n", Urb->UrbControlDescriptorRequest.DescriptorType);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_SELECT_CONFIGURATION:
|
||||
{
|
||||
PUSBD_INTERFACE_INFORMATION InterfaceInfo;
|
||||
LONG iCount, pCount;
|
||||
|
||||
DPRINT("Selecting Configuration\n");
|
||||
DPRINT("Length %x\n", Urb->UrbHeader.Length);
|
||||
DPRINT("Urb->UrbSelectConfiguration.ConfigurationHandle %x\n",Urb->UrbSelectConfiguration.ConfigurationHandle);
|
||||
|
||||
if (Urb->UrbSelectConfiguration.ConfigurationDescriptor)
|
||||
{
|
||||
DPRINT("ConfigurationDescriptor = %p\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor);
|
||||
DPRINT(" bLength = %d\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor->bLength);
|
||||
DPRINT(" bDescriptorType = %d\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor->bDescriptorType);
|
||||
DPRINT(" wTotalLength = %d\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor->wTotalLength);
|
||||
DPRINT(" bNumInterfaces = %d\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor->bNumInterfaces);
|
||||
DPRINT(" bConfigurationValue = %d\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor->bConfigurationValue);
|
||||
DPRINT(" iConfiguration = %d\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor->iConfiguration);
|
||||
DPRINT(" bmAttributes = %04x\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor->bmAttributes);
|
||||
DPRINT(" MaxPower = %d\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor->MaxPower);
|
||||
|
||||
|
||||
Urb->UrbSelectConfiguration.ConfigurationHandle = (PVOID)&DeviceExtension->UsbDevices[0]->ActiveConfig->ConfigurationDescriptor;
|
||||
DPRINT("ConfigHandle %x\n", Urb->UrbSelectConfiguration.ConfigurationHandle);
|
||||
InterfaceInfo = &Urb->UrbSelectConfiguration.Interface;
|
||||
|
||||
for (iCount = 0; iCount < Urb->UrbSelectConfiguration.ConfigurationDescriptor->bNumInterfaces; iCount++)
|
||||
{
|
||||
DPRINT("InterfaceInformation[%d]\n", iCount);
|
||||
DPRINT(" Length = %d\n", InterfaceInfo->Length);
|
||||
DPRINT(" InterfaceNumber = %d\n", InterfaceInfo->InterfaceNumber);
|
||||
DPRINT(" AlternateSetting = %d\n", InterfaceInfo->AlternateSetting);
|
||||
DPRINT(" Class = %02x\n", (ULONG)InterfaceInfo->Class);
|
||||
DPRINT(" SubClass = %02x\n", (ULONG)InterfaceInfo->SubClass);
|
||||
DPRINT(" Protocol = %02x\n", (ULONG)InterfaceInfo->Protocol);
|
||||
DPRINT(" Reserved = %02x\n", (ULONG)InterfaceInfo->Reserved);
|
||||
DPRINT(" InterfaceHandle = %p\n", InterfaceInfo->InterfaceHandle);
|
||||
DPRINT(" NumberOfPipes = %d\n", InterfaceInfo->NumberOfPipes);
|
||||
InterfaceInfo->InterfaceHandle = (PVOID)&UsbDevice->ActiveInterface->InterfaceDescriptor;
|
||||
InterfaceInfo->Class = UsbDevice->ActiveInterface->InterfaceDescriptor.bInterfaceClass;
|
||||
InterfaceInfo->SubClass = UsbDevice->ActiveInterface->InterfaceDescriptor.bInterfaceSubClass;
|
||||
InterfaceInfo->Protocol = UsbDevice->ActiveInterface->InterfaceDescriptor.bInterfaceProtocol;
|
||||
InterfaceInfo->Reserved = 0;
|
||||
|
||||
for (pCount = 0; pCount < InterfaceInfo->NumberOfPipes; pCount++)
|
||||
{
|
||||
DPRINT("Pipe[%d]\n", pCount);
|
||||
DPRINT(" MaximumPacketSize = %d\n", InterfaceInfo->Pipes[pCount].MaximumPacketSize);
|
||||
DPRINT(" EndpointAddress = %d\n", InterfaceInfo->Pipes[pCount].EndpointAddress);
|
||||
DPRINT(" Interval = %d\n", InterfaceInfo->Pipes[pCount].Interval);
|
||||
DPRINT(" PipeType = %d\n", InterfaceInfo->Pipes[pCount].PipeType);
|
||||
DPRINT(" PipeHandle = %x\n", InterfaceInfo->Pipes[pCount].PipeHandle);
|
||||
DPRINT(" MaximumTransferSize = %d\n", InterfaceInfo->Pipes[pCount].MaximumTransferSize);
|
||||
DPRINT(" PipeFlags = %08x\n", InterfaceInfo->Pipes[pCount].PipeFlags);
|
||||
InterfaceInfo->Pipes[pCount].MaximumPacketSize = UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor.wMaxPacketSize;
|
||||
InterfaceInfo->Pipes[pCount].EndpointAddress = UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor.bEndpointAddress;
|
||||
InterfaceInfo->Pipes[pCount].Interval = UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor.bInterval;
|
||||
InterfaceInfo->Pipes[pCount].PipeType = UsbdPipeTypeInterrupt;
|
||||
InterfaceInfo->Pipes[pCount].PipeHandle = (PVOID)&UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor;
|
||||
if (InterfaceInfo->Pipes[pCount].MaximumTransferSize == 0)
|
||||
InterfaceInfo->Pipes[pCount].MaximumTransferSize = 4096;
|
||||
/* InterfaceInfo->Pipes[j].PipeFlags = 0; */
|
||||
}
|
||||
InterfaceInfo = (PUSBD_INTERFACE_INFORMATION)((PUCHAR)InterfaceInfo + InterfaceInfo->Length);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME: Set device to unconfigured state */
|
||||
}
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_CLASS_DEVICE:
|
||||
{
|
||||
switch (Urb->UrbControlVendorClassRequest.Request)
|
||||
{
|
||||
case USB_REQUEST_GET_DESCRIPTOR:
|
||||
{
|
||||
DPRINT1("TransferFlags %x\n", Urb->UrbControlVendorClassRequest.TransferFlags);
|
||||
DPRINT1("Urb->UrbControlVendorClassRequest.Value %x\n", Urb->UrbControlVendorClassRequest.Value);
|
||||
|
||||
switch (Urb->UrbControlVendorClassRequest.Value >> 8)
|
||||
{
|
||||
case USB_DEVICE_CLASS_AUDIO:
|
||||
{
|
||||
DPRINT1("USB_DEVICE_CLASS_AUDIO\n");
|
||||
break;
|
||||
}
|
||||
case USB_DEVICE_CLASS_COMMUNICATIONS:
|
||||
{
|
||||
DPRINT1("USB_DEVICE_CLASS_COMMUNICATIONS\n");
|
||||
break;
|
||||
}
|
||||
case USB_DEVICE_CLASS_HUMAN_INTERFACE:
|
||||
{
|
||||
DPRINT1("USB_DEVICE_CLASS_HUMAN_INTERFACE\n");
|
||||
break;
|
||||
}
|
||||
case USB_DEVICE_CLASS_MONITOR:
|
||||
{
|
||||
DPRINT1("USB_DEVICE_CLASS_MONITOR\n");
|
||||
break;
|
||||
}
|
||||
case USB_DEVICE_CLASS_PHYSICAL_INTERFACE:
|
||||
{
|
||||
DPRINT1("USB_DEVICE_CLASS_PHYSICAL_INTERFACE\n");
|
||||
break;
|
||||
}
|
||||
case USB_DEVICE_CLASS_POWER:
|
||||
{
|
||||
DPRINT1("USB_DEVICE_CLASS_POWER\n");
|
||||
break;
|
||||
}
|
||||
case USB_DEVICE_CLASS_PRINTER:
|
||||
{
|
||||
DPRINT1("USB_DEVICE_CLASS_PRINTER\n");
|
||||
break;
|
||||
}
|
||||
case USB_DEVICE_CLASS_STORAGE:
|
||||
{
|
||||
DPRINT1("USB_DEVICE_CLASS_STORAGE\n");
|
||||
break;
|
||||
}
|
||||
case USB_DEVICE_CLASS_RESERVED:
|
||||
DPRINT1("Reserved!!!\n");
|
||||
case USB_DEVICE_CLASS_HUB:
|
||||
{
|
||||
|
||||
PUSB_HUB_DESCRIPTOR UsbHubDescr = Urb->UrbControlVendorClassRequest.TransferBuffer;
|
||||
ASSERT(Urb->UrbControlVendorClassRequest.TransferBuffer != 0);
|
||||
/* FIXME: Handle more than root hub? */
|
||||
if(Urb->UrbControlVendorClassRequest.TransferBufferLength >= sizeof(USB_HUB_DESCRIPTOR))
|
||||
{
|
||||
Urb->UrbControlVendorClassRequest.TransferBufferLength = sizeof(USB_HUB_DESCRIPTOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME: Handle this correctly */
|
||||
UsbHubDescr->bDescriptorLength = sizeof(USB_HUB_DESCRIPTOR);
|
||||
UsbHubDescr->bDescriptorType = 0x29;
|
||||
break;
|
||||
}
|
||||
DPRINT1("USB_DEVICE_CLASS_HUB request\n");
|
||||
UsbHubDescr->bDescriptorLength = sizeof(USB_HUB_DESCRIPTOR);
|
||||
UsbHubDescr->bDescriptorType = 0x29;
|
||||
UsbHubDescr->bNumberOfPorts = 0x08;
|
||||
UsbHubDescr->wHubCharacteristics = 0x0012;
|
||||
UsbHubDescr->bPowerOnToPowerGood = 0x01;
|
||||
UsbHubDescr->bHubControlCurrent = 0x00;
|
||||
UsbHubDescr->bRemoveAndPowerMask[0] = 0x00;
|
||||
UsbHubDescr->bRemoveAndPowerMask[1] = 0x00;
|
||||
UsbHubDescr->bRemoveAndPowerMask[2] = 0xff;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("Unknown UrbControlVendorClassRequest Value\n");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_GET_STATUS:
|
||||
{
|
||||
DPRINT1("DEVICE: USB_REQUEST_GET_STATUS for port %d\n", Urb->UrbControlVendorClassRequest.Index);
|
||||
|
||||
if (Urb->UrbControlVendorClassRequest.Index == 1)
|
||||
{
|
||||
ASSERT(Urb->UrbControlVendorClassRequest.TransferBuffer != 0);
|
||||
((PULONG)Urb->UrbControlVendorClassRequest.TransferBuffer)[0] = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("Unhandled URB request for class device\n");
|
||||
Urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_CLASS_OTHER:
|
||||
{
|
||||
switch (Urb->UrbControlVendorClassRequest.Request)
|
||||
{
|
||||
case USB_REQUEST_GET_STATUS:
|
||||
{
|
||||
DPRINT1("OTHER: USB_REQUEST_GET_STATUS for port %d\n", Urb->UrbControlVendorClassRequest.Index);
|
||||
ASSERT(Urb->UrbControlVendorClassRequest.TransferBuffer != 0);
|
||||
((PUSHORT)Urb->UrbControlVendorClassRequest.TransferBuffer)[0] = DeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortStatus;
|
||||
((PUSHORT)Urb->UrbControlVendorClassRequest.TransferBuffer)[1] = DeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange;
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_CLEAR_FEATURE:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_CLEAR_FEATURE Port %d, value %x\n", Urb->UrbControlVendorClassRequest.Index,
|
||||
Urb->UrbControlVendorClassRequest.Value);
|
||||
switch (Urb->UrbControlVendorClassRequest.Value)
|
||||
{
|
||||
case C_PORT_CONNECTION:
|
||||
DeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange &= ~USB_PORT_STATUS_CONNECT;
|
||||
break;
|
||||
case C_PORT_RESET:
|
||||
DeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange &= ~USB_PORT_STATUS_RESET;
|
||||
break;
|
||||
default:
|
||||
DPRINT1("Unknown Value for Clear Feature %x \n", Urb->UrbControlVendorClassRequest.Value);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_SET_FEATURE:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_SET_FEATURE Port %d, value %x\n", Urb->UrbControlVendorClassRequest.Index,
|
||||
Urb->UrbControlVendorClassRequest.Value);
|
||||
|
||||
switch(Urb->UrbControlVendorClassRequest.Value)
|
||||
{
|
||||
case PORT_RESET:
|
||||
{
|
||||
DeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange |= USB_PORT_STATUS_RESET;
|
||||
break;
|
||||
}
|
||||
case PORT_ENABLE:
|
||||
{
|
||||
DPRINT1("Unhandled Set Feature\n");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("Unknown Set Feature!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_SET_ADDRESS:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_SET_ADDRESS\n");
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_GET_DESCRIPTOR:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_GET_DESCRIPTOR\n");
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_SET_DESCRIPTOR:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_SET_DESCRIPTOR\n");
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_GET_CONFIGURATION:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_GET_CONFIGURATION\n");
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_SET_CONFIGURATION:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_SET_CONFIGURATION\n");
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_GET_INTERFACE:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_GET_INTERFACE\n");
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_SET_INTERFACE:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_SET_INTERFACE\n");
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_SYNC_FRAME:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_SYNC_FRAME\n");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("Unknown Function Class Unknown request\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("Unhandled URB %x\n", Urb->UrbHeader.Function);
|
||||
Urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = Information;
|
||||
|
||||
if (Urb->UrbHeader.Status == USBD_STATUS_SUCCESS)
|
||||
{
|
||||
/* Fake a successful Control Transfer */
|
||||
Urb->UrbHeader.Function = 0x08;
|
||||
Urb->UrbHeader.UsbdFlags = 0;
|
||||
}
|
||||
|
||||
KeReleaseSpinLock(&DeviceExtension->IrpQueueLock, oldIrql);
|
||||
HandleUrbRequest(DeviceExtension, Irp);
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
KeAcquireSpinLock(&DeviceExtension->IrpQueueLock, &oldIrql);
|
||||
|
||||
if (DeviceExtension->HaltQueue)
|
||||
break;
|
||||
}
|
||||
|
||||
KeReleaseSpinLock(&DeviceExtension->IrpQueueLock, oldIrql);
|
||||
if (!DeviceExtension->HaltQueue)
|
||||
KeSetEvent(&DeviceExtension->QueueDrainedEvent, 0, FALSE);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* FILE: drivers/usb/usbehci/misc.c
|
||||
* PURPOSE: Misceallenous operations.
|
||||
* PROGRAMMERS:
|
||||
* Michael Martin
|
||||
* Michael Martin (michael.martin@reactos.org)
|
||||
*/
|
||||
|
||||
#include "usbehci.h"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* FILE: drivers/usb/usbehci/pdo.c
|
||||
* PURPOSE: USB EHCI device driver.
|
||||
* PROGRAMMERS:
|
||||
* Michael Martin
|
||||
* Michael Martin (michael.martin@reactos.org)
|
||||
*/
|
||||
|
||||
#define INITGUID
|
||||
|
@ -125,16 +125,56 @@ PdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
{
|
||||
case IOCTL_INTERNAL_USB_SUBMIT_URB:
|
||||
{
|
||||
PUSB_DEVICE UsbDevice = NULL;
|
||||
URB *Urb;
|
||||
ULONG i;
|
||||
|
||||
Urb = (PURB) Stack->Parameters.Others.Argument1;
|
||||
DPRINT("Header Length %d\n", Urb->UrbHeader.Length);
|
||||
DPRINT("Header Function %d\n", Urb->UrbHeader.Function);
|
||||
/* Queue all request for now, kernel thread will complete them */
|
||||
QueueURBRequest(PdoDeviceExtension, Irp);
|
||||
Information = 0;
|
||||
IoMarkIrpPending(Irp);
|
||||
Status = STATUS_PENDING;
|
||||
|
||||
UsbDevice = Urb->UrbHeader.UsbdDeviceHandle;
|
||||
|
||||
if (UsbDevice == NULL)
|
||||
UsbDevice = PdoDeviceExtension->UsbDevices[0];
|
||||
|
||||
if ((Urb->UrbHeader.Function == URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER) &&
|
||||
(UsbDevice == PdoDeviceExtension->UsbDevices[0]))
|
||||
{
|
||||
if (Urb->UrbBulkOrInterruptTransfer.PipeHandle == &UsbDevice->ActiveInterface->EndPoints[0]->EndPointDescriptor)
|
||||
{
|
||||
DPRINT1("PipeHandle doesnt match SCE PipeHandle\n");
|
||||
}
|
||||
|
||||
/* Queue the Irp first */
|
||||
QueueURBRequest(PdoDeviceExtension, Irp);
|
||||
|
||||
/* Check if there is any connected devices */
|
||||
for (i = 0; i < PdoDeviceExtension->NumberOfPorts; i++)
|
||||
{
|
||||
if (PdoDeviceExtension->Ports[i].PortChange == 0x01)
|
||||
{
|
||||
DPRINT1("Inform hub driver that port %d has changed\n", i+1);
|
||||
((PUCHAR)Urb->UrbBulkOrInterruptTransfer.TransferBuffer)[0] = 1 << ((i + 1) & 7);
|
||||
Information = 0;
|
||||
Status = STATUS_SUCCESS;
|
||||
/* Assume URB success */
|
||||
Urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
|
||||
/* Set the DeviceHandle to the Internal Device */
|
||||
Urb->UrbHeader.UsbdDeviceHandle = UsbDevice;
|
||||
|
||||
/* Request handled, Remove it from the queue */
|
||||
RemoveUrbRequest(PdoDeviceExtension, Irp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Status == STATUS_SUCCESS) break;
|
||||
DPRINT1("Queueing IRP\n");
|
||||
IoMarkIrpPending(Irp);
|
||||
Status = STATUS_PENDING;
|
||||
break;
|
||||
}
|
||||
|
||||
Status = HandleUrbRequest(PdoDeviceExtension, Irp);
|
||||
|
||||
break;
|
||||
}
|
||||
case IOCTL_INTERNAL_USB_CYCLE_PORT:
|
||||
|
@ -166,11 +206,11 @@ PdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
}
|
||||
case IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE:
|
||||
{
|
||||
DPRINT1("IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE %x\n", IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE);
|
||||
DPRINT("Ehci: IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE %x\n", Stack->Parameters.Others.Argument2);
|
||||
if (Stack->Parameters.Others.Argument1)
|
||||
{
|
||||
/* Return the root hubs devicehandle */
|
||||
DPRINT1("Returning RootHub Handle %x\n", PdoDeviceExtension->UsbDevices[0]);
|
||||
DPRINT("Returning RootHub Handle %x\n", PdoDeviceExtension->UsbDevices[0]);
|
||||
*(PVOID *)Stack->Parameters.Others.Argument1 = (PVOID)PdoDeviceExtension->UsbDevices[0];
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -182,13 +222,13 @@ PdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
}
|
||||
case IOCTL_INTERNAL_USB_GET_HUB_COUNT:
|
||||
{
|
||||
DPRINT1("IOCTL_INTERNAL_USB_GET_HUB_COUNT %x\n", IOCTL_INTERNAL_USB_GET_HUB_COUNT);
|
||||
DPRINT("Ehci: IOCTL_INTERNAL_USB_GET_HUB_COUNT %x\n", IOCTL_INTERNAL_USB_GET_HUB_COUNT);
|
||||
ASSERT(Stack->Parameters.Others.Argument1 != NULL);
|
||||
if (Stack->Parameters.Others.Argument1)
|
||||
{
|
||||
/* FIXME: Determine the number of hubs between the usb device and root hub */
|
||||
DPRINT1("RootHubCount %x\n", *(PULONG)Stack->Parameters.Others.Argument1);
|
||||
*(PULONG)Stack->Parameters.Others.Argument1 = 0;
|
||||
*(PULONG)Stack->Parameters.Others.Argument1 = 1;
|
||||
}
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
@ -215,12 +255,14 @@ PdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
}
|
||||
case IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO:
|
||||
{
|
||||
DPRINT1("IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO\n");
|
||||
|
||||
DPRINT("Ehci: IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO Arg1 %x, Arg2 %x\n", Stack->Parameters.Others.Argument1, Stack->Parameters.Others.Argument2);
|
||||
if (Stack->Parameters.Others.Argument1)
|
||||
*(PVOID *)Stack->Parameters.Others.Argument1 = FdoDeviceExtension->Pdo;
|
||||
|
||||
/* Windows usbehci driver gives the Pdo in both Arguments. */
|
||||
if (Stack->Parameters.Others.Argument2)
|
||||
*(PVOID *)Stack->Parameters.Others.Argument2 = IoGetAttachedDeviceReference(FdoDeviceExtension->DeviceObject);
|
||||
//*(PVOID *)Stack->Parameters.Others.Argument2 = IoGetAttachedDeviceReference(FdoDeviceExtension->DeviceObject);
|
||||
*(PVOID *)Stack->Parameters.Others.Argument2 = FdoDeviceExtension->Pdo;
|
||||
|
||||
Information = 0;
|
||||
Status = STATUS_SUCCESS;
|
||||
|
@ -229,7 +271,7 @@ PdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
case IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION:
|
||||
{
|
||||
PUSB_IDLE_CALLBACK_INFO CallBackInfo;
|
||||
DPRINT1("IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION\n");
|
||||
DPRINT1("Ehci: IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION\n");
|
||||
/* FIXME: Set Callback for safe power down */
|
||||
CallBackInfo = Stack->Parameters.DeviceIoControl.Type3InputBuffer;
|
||||
DPRINT1("IdleCallback %x\n", CallBackInfo->IdleCallback);
|
||||
|
@ -368,16 +410,20 @@ PdoDispatchPnp(
|
|||
UNICODE_STRING InterfaceSymLinkName;
|
||||
LONG i;
|
||||
|
||||
DPRINT1("Ehci: PDO StartDevice\n");
|
||||
PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)PdoDeviceExtension->ControllerFdo->DeviceExtension;
|
||||
|
||||
/* Create the root hub */
|
||||
RootHubDevice = InternalCreateUsbDevice(1, 0, NULL, TRUE);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
for (i = 0; i < PdoDeviceExtension->NumberOfPorts; i++)
|
||||
{
|
||||
PdoDeviceExtension->Ports[i].PortStatus = USB_PORT_STATUS_ENABLE;
|
||||
PdoDeviceExtension->Ports[i].PortStatus = USB_PORT_STATUS_HIGH_SPEED | 0x8000;
|
||||
PdoDeviceExtension->Ports[i].PortChange = 0;
|
||||
|
||||
if (!FdoDeviceExtension->ECHICaps.HCSParams.PortPowerControl)
|
||||
PdoDeviceExtension->Ports[i].PortStatus |= USB_PORT_STATUS_POWER;
|
||||
}
|
||||
|
||||
RtlCopyMemory(&RootHubDevice->DeviceDescriptor,
|
||||
|
@ -425,7 +471,7 @@ PdoDispatchPnp(
|
|||
PdoDeviceExtension->UsbDevices[0] = RootHubDevice;
|
||||
|
||||
/* Create a thread to handle the URB's */
|
||||
|
||||
/*
|
||||
Status = PsCreateSystemThread(&PdoDeviceExtension->ThreadHandle,
|
||||
THREAD_ALL_ACCESS,
|
||||
NULL,
|
||||
|
@ -436,18 +482,18 @@ PdoDispatchPnp(
|
|||
|
||||
if (!NT_SUCCESS(Status))
|
||||
DPRINT1("Failed Thread Creation with Status: %x\n", Status);
|
||||
|
||||
*/
|
||||
Status = IoRegisterDeviceInterface(DeviceObject, &GUID_DEVINTERFACE_USB_HUB, NULL, &InterfaceSymLinkName);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Failed to register interface\n");
|
||||
ASSERT(FALSE);
|
||||
return Status;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = IoSetDeviceInterfaceState(&InterfaceSymLinkName, TRUE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
ASSERT(FALSE);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
|
@ -455,6 +501,7 @@ PdoDispatchPnp(
|
|||
}
|
||||
case IRP_MN_QUERY_DEVICE_RELATIONS:
|
||||
{
|
||||
DPRINT1("Ehci: PDO QueryDeviceRelations\n");
|
||||
switch (Stack->Parameters.QueryDeviceRelations.Type)
|
||||
{
|
||||
case TargetDeviceRelation:
|
||||
|
@ -499,6 +546,7 @@ PdoDispatchPnp(
|
|||
}
|
||||
case IRP_MN_QUERY_CAPABILITIES:
|
||||
{
|
||||
DPRINT("Ehci: PDO Query Capabilities\n");
|
||||
PDEVICE_CAPABILITIES DeviceCapabilities;
|
||||
ULONG i;
|
||||
|
||||
|
@ -538,6 +586,7 @@ PdoDispatchPnp(
|
|||
|
||||
case IRP_MN_QUERY_ID:
|
||||
{
|
||||
DPRINT("Ehci: PDO Query ID\n");
|
||||
Status = PdoQueryId(DeviceObject, Irp, &Information);
|
||||
break;
|
||||
}
|
||||
|
@ -549,6 +598,8 @@ PdoDispatchPnp(
|
|||
PPDO_DEVICE_EXTENSION PdoDeviceExtension;
|
||||
PFDO_DEVICE_EXTENSION FdoDeviceExtension;
|
||||
|
||||
DPRINT("Ehci: PDO Query Interface\n");
|
||||
|
||||
PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)PdoDeviceExtension->ControllerFdo->DeviceExtension;
|
||||
|
||||
|
@ -558,10 +609,6 @@ PdoDispatchPnp(
|
|||
DPRINT1("Failed to create string from GUID!\n");
|
||||
}
|
||||
|
||||
DPRINT("Interface GUID requested %wZ\n", &GuidString);
|
||||
DPRINT("QueryInterface.Size %x\n", Stack->Parameters.QueryInterface.Size);
|
||||
DPRINT("QueryInterface.Version %x\n", Stack->Parameters.QueryInterface.Version);
|
||||
|
||||
/* Assume success */
|
||||
Status = STATUS_SUCCESS;
|
||||
Information = 0;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* FILE: drivers/usb/usbehci/urbreq.c
|
||||
* PURPOSE: URB Related Functions.
|
||||
* PROGRAMMERS:
|
||||
* Michael Martin (mjmartin@reactos.org)
|
||||
* Michael Martin (michael.martin@reactos.org)
|
||||
*/
|
||||
|
||||
#include "usbehci.h"
|
||||
|
@ -125,6 +125,8 @@ ExecuteControlRequest(PFDO_DEVICE_EXTENSION DeviceExtension, PUSB_DEFAULT_PIPE_S
|
|||
|
||||
DPRINT1("ExecuteControlRequest: Buffer %x, Length %x\n", Buffer, BufferLength);
|
||||
|
||||
ExAcquireFastMutex(&DeviceExtension->AsyncListMutex);
|
||||
|
||||
Base = (ULONG) DeviceExtension->ResourceMemory;
|
||||
|
||||
/* Set up the QUEUE HEAD in memory */
|
||||
|
@ -198,7 +200,7 @@ ExecuteControlRequest(PFDO_DEVICE_EXTENSION DeviceExtension, PUSB_DEFAULT_PIPE_S
|
|||
UsbCmd->Run = FALSE;
|
||||
WRITE_REGISTER_ULONG((PULONG)(Base + EHCI_USBCMD), tmp);
|
||||
|
||||
if (CtrlSetup->bmRequestType._BM.Dir == BMREQUEST_DEVICE_TO_HOST)
|
||||
if (SetupPacket->bmRequestType._BM.Dir == BMREQUEST_DEVICE_TO_HOST)
|
||||
{
|
||||
if ((Buffer) && (BufferLength))
|
||||
{
|
||||
|
@ -208,5 +210,7 @@ ExecuteControlRequest(PFDO_DEVICE_EXTENSION DeviceExtension, PUSB_DEFAULT_PIPE_S
|
|||
DPRINT1("Unable to copy data to buffer\n");
|
||||
}
|
||||
|
||||
ExReleaseFastMutex(&DeviceExtension->AsyncListMutex);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* FILE: drivers/usb/usbehci/usbehci.c
|
||||
* PURPOSE: USB EHCI device driver.
|
||||
* PROGRAMMERS:
|
||||
* Michael Martin (mjmartin@reactos.com)
|
||||
* Michael Martin (michael.martin@reactos.org)
|
||||
*/
|
||||
|
||||
/* DEFINES *******************************************************************/
|
||||
|
|
|
@ -361,10 +361,13 @@ typedef struct _FDO_DEVICE_EXTENSION
|
|||
ULONG Vector;
|
||||
KIRQL Irql;
|
||||
|
||||
KTIMER UpdateTimer;
|
||||
KINTERRUPT_MODE Mode;
|
||||
BOOLEAN IrqShared;
|
||||
PKINTERRUPT EhciInterrupt;
|
||||
KDPC DpcObject;
|
||||
KDPC TimerDpcObject;
|
||||
|
||||
KAFFINITY Affinity;
|
||||
|
||||
ULONG MapRegisters;
|
||||
|
@ -390,6 +393,9 @@ typedef struct _FDO_DEVICE_EXTENSION
|
|||
PHYSICAL_ADDRESS PeriodicFramListPhysAddr;
|
||||
PHYSICAL_ADDRESS AsyncListQueueHeadPtrPhysAddr;
|
||||
|
||||
FAST_MUTEX AsyncListMutex;
|
||||
FAST_MUTEX FrameListMutex;
|
||||
|
||||
BOOLEAN AsyncComplete;
|
||||
|
||||
PULONG ResourceBase;
|
||||
|
@ -461,14 +467,23 @@ FdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
|||
BOOLEAN
|
||||
ExecuteControlRequest(PFDO_DEVICE_EXTENSION DeviceExtension, PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket, UCHAR Address, ULONG Port, PVOID Buffer, ULONG BufferLength);
|
||||
|
||||
VOID
|
||||
RequestURBCancel (PPDO_DEVICE_EXTENSION DeviceExtension, PIRP Irp);
|
||||
|
||||
VOID
|
||||
RemoveUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp);
|
||||
|
||||
VOID
|
||||
QueueURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension, PIRP Irp);
|
||||
|
||||
VOID
|
||||
CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension);
|
||||
|
||||
VOID
|
||||
URBRequestCancel (PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS
|
||||
HandleUrbRequest(PPDO_DEVICE_EXTENSION DeviceExtension, PIRP Irp);
|
||||
|
||||
PUSB_DEVICE
|
||||
DeviceHandleToUsbDevice(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PUSB_DEVICE_HANDLE DeviceHandle);
|
||||
|
||||
BOOLEAN
|
||||
ResetPort(PFDO_DEVICE_EXTENSION FdoDeviceExtension, UCHAR Port);
|
|
@ -4,7 +4,7 @@
|
|||
* FILE: drivers/usb/usbehci/usbiffn.c
|
||||
* PURPOSE: Direct Call Interface Functions.
|
||||
* PROGRAMMERS:
|
||||
* Michael Martin (mjmartin@reactos.org)
|
||||
* Michael Martin (michael.martin@reactos.org)
|
||||
*/
|
||||
|
||||
#include "usbehci.h"
|
||||
|
@ -14,6 +14,7 @@
|
|||
PVOID InternalCreateUsbDevice(UCHAR DeviceNumber, ULONG Port, PUSB_DEVICE Parent, BOOLEAN Hub)
|
||||
{
|
||||
PUSB_DEVICE UsbDevicePointer = NULL;
|
||||
|
||||
UsbDevicePointer = ExAllocatePoolWithTag(NonPagedPool, sizeof(USB_DEVICE), USB_POOL_TAG);
|
||||
|
||||
if (!UsbDevicePointer)
|
||||
|
@ -29,7 +30,7 @@ PVOID InternalCreateUsbDevice(UCHAR DeviceNumber, ULONG Port, PUSB_DEVICE Parent
|
|||
DPRINT1("This is the root hub\n");
|
||||
}
|
||||
|
||||
UsbDevicePointer->Address = DeviceNumber;
|
||||
UsbDevicePointer->Address = 0;// DeviceNumber;
|
||||
UsbDevicePointer->Port = Port;
|
||||
UsbDevicePointer->ParentDevice = Parent;
|
||||
|
||||
|
@ -42,14 +43,14 @@ VOID
|
|||
USB_BUSIFFN
|
||||
InterfaceReference(PVOID BusContext)
|
||||
{
|
||||
DPRINT1("InterfaceReference called\n");
|
||||
DPRINT1("Ehci: InterfaceReference called\n");
|
||||
}
|
||||
|
||||
VOID
|
||||
USB_BUSIFFN
|
||||
InterfaceDereference(PVOID BusContext)
|
||||
{
|
||||
DPRINT1("InterfaceDereference called\n");
|
||||
DPRINT1("Ehci: InterfaceDereference called\n");
|
||||
}
|
||||
|
||||
/* Bus Interface Hub V5 Functions */
|
||||
|
@ -65,7 +66,7 @@ CreateUsbDevice(PVOID BusContext,
|
|||
PUSB_DEVICE UsbDevice;
|
||||
LONG i = 0;
|
||||
PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)BusContext)->DeviceExtension;
|
||||
DPRINT("CreateUsbDevice: HubDeviceHandle %x, PortStatus %x, PortNumber %x\n", HubDeviceHandle, PortStatus, PortNumber);
|
||||
DPRINT1("Ehci: CreateUsbDevice: HubDeviceHandle %x, PortStatus %x, PortNumber %x\n", HubDeviceHandle, PortStatus, PortNumber);
|
||||
|
||||
if (PdoDeviceExtension->UsbDevices[0] != HubDeviceHandle)
|
||||
{
|
||||
|
@ -84,8 +85,6 @@ CreateUsbDevice(PVOID BusContext,
|
|||
if (PdoDeviceExtension->UsbDevices[i] == NULL)
|
||||
{
|
||||
PdoDeviceExtension->UsbDevices[i] = (PUSB_DEVICE)UsbDevice;
|
||||
PdoDeviceExtension->UsbDevices[i]->Address = i + 1;
|
||||
PdoDeviceExtension->UsbDevices[i]->Port = PortNumber;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
|
@ -116,7 +115,7 @@ InitializeUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE DeviceHandle)
|
|||
PUCHAR Ptr;
|
||||
LONG i, j, k;
|
||||
|
||||
DPRINT1("InitializeUsbDevice called, device %x\n", DeviceHandle);
|
||||
DPRINT1("Ehci: InitializeUsbDevice called, device %x\n", DeviceHandle);
|
||||
PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)BusContext)->DeviceExtension;
|
||||
FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)PdoDeviceExtension->ControllerFdo->DeviceExtension;
|
||||
|
||||
|
@ -139,8 +138,10 @@ InitializeUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE DeviceHandle)
|
|||
Ptr = Buffer;
|
||||
|
||||
/* Set the device address */
|
||||
/*
|
||||
CtrlSetup.bmRequestType._BM.Recipient = BMREQUEST_TO_DEVICE;
|
||||
CtrlSetup.bmRequestType._BM.Type = BMREQUEST_STANDARD;
|
||||
CtrlSetup.bmRequestType._BM.Reserved = 0;
|
||||
CtrlSetup.bmRequestType._BM.Dir = BMREQUEST_HOST_TO_DEVICE;
|
||||
CtrlSetup.bRequest = USB_REQUEST_SET_ADDRESS;
|
||||
CtrlSetup.wValue.W = UsbDevice->Address;
|
||||
|
@ -150,6 +151,8 @@ InitializeUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE DeviceHandle)
|
|||
DPRINT1("Setting Address to %x\n", UsbDevice->Address);
|
||||
ResultOk = ExecuteControlRequest(FdoDeviceExtension, &CtrlSetup, 0, UsbDevice->Port, NULL, 0);
|
||||
|
||||
*/
|
||||
|
||||
/* Get the Device Descriptor */
|
||||
CtrlSetup.bmRequestType._BM.Recipient = BMREQUEST_TO_DEVICE;
|
||||
CtrlSetup.bmRequestType._BM.Type = BMREQUEST_STANDARD;
|
||||
|
@ -209,6 +212,7 @@ InitializeUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE DeviceHandle)
|
|||
sizeof(USB_CONFIGURATION) + sizeof(PVOID) * ConfigDesc->bNumInterfaces,
|
||||
USB_POOL_TAG);
|
||||
UsbDevice->Configs[i]->Device = UsbDevice;
|
||||
|
||||
RtlCopyMemory(&UsbDevice->Configs[0]->ConfigurationDescriptor,
|
||||
ConfigDesc, sizeof(USB_CONFIGURATION_DESCRIPTOR));
|
||||
Ptr += ConfigDesc->bLength;
|
||||
|
@ -252,7 +256,7 @@ GetUsbDescriptors(PVOID BusContext,
|
|||
PULONG ConfigDescriptorBufferLength)
|
||||
{
|
||||
PUSB_DEVICE UsbDevice;
|
||||
DPRINT1("GetUsbDescriptor %x, %x, %x, %x\n", DeviceDescriptorBuffer, *DeviceDescriptorBufferLength, ConfigDescriptorBuffer, *ConfigDescriptorBufferLength);
|
||||
DPRINT1("Ehci: GetUsbDescriptor %x, %x, %x, %x\n", DeviceDescriptorBuffer, *DeviceDescriptorBufferLength, ConfigDescriptorBuffer, *ConfigDescriptorBufferLength);
|
||||
|
||||
UsbDevice = DeviceHandleToUsbDevice(BusContext, DeviceHandle);
|
||||
|
||||
|
@ -267,6 +271,7 @@ GetUsbDescriptors(PVOID BusContext,
|
|||
RtlCopyMemory(DeviceDescriptorBuffer, &UsbDevice->DeviceDescriptor, sizeof(USB_DEVICE_DESCRIPTOR));
|
||||
*DeviceDescriptorBufferLength = sizeof(USB_DEVICE_DESCRIPTOR);
|
||||
}
|
||||
|
||||
if ((ConfigDescriptorBuffer) && (ConfigDescriptorBufferLength))
|
||||
{
|
||||
RtlCopyMemory(ConfigDescriptorBuffer, &UsbDevice->ActiveConfig->ConfigurationDescriptor, sizeof(USB_CONFIGURATION_DESCRIPTOR));
|
||||
|
@ -340,7 +345,7 @@ NTSTATUS
|
|||
USB_BUSIFFN
|
||||
RestoreUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE OldDeviceHandle, PUSB_DEVICE_HANDLE NewDeviceHandle)
|
||||
{
|
||||
DPRINT1("RestoreUsbDevice called\n");
|
||||
DPRINT1("Ehci: RestoreUsbDevice called\n");
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
@ -348,7 +353,7 @@ NTSTATUS
|
|||
USB_BUSIFFN
|
||||
GetPortHackFlags(PVOID BusContext, PULONG Flags)
|
||||
{
|
||||
DPRINT1("GetPortHackFlags called\n");
|
||||
DPRINT1("Ehci: GetPortHackFlags called\n");
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
@ -365,7 +370,7 @@ QueryDeviceInformation(PVOID BusContext,
|
|||
ULONG SizeNeeded;
|
||||
LONG i;
|
||||
|
||||
DPRINT1("QueryDeviceInformation (%x, %x, %x, %d, %x\n", BusContext, DeviceHandle, DeviceInformationBuffer, DeviceInformationBufferLength, LengthReturned);
|
||||
DPRINT1("Ehci: QueryDeviceInformation (%x, %x, %x, %d, %x\n", BusContext, DeviceHandle, DeviceInformationBuffer, DeviceInformationBufferLength, LengthReturned);
|
||||
|
||||
UsbDevice = DeviceHandleToUsbDevice(BusContext, DeviceHandle);
|
||||
|
||||
|
@ -418,7 +423,7 @@ GetControllerInformation(PVOID BusContext,
|
|||
{
|
||||
PUSB_CONTROLLER_INFORMATION_0 ControllerInfo;
|
||||
|
||||
DPRINT1("GetControllerInformation called\n");
|
||||
DPRINT1("Ehci: GetControllerInformation called\n");
|
||||
|
||||
ControllerInfo = ControllerInformationBuffer;
|
||||
|
||||
|
@ -447,7 +452,7 @@ NTSTATUS
|
|||
USB_BUSIFFN
|
||||
ControllerSelectiveSuspend(PVOID BusContext, BOOLEAN Enable)
|
||||
{
|
||||
DPRINT1("ControllerSelectiveSuspend called\n");
|
||||
DPRINT1("Ehci: ControllerSelectiveSuspend called\n");
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
@ -464,13 +469,16 @@ GetExtendedHubInformation(PVOID BusContext,
|
|||
PPDO_DEVICE_EXTENSION PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)BusContext)->DeviceExtension;
|
||||
PFDO_DEVICE_EXTENSION FdoDeviceExntension = (PFDO_DEVICE_EXTENSION)PdoDeviceExtension->ControllerFdo->DeviceExtension;
|
||||
LONG i;
|
||||
DPRINT1("GetExtendedHubInformation\n");
|
||||
DPRINT1("Ehci: GetExtendedHubInformation BusContext %x, PDO %x\n", BusContext, HubPhysicalDeviceObject);
|
||||
/* Set the default return value */
|
||||
*LengthReturned = 0;
|
||||
/* Caller must have set InformationLevel to 0 */
|
||||
|
||||
DPRINT1("InformationLevel %x\n", UsbExtHubInfo->InformationLevel);
|
||||
|
||||
/* Caller is suppose to have set InformationLevel to 0. However usbehci from MS seems to ignore this */
|
||||
if (UsbExtHubInfo->InformationLevel != 0)
|
||||
{
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
DPRINT1("InformationLevel should really be set to 0. Ignoring\n");
|
||||
}
|
||||
|
||||
UsbExtHubInfo->NumberOfPorts = 8;
|
||||
|
@ -496,7 +504,7 @@ GetRootHubSymbolicName(PVOID BusContext,
|
|||
ULONG HubSymNameBufferLength,
|
||||
PULONG HubSymNameActualLength)
|
||||
{
|
||||
DPRINT1("GetRootHubSymbolicName called\n");
|
||||
DPRINT1("Ehci: GetRootHubSymbolicName called\n");
|
||||
|
||||
if (HubSymNameBufferLength < 16)
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
|
@ -512,7 +520,7 @@ GetDeviceBusContext(PVOID HubBusContext, PVOID DeviceHandle)
|
|||
{
|
||||
PUSB_DEVICE UsbDevice;
|
||||
|
||||
DPRINT1("GetDeviceBusContext called\n");
|
||||
DPRINT1("Ehci: GetDeviceBusContext called\n");
|
||||
UsbDevice = DeviceHandleToUsbDevice(HubBusContext, DeviceHandle);
|
||||
|
||||
if (!UsbDevice)
|
||||
|
@ -528,8 +536,7 @@ NTSTATUS
|
|||
USB_BUSIFFN
|
||||
Initialize20Hub(PVOID BusContext, PUSB_DEVICE_HANDLE HubDeviceHandle, ULONG TtCount)
|
||||
{
|
||||
DPRINT1("Initialize20Hub called, HubDeviceHandle: %x\n", HubDeviceHandle);
|
||||
|
||||
DPRINT1("Ehci: Initialize20Hub called, HubDeviceHandle: %x\n", HubDeviceHandle);
|
||||
/* FIXME: */
|
||||
/* Create the Irp Queue for SCE */
|
||||
/* Should queue be created for each device or each enpoint??? */
|
||||
|
@ -541,7 +548,7 @@ USB_BUSIFFN
|
|||
RootHubInitNotification(PVOID BusContext, PVOID CallbackContext, PRH_INIT_CALLBACK CallbackRoutine)
|
||||
{
|
||||
PPDO_DEVICE_EXTENSION PdoDeviceExtension;
|
||||
DPRINT1("RootHubInitNotification %x, %x, %x\n", BusContext, CallbackContext, CallbackRoutine);
|
||||
DPRINT1("Ehci: RootHubInitNotification %x, %x, %x\n", BusContext, CallbackContext, CallbackRoutine);
|
||||
|
||||
PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)BusContext)->DeviceExtension;
|
||||
PdoDeviceExtension->CallbackContext = CallbackContext;
|
||||
|
@ -579,7 +586,7 @@ VOID
|
|||
USB_BUSIFFN
|
||||
SetDeviceHandleData(PVOID BusContext, PVOID DeviceHandle, PDEVICE_OBJECT UsbDevicePdo)
|
||||
{
|
||||
DPRINT1("SetDeviceHandleData called\n");
|
||||
DPRINT1("Ehci: SetDeviceHandleData called\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -589,7 +596,7 @@ VOID
|
|||
USB_BUSIFFN
|
||||
GetUSBDIVersion(PVOID BusContext, PUSBD_VERSION_INFORMATION VersionInformation, PULONG HcdCapabilites)
|
||||
{
|
||||
DPRINT1("GetUSBDIVersion called\n");
|
||||
DPRINT1("Ehci: GetUSBDIVersion called\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -597,7 +604,7 @@ NTSTATUS
|
|||
USB_BUSIFFN
|
||||
QueryBusTime(PVOID BusContext, PULONG CurrentFrame)
|
||||
{
|
||||
DPRINT1("QueryBusTime called\n");
|
||||
DPRINT1("Ehci: QueryBusTime called\n");
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
@ -605,7 +612,7 @@ NTSTATUS
|
|||
USB_BUSIFFN
|
||||
SubmitIsoOutUrb(PVOID BusContext, PURB Urb)
|
||||
{
|
||||
DPRINT1("SubmitIsoOutUrb called\n");
|
||||
DPRINT1("Ehci: SubmitIsoOutUrb called\n");
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
@ -617,7 +624,7 @@ QueryBusInformation(PVOID BusContext,
|
|||
PULONG BusInformationBufferLength,
|
||||
PULONG BusInformationActualLength)
|
||||
{
|
||||
DPRINT1("QueryBusInformation called\n");
|
||||
DPRINT1("Ehci: QueryBusInformation called\n");
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
@ -625,7 +632,7 @@ BOOLEAN
|
|||
USB_BUSIFFN
|
||||
IsDeviceHighSpeed(PVOID BusContext)
|
||||
{
|
||||
DPRINT1("IsDeviceHighSpeed called\n");
|
||||
DPRINT1("Ehci: IsDeviceHighSpeed called\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -633,6 +640,6 @@ NTSTATUS
|
|||
USB_BUSIFFN
|
||||
EnumLogEntry(PVOID BusContext, ULONG DriverTag, ULONG EnumTag, ULONG P1, ULONG P2)
|
||||
{
|
||||
DPRINT1("EnumLogEntry called\n");
|
||||
DPRINT1("Ehci: EnumLogEntry called\n");
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -4,7 +4,7 @@
|
|||
* FILE: drivers/usb/cromwell/hub/misc.c
|
||||
* PURPOSE: Misceallenous operations
|
||||
*
|
||||
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.com),
|
||||
* PROGRAMMERS: Herv<EFBFBD> Poussineau (hpoussin@reactos.com),
|
||||
*/
|
||||
|
||||
#define NDEBUG
|
||||
|
@ -13,54 +13,50 @@
|
|||
|
||||
NTSTATUS NTAPI
|
||||
ForwardIrpAndWaitCompletion(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
IN PVOID Context)
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
IN PVOID Context)
|
||||
{
|
||||
if (Irp->PendingReturned)
|
||||
KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
|
||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
||||
if (Irp->PendingReturned)
|
||||
KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
|
||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
ForwardIrpAndWait(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PDEVICE_OBJECT LowerDevice = ((PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
||||
KEVENT Event;
|
||||
NTSTATUS Status;
|
||||
KEVENT Event;
|
||||
NTSTATUS Status;
|
||||
|
||||
ASSERT(LowerDevice);
|
||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||
|
||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
||||
|
||||
DPRINT("UHCI: Calling lower device %p [%wZ]\n", LowerDevice, &LowerDevice->DriverObject->DriverName);
|
||||
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
||||
Status = IoCallDriver(DeviceObject, Irp);
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
||||
if (NT_SUCCESS(Status))
|
||||
Status = Irp->IoStatus.Status;
|
||||
}
|
||||
|
||||
Status = IoCallDriver(LowerDevice, Irp);
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
||||
if (NT_SUCCESS(Status))
|
||||
Status = Irp->IoStatus.Status;
|
||||
}
|
||||
|
||||
return Status;
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS NTAPI
|
||||
ForwardIrpAndForget(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PDEVICE_OBJECT LowerDevice = ((PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
||||
PDEVICE_OBJECT LowerDevice = ((PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
||||
|
||||
ASSERT(LowerDevice);
|
||||
ASSERT(LowerDevice);
|
||||
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(LowerDevice, Irp);
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(LowerDevice, Irp);
|
||||
}
|
||||
|
||||
/* I really want PCSZ strings as last arguments because
|
||||
|
@ -68,99 +64,99 @@ ForwardIrpAndForget(
|
|||
* identification */
|
||||
NTSTATUS
|
||||
UsbhubInitMultiSzString(
|
||||
OUT PUNICODE_STRING Destination,
|
||||
... /* list of PCSZ */)
|
||||
OUT PUNICODE_STRING Destination,
|
||||
... /* list of PCSZ */)
|
||||
{
|
||||
va_list args;
|
||||
PCSZ Source;
|
||||
ANSI_STRING AnsiString;
|
||||
UNICODE_STRING UnicodeString;
|
||||
ULONG DestinationSize = 0;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
va_list args;
|
||||
PCSZ Source;
|
||||
ANSI_STRING AnsiString;
|
||||
UNICODE_STRING UnicodeString;
|
||||
ULONG DestinationSize = 0;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
ASSERT(Destination);
|
||||
ASSERT(Destination);
|
||||
|
||||
/* Calculate length needed for destination unicode string */
|
||||
va_start(args, Destination);
|
||||
Source = va_arg(args, PCSZ);
|
||||
while (Source != NULL)
|
||||
{
|
||||
RtlInitAnsiString(&AnsiString, Source);
|
||||
DestinationSize += RtlAnsiStringToUnicodeSize(&AnsiString)
|
||||
+ sizeof(WCHAR) /* final NULL */;
|
||||
Source = va_arg(args, PCSZ);
|
||||
}
|
||||
va_end(args);
|
||||
if (DestinationSize == 0)
|
||||
{
|
||||
RtlInitUnicodeString(Destination, NULL);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
/* Calculate length needed for destination unicode string */
|
||||
va_start(args, Destination);
|
||||
Source = va_arg(args, PCSZ);
|
||||
while (Source != NULL)
|
||||
{
|
||||
RtlInitAnsiString(&AnsiString, Source);
|
||||
DestinationSize += RtlAnsiStringToUnicodeSize(&AnsiString)
|
||||
+ sizeof(WCHAR) /* final NULL */;
|
||||
Source = va_arg(args, PCSZ);
|
||||
}
|
||||
va_end(args);
|
||||
if (DestinationSize == 0)
|
||||
{
|
||||
RtlInitUnicodeString(Destination, NULL);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* Initialize destination string */
|
||||
DestinationSize += sizeof(WCHAR); // final NULL
|
||||
Destination->Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool, DestinationSize, USB_HUB_TAG);
|
||||
if (!Destination->Buffer)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
Destination->Length = 0;
|
||||
Destination->MaximumLength = (USHORT)DestinationSize;
|
||||
/* Initialize destination string */
|
||||
DestinationSize += sizeof(WCHAR); // final NULL
|
||||
Destination->Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool, DestinationSize, USB_HUB_TAG);
|
||||
if (!Destination->Buffer)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
Destination->Length = 0;
|
||||
Destination->MaximumLength = (USHORT)DestinationSize;
|
||||
|
||||
/* Copy arguments to destination string */
|
||||
/* Use a temporary unicode string, which buffer is shared with
|
||||
* destination string, to copy arguments */
|
||||
UnicodeString.Length = Destination->Length;
|
||||
UnicodeString.MaximumLength = Destination->MaximumLength;
|
||||
UnicodeString.Buffer = Destination->Buffer;
|
||||
va_start(args, Destination);
|
||||
Source = va_arg(args, PCSZ);
|
||||
while (Source != NULL)
|
||||
{
|
||||
RtlInitAnsiString(&AnsiString, Source);
|
||||
Status = RtlAnsiStringToUnicodeString(&UnicodeString, &AnsiString, FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ExFreePoolWithTag(Destination->Buffer, USB_HUB_TAG);
|
||||
break;
|
||||
}
|
||||
Destination->Length += UnicodeString.Length + sizeof(WCHAR);
|
||||
UnicodeString.MaximumLength -= UnicodeString.Length + sizeof(WCHAR);
|
||||
UnicodeString.Buffer += UnicodeString.Length / sizeof(WCHAR) + 1;
|
||||
UnicodeString.Length = 0;
|
||||
Source = va_arg(args, PCSZ);
|
||||
}
|
||||
va_end(args);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* Finish multi-sz string */
|
||||
Destination->Buffer[Destination->Length / sizeof(WCHAR)] = L'\0';
|
||||
Destination->Length += sizeof(WCHAR);
|
||||
}
|
||||
return Status;
|
||||
/* Copy arguments to destination string */
|
||||
/* Use a temporary unicode string, which buffer is shared with
|
||||
* destination string, to copy arguments */
|
||||
UnicodeString.Length = Destination->Length;
|
||||
UnicodeString.MaximumLength = Destination->MaximumLength;
|
||||
UnicodeString.Buffer = Destination->Buffer;
|
||||
va_start(args, Destination);
|
||||
Source = va_arg(args, PCSZ);
|
||||
while (Source != NULL)
|
||||
{
|
||||
RtlInitAnsiString(&AnsiString, Source);
|
||||
Status = RtlAnsiStringToUnicodeString(&UnicodeString, &AnsiString, FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ExFreePoolWithTag(Destination->Buffer, USB_HUB_TAG);
|
||||
break;
|
||||
}
|
||||
Destination->Length += UnicodeString.Length + sizeof(WCHAR);
|
||||
UnicodeString.MaximumLength -= UnicodeString.Length + sizeof(WCHAR);
|
||||
UnicodeString.Buffer += UnicodeString.Length / sizeof(WCHAR) + 1;
|
||||
UnicodeString.Length = 0;
|
||||
Source = va_arg(args, PCSZ);
|
||||
}
|
||||
va_end(args);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* Finish multi-sz string */
|
||||
Destination->Buffer[Destination->Length / sizeof(WCHAR)] = L'\0';
|
||||
Destination->Length += sizeof(WCHAR);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
UsbhubDuplicateUnicodeString(
|
||||
OUT PUNICODE_STRING Destination,
|
||||
IN PUNICODE_STRING Source,
|
||||
IN POOL_TYPE PoolType)
|
||||
OUT PUNICODE_STRING Destination,
|
||||
IN PUNICODE_STRING Source,
|
||||
IN POOL_TYPE PoolType)
|
||||
{
|
||||
ASSERT(Destination);
|
||||
ASSERT(Destination);
|
||||
|
||||
if (Source == NULL)
|
||||
{
|
||||
RtlInitUnicodeString(Destination, NULL);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
if (Source == NULL)
|
||||
{
|
||||
RtlInitUnicodeString(Destination, NULL);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
Destination->Buffer = ExAllocatePool(PoolType, Source->MaximumLength);
|
||||
if (Destination->Buffer == NULL)
|
||||
{
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
Destination->Buffer = ExAllocatePool(PoolType, Source->MaximumLength);
|
||||
if (Destination->Buffer == NULL)
|
||||
{
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
Destination->MaximumLength = Source->MaximumLength;
|
||||
Destination->Length = Source->Length;
|
||||
RtlCopyMemory(Destination->Buffer, Source->Buffer, Source->MaximumLength);
|
||||
Destination->MaximumLength = Source->MaximumLength;
|
||||
Destination->Length = Source->Length;
|
||||
RtlCopyMemory(Destination->Buffer, Source->Buffer, Source->MaximumLength);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* PURPOSE: IRP_MJ_PNP operations for PDOs
|
||||
*
|
||||
* PROGRAMMERS: Copyright 2005-2006 Hervé Poussineau (hpoussin@reactos.org)
|
||||
* 2010 Michael Martin (michael.martin@reactos.org)
|
||||
*/
|
||||
|
||||
#define NDEBUG
|
||||
|
@ -15,333 +16,299 @@
|
|||
|
||||
NTSTATUS
|
||||
UsbhubInternalDeviceControlPdo(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION Stack;
|
||||
ULONG_PTR Information = 0;
|
||||
NTSTATUS Status;
|
||||
PIO_STACK_LOCATION Stack;
|
||||
ULONG_PTR Information = 0;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("Usbhub: UsbhubInternalDeviceControlPdo() called\n");
|
||||
DPRINT1("Usbhub: UsbhubInternalDeviceControlPdo() called\n");
|
||||
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
Status = Irp->IoStatus.Status;
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
Status = Irp->IoStatus.Status;
|
||||
|
||||
switch (Stack->Parameters.DeviceIoControl.IoControlCode)
|
||||
{
|
||||
case IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO:
|
||||
{
|
||||
PHUB_DEVICE_EXTENSION DeviceExtension;
|
||||
switch (Stack->Parameters.DeviceIoControl.IoControlCode)
|
||||
{
|
||||
case IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO:
|
||||
{
|
||||
PHUB_DEVICE_EXTENSION DeviceExtension;
|
||||
|
||||
DPRINT("Usbhub: IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO\n");
|
||||
if (Irp->AssociatedIrp.SystemBuffer == NULL
|
||||
|| Stack->Parameters.DeviceIoControl.OutputBufferLength != sizeof(PVOID))
|
||||
{
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
else
|
||||
{
|
||||
PVOID* pHubPointer;
|
||||
DeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
DPRINT1("Usbhub: IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO\n");
|
||||
if (Irp->AssociatedIrp.SystemBuffer == NULL
|
||||
|| Stack->Parameters.DeviceIoControl.OutputBufferLength != sizeof(PVOID))
|
||||
{
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
else
|
||||
{
|
||||
PVOID* pHubPointer;
|
||||
DeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
|
||||
pHubPointer = (PVOID*)Irp->AssociatedIrp.SystemBuffer;
|
||||
*pHubPointer = DeviceExtension->dev;
|
||||
Information = sizeof(PVOID);
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("Usbhub: Unknown IOCTL code 0x%lx\n", Stack->Parameters.DeviceIoControl.IoControlCode);
|
||||
Information = Irp->IoStatus.Information;
|
||||
Status = Irp->IoStatus.Status;
|
||||
}
|
||||
}
|
||||
pHubPointer = (PVOID*)Irp->AssociatedIrp.SystemBuffer;
|
||||
*pHubPointer = DeviceExtension->dev;
|
||||
Information = sizeof(PVOID);
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("Usbhub: Unknown IOCTL code 0x%lx\n", Stack->Parameters.DeviceIoControl.IoControlCode);
|
||||
Information = Irp->IoStatus.Information;
|
||||
Status = Irp->IoStatus.Status;
|
||||
}
|
||||
}
|
||||
|
||||
Irp->IoStatus.Information = Information;
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
Irp->IoStatus.Information = Information;
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
UsbhubPdoStartDevice(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PHUB_DEVICE_EXTENSION DeviceExtension;
|
||||
NTSTATUS Status;
|
||||
PHUB_DEVICE_EXTENSION DeviceExtension;
|
||||
NTSTATUS Status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
DeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
DeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
|
||||
/* Register and activate device interface */
|
||||
Status = IoRegisterDeviceInterface(
|
||||
DeviceObject,
|
||||
DeviceExtension->dev->descriptor.bDeviceClass == USB_CLASS_HUB ?
|
||||
&GUID_DEVINTERFACE_USB_HUB :
|
||||
&GUID_DEVINTERFACE_USB_DEVICE,
|
||||
NULL, /* Reference string */
|
||||
&DeviceExtension->SymbolicLinkName);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Usbhub: IoRegisterDeviceInterface() failed with status 0x%08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
/* Register and activate device interface */
|
||||
/*
|
||||
Status = IoRegisterDeviceInterface(
|
||||
DeviceObject,
|
||||
DeviceExtension->dev->descriptor.bDeviceClass == USB_CLASS_HUB ?
|
||||
&GUID_DEVINTERFACE_USB_HUB :
|
||||
&GUID_DEVINTERFACE_USB_DEVICE,
|
||||
NULL,
|
||||
&DeviceExtension->SymbolicLinkName);
|
||||
*/
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Usbhub: IoRegisterDeviceInterface() failed with status 0x%08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = IoSetDeviceInterfaceState(&DeviceExtension->SymbolicLinkName, TRUE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Usbhub: IoSetDeviceInterfaceState() failed with status 0x%08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
//Status = IoSetDeviceInterfaceState(&DeviceExtension->SymbolicLinkName, TRUE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Usbhub: IoSetDeviceInterfaceState() failed with status 0x%08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
UsbhubPdoQueryId(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
OUT ULONG_PTR* Information)
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
OUT ULONG_PTR* Information)
|
||||
{
|
||||
PHUB_DEVICE_EXTENSION DeviceExtension;
|
||||
ULONG IdType;
|
||||
PUNICODE_STRING SourceString;
|
||||
UNICODE_STRING String;
|
||||
NTSTATUS Status;
|
||||
PHUB_CHILDDEVICE_EXTENSION DeviceExtension;
|
||||
ULONG IdType;
|
||||
PWCHAR SourceString = NULL;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
IdType = IoGetCurrentIrpStackLocation(Irp)->Parameters.QueryId.IdType;
|
||||
DeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
RtlInitUnicodeString(&String, NULL);
|
||||
IdType = IoGetCurrentIrpStackLocation(Irp)->Parameters.QueryId.IdType;
|
||||
DeviceExtension = (PHUB_CHILDDEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
|
||||
switch (IdType)
|
||||
{
|
||||
case BusQueryDeviceID:
|
||||
{
|
||||
DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryDeviceID\n");
|
||||
SourceString = &DeviceExtension->DeviceId;
|
||||
break;
|
||||
}
|
||||
case BusQueryHardwareIDs:
|
||||
{
|
||||
DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryHardwareIDs\n");
|
||||
SourceString = &DeviceExtension->HardwareIds;
|
||||
break;
|
||||
}
|
||||
case BusQueryCompatibleIDs:
|
||||
{
|
||||
DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryCompatibleIDs\n");
|
||||
SourceString = &DeviceExtension->CompatibleIds;
|
||||
break;
|
||||
}
|
||||
case BusQueryInstanceID:
|
||||
{
|
||||
DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryInstanceID\n");
|
||||
SourceString = &DeviceExtension->InstanceId;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_ID / unknown query id type 0x%lx\n", IdType);
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
switch (IdType)
|
||||
{
|
||||
case BusQueryDeviceID:
|
||||
{
|
||||
DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryDeviceID\n");
|
||||
SourceString = DeviceExtension->DeviceId;
|
||||
break;
|
||||
}
|
||||
/* FIXME: Implement */
|
||||
case BusQueryHardwareIDs:
|
||||
{
|
||||
DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryHardwareIDs\n");
|
||||
SourceString = DeviceExtension->HardwareIds;
|
||||
Status = STATUS_NOT_SUPPORTED;
|
||||
break;
|
||||
}
|
||||
/* FIXME: Implement */
|
||||
case BusQueryCompatibleIDs:
|
||||
{
|
||||
DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryCompatibleIDs\n");
|
||||
SourceString = DeviceExtension->CompatibleIds;
|
||||
Status = STATUS_NOT_SUPPORTED;
|
||||
break;
|
||||
}
|
||||
case BusQueryInstanceID:
|
||||
{
|
||||
DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryInstanceID\n");
|
||||
SourceString = DeviceExtension->InstanceId;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_ID / unknown query id type 0x%lx\n", IdType);
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
Status = UsbhubDuplicateUnicodeString(
|
||||
&String,
|
||||
SourceString,
|
||||
PagedPool);
|
||||
*Information = (ULONG_PTR)String.Buffer;
|
||||
return Status;
|
||||
*Information = (ULONG_PTR)SourceString;
|
||||
return Status;
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
UsbhubPdoQueryDeviceText(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
OUT ULONG_PTR* Information)
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
OUT ULONG_PTR* Information)
|
||||
{
|
||||
PHUB_DEVICE_EXTENSION DeviceExtension;
|
||||
DEVICE_TEXT_TYPE DeviceTextType;
|
||||
LCID LocaleId;
|
||||
PHUB_CHILDDEVICE_EXTENSION DeviceExtension;
|
||||
DEVICE_TEXT_TYPE DeviceTextType;
|
||||
LCID LocaleId;
|
||||
|
||||
DeviceTextType = IoGetCurrentIrpStackLocation(Irp)->Parameters.QueryDeviceText.DeviceTextType;
|
||||
LocaleId = IoGetCurrentIrpStackLocation(Irp)->Parameters.QueryDeviceText.LocaleId;
|
||||
DeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
DeviceTextType = IoGetCurrentIrpStackLocation(Irp)->Parameters.QueryDeviceText.DeviceTextType;
|
||||
LocaleId = IoGetCurrentIrpStackLocation(Irp)->Parameters.QueryDeviceText.LocaleId;
|
||||
DeviceExtension = (PHUB_CHILDDEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
|
||||
switch (DeviceTextType)
|
||||
{
|
||||
case DeviceTextDescription:
|
||||
case DeviceTextLocationInformation:
|
||||
{
|
||||
unsigned short size;
|
||||
int ret;
|
||||
PWCHAR buf;
|
||||
PWCHAR bufret;
|
||||
switch (DeviceTextType)
|
||||
{
|
||||
case DeviceTextDescription:
|
||||
case DeviceTextLocationInformation:
|
||||
{
|
||||
if (DeviceTextType == DeviceTextDescription)
|
||||
{
|
||||
*Information = (ULONG_PTR)DeviceExtension->TextDescription;
|
||||
DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription\n");
|
||||
}
|
||||
else
|
||||
DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextLocationInformation\n");
|
||||
|
||||
if (DeviceTextType == DeviceTextDescription)
|
||||
DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription\n");
|
||||
else
|
||||
DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextLocationInformation\n");
|
||||
/* if (!DeviceExtension->dev->descriptor.iProduct)
|
||||
return STATUS_NOT_SUPPORTED;*/
|
||||
|
||||
if (!DeviceExtension->dev->descriptor.iProduct)
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
|
||||
ret = usb_get_string(DeviceExtension->dev, LocaleId, DeviceExtension->dev->descriptor.iProduct, &size, sizeof(size));
|
||||
if (ret < 2)
|
||||
{
|
||||
DPRINT("Usbhub: usb_get_string() failed with error %d\n", ret);
|
||||
return STATUS_IO_DEVICE_ERROR;
|
||||
}
|
||||
size &= 0xff;
|
||||
buf = ExAllocatePool(PagedPool, size);
|
||||
if (buf == NULL)
|
||||
{
|
||||
DPRINT("Usbhub: ExAllocatePool() failed\n");
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
ret = usb_get_string(DeviceExtension->dev, LocaleId, DeviceExtension->dev->descriptor.iProduct, buf, size);
|
||||
if (ret < 0)
|
||||
{
|
||||
DPRINT("Usbhub: usb_get_string() failed with error %d\n", ret);
|
||||
ExFreePool(buf);
|
||||
return STATUS_IO_DEVICE_ERROR;
|
||||
}
|
||||
bufret = ExAllocatePool(PagedPool, size - 2 /* size of length identifier */ + 2 /* final NULL */);
|
||||
if (bufret == NULL)
|
||||
{
|
||||
DPRINT("Usbhub: ExAllocatePool() failed\n");
|
||||
ExFreePool(buf);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
RtlCopyMemory(bufret, &buf[1], size - 2);
|
||||
bufret[(size - 1) / sizeof(WCHAR)] = 0;
|
||||
*Information = (ULONG_PTR)bufret;
|
||||
ExFreePool(buf);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
default:
|
||||
DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / unknown device text type 0x%lx\n", DeviceTextType);
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
default:
|
||||
DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / unknown device text type 0x%lx\n", DeviceTextType);
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS NTAPI
|
||||
UsbhubPnpPdo(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
ULONG MinorFunction;
|
||||
PIO_STACK_LOCATION Stack;
|
||||
ULONG_PTR Information = 0;
|
||||
NTSTATUS Status;
|
||||
ULONG MinorFunction;
|
||||
PIO_STACK_LOCATION Stack;
|
||||
ULONG_PTR Information = 0;
|
||||
NTSTATUS Status;
|
||||
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
MinorFunction = Stack->MinorFunction;
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
MinorFunction = Stack->MinorFunction;
|
||||
|
||||
switch (MinorFunction)
|
||||
{
|
||||
case IRP_MN_START_DEVICE: /* 0x0 */
|
||||
{
|
||||
DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
||||
Status = UsbhubPdoStartDevice(DeviceObject, Irp);
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_CAPABILITIES: /* 0x09 */
|
||||
{
|
||||
PDEVICE_CAPABILITIES DeviceCapabilities;
|
||||
ULONG i;
|
||||
DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_CAPABILITIES\n");
|
||||
switch (MinorFunction)
|
||||
{
|
||||
case IRP_MN_START_DEVICE: /* 0x0 */
|
||||
{
|
||||
DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
||||
Status = UsbhubPdoStartDevice(DeviceObject, Irp);
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_CAPABILITIES: /* 0x09 */
|
||||
{
|
||||
PDEVICE_CAPABILITIES DeviceCapabilities;
|
||||
ULONG i;
|
||||
DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_CAPABILITIES\n");
|
||||
|
||||
DeviceCapabilities = (PDEVICE_CAPABILITIES)Stack->Parameters.DeviceCapabilities.Capabilities;
|
||||
/* FIXME: capabilities can change with connected device */
|
||||
DeviceCapabilities->LockSupported = TRUE;
|
||||
DeviceCapabilities->EjectSupported = FALSE;
|
||||
DeviceCapabilities->Removable = FALSE;
|
||||
DeviceCapabilities->DockDevice = FALSE;
|
||||
DeviceCapabilities->UniqueID = FALSE;
|
||||
DeviceCapabilities->SilentInstall = TRUE;
|
||||
DeviceCapabilities->RawDeviceOK = FALSE;
|
||||
DeviceCapabilities->SurpriseRemovalOK = FALSE;
|
||||
DeviceCapabilities->HardwareDisabled = FALSE; /* FIXME */
|
||||
//DeviceCapabilities->NoDisplayInUI = FALSE; /* FIXME */
|
||||
DeviceCapabilities->DeviceState[0] = PowerDeviceD0; /* FIXME */
|
||||
for (i = 0; i < PowerSystemMaximum; i++)
|
||||
DeviceCapabilities->DeviceState[i] = PowerDeviceD3; /* FIXME */
|
||||
//DeviceCapabilities->DeviceWake = PowerDeviceUndefined; /* FIXME */
|
||||
DeviceCapabilities->D1Latency = 0; /* FIXME */
|
||||
DeviceCapabilities->D2Latency = 0; /* FIXME */
|
||||
DeviceCapabilities->D3Latency = 0; /* FIXME */
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_RESOURCES: /* 0x0a */
|
||||
{
|
||||
PCM_RESOURCE_LIST ResourceList;
|
||||
DeviceCapabilities = (PDEVICE_CAPABILITIES)Stack->Parameters.DeviceCapabilities.Capabilities;
|
||||
/* FIXME: capabilities can change with connected device */
|
||||
DeviceCapabilities->LockSupported = TRUE;
|
||||
DeviceCapabilities->EjectSupported = FALSE;
|
||||
DeviceCapabilities->Removable = FALSE;
|
||||
DeviceCapabilities->DockDevice = FALSE;
|
||||
DeviceCapabilities->UniqueID = FALSE;
|
||||
DeviceCapabilities->SilentInstall = TRUE;
|
||||
DeviceCapabilities->RawDeviceOK = FALSE;
|
||||
DeviceCapabilities->SurpriseRemovalOK = FALSE;
|
||||
DeviceCapabilities->HardwareDisabled = FALSE; /* FIXME */
|
||||
//DeviceCapabilities->NoDisplayInUI = FALSE; /* FIXME */
|
||||
DeviceCapabilities->DeviceState[0] = PowerDeviceD0; /* FIXME */
|
||||
for (i = 0; i < PowerSystemMaximum; i++)
|
||||
DeviceCapabilities->DeviceState[i] = PowerDeviceD3; /* FIXME */
|
||||
//DeviceCapabilities->DeviceWake = PowerDeviceUndefined; /* FIXME */
|
||||
DeviceCapabilities->D1Latency = 0; /* FIXME */
|
||||
DeviceCapabilities->D2Latency = 0; /* FIXME */
|
||||
DeviceCapabilities->D3Latency = 0; /* FIXME */
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_RESOURCES: /* 0x0a */
|
||||
{
|
||||
PCM_RESOURCE_LIST ResourceList;
|
||||
|
||||
DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_RESOURCES\n");
|
||||
ResourceList = ExAllocatePool(PagedPool, sizeof(CM_RESOURCE_LIST));
|
||||
if (!ResourceList)
|
||||
{
|
||||
DPRINT("Usbhub: ExAllocatePool() failed\n");
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
else
|
||||
{
|
||||
ResourceList->Count = 0;
|
||||
Information = (ULONG_PTR)ResourceList;
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: /* 0x0b */
|
||||
{
|
||||
PIO_RESOURCE_REQUIREMENTS_LIST ResourceList;
|
||||
DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_RESOURCES\n");
|
||||
ResourceList = ExAllocatePool(PagedPool, sizeof(CM_RESOURCE_LIST));
|
||||
if (!ResourceList)
|
||||
{
|
||||
DPRINT1("Usbhub: ExAllocatePool() failed\n");
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
else
|
||||
{
|
||||
ResourceList->Count = 0;
|
||||
Information = (ULONG_PTR)ResourceList;
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: /* 0x0b */
|
||||
{
|
||||
PIO_RESOURCE_REQUIREMENTS_LIST ResourceList;
|
||||
|
||||
DPRINT("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
|
||||
ResourceList = ExAllocatePool(PagedPool, sizeof(IO_RESOURCE_REQUIREMENTS_LIST));
|
||||
if (!ResourceList)
|
||||
{
|
||||
DPRINT("Usbhub: ExAllocatePool() failed\n");
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
else
|
||||
{
|
||||
RtlZeroMemory(ResourceList, sizeof(IO_RESOURCE_REQUIREMENTS_LIST));
|
||||
ResourceList->ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST);
|
||||
ResourceList->AlternativeLists = 1;
|
||||
ResourceList->List->Version = 1;
|
||||
ResourceList->List->Revision = 1;
|
||||
ResourceList->List->Count = 0;
|
||||
Information = (ULONG_PTR)ResourceList;
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_DEVICE_TEXT: /* 0x0c */
|
||||
{
|
||||
Status = UsbhubPdoQueryDeviceText(DeviceObject, Irp, &Information);
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_ID: /* 0x13 */
|
||||
{
|
||||
Status = UsbhubPdoQueryId(DeviceObject, Irp, &Information);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
/* We can't forward request to the lower driver, because
|
||||
* we are a Pdo, so we don't have lower driver...
|
||||
*/
|
||||
DPRINT1("Usbhub: IRP_MJ_PNP / unknown minor function 0x%lx\n", MinorFunction);
|
||||
Information = Irp->IoStatus.Information;
|
||||
Status = Irp->IoStatus.Status;
|
||||
}
|
||||
}
|
||||
DPRINT1("Usbhub: IRP_MJ_PNP / IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
|
||||
ResourceList = ExAllocatePool(PagedPool, sizeof(IO_RESOURCE_REQUIREMENTS_LIST));
|
||||
if (!ResourceList)
|
||||
{
|
||||
DPRINT1("Usbhub: ExAllocatePool() failed\n");
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
else
|
||||
{
|
||||
RtlZeroMemory(ResourceList, sizeof(IO_RESOURCE_REQUIREMENTS_LIST));
|
||||
ResourceList->ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST);
|
||||
ResourceList->AlternativeLists = 1;
|
||||
ResourceList->List->Version = 1;
|
||||
ResourceList->List->Revision = 1;
|
||||
ResourceList->List->Count = 0;
|
||||
Information = (ULONG_PTR)ResourceList;
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_DEVICE_TEXT: /* 0x0c */
|
||||
{
|
||||
Status = UsbhubPdoQueryDeviceText(DeviceObject, Irp, &Information);
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_ID: /* 0x13 */
|
||||
{
|
||||
Status = UsbhubPdoQueryId(DeviceObject, Irp, &Information);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
/* We can't forward request to the lower driver, because
|
||||
* we are a Pdo, so we don't have lower driver...
|
||||
*/
|
||||
DPRINT1("Usbhub: IRP_MJ_PNP / unknown minor function 0x%lx\n", MinorFunction);
|
||||
Information = Irp->IoStatus.Information;
|
||||
Status = Irp->IoStatus.Status;
|
||||
}
|
||||
}
|
||||
|
||||
Irp->IoStatus.Information = Information;
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
Irp->IoStatus.Information = Information;
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
* ReactOS USB hub driver
|
||||
* Copyright (C) 2004 Aleksey Bragin
|
||||
* (C) 2005 Mark Tempel
|
||||
* (C) 2005 Hervé Poussineau
|
||||
* (C) 2005 Herv<EFBFBD> Poussineau
|
||||
* (C) 2010 Michael Martin
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -26,159 +27,108 @@
|
|||
|
||||
/* PUBLIC AND PRIVATE FUNCTIONS ***********************************************/
|
||||
|
||||
static NTSTATUS
|
||||
GetRootHubPointer(
|
||||
IN PDEVICE_OBJECT Pdo,
|
||||
OUT PVOID* RootHubPointer)
|
||||
{
|
||||
KEVENT Event;
|
||||
PIRP Irp;
|
||||
IO_STATUS_BLOCK IoStatus;
|
||||
NTSTATUS Status;
|
||||
|
||||
KeInitializeEvent (&Event, NotificationEvent, FALSE);
|
||||
|
||||
Irp = IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO,
|
||||
Pdo,
|
||||
NULL, sizeof(NULL),
|
||||
RootHubPointer, sizeof(*RootHubPointer),
|
||||
FALSE,
|
||||
&Event,
|
||||
&IoStatus);
|
||||
if (Irp == NULL)
|
||||
{
|
||||
DPRINT("Usbhub: IoBuildDeviceIoControlRequest() failed\n");
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
/* Initialize the status block before sending the IRP */
|
||||
IoGetNextIrpStackLocation(Irp)->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
|
||||
IoStatus.Status = STATUS_NOT_SUPPORTED;
|
||||
IoStatus.Information = 0;
|
||||
|
||||
Status = IoCallDriver(Pdo, Irp);
|
||||
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
DPRINT("Usbhub: Operation pending\n");
|
||||
KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
||||
Status = IoStatus.Status;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS NTAPI
|
||||
UsbhubAddDevice(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PDEVICE_OBJECT Pdo)
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PDEVICE_OBJECT Pdo)
|
||||
{
|
||||
PDEVICE_OBJECT Fdo;
|
||||
PHUB_DEVICE_EXTENSION DeviceExtension;
|
||||
NTSTATUS Status;
|
||||
PDEVICE_OBJECT Fdo;
|
||||
PHUB_DEVICE_EXTENSION DeviceExtension;
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = IoCreateDevice(DriverObject,
|
||||
sizeof(HUB_DEVICE_EXTENSION),
|
||||
NULL, /* DeviceName */
|
||||
FILE_DEVICE_BUS_EXTENDER,
|
||||
0,
|
||||
FALSE,
|
||||
&Fdo);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Usbhub: IoCreateDevice() failed with status 0x%08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
Status = IoCreateDevice(DriverObject,
|
||||
sizeof(HUB_DEVICE_EXTENSION),
|
||||
NULL, /* DeviceName */
|
||||
FILE_DEVICE_BUS_EXTENDER,
|
||||
FILE_AUTOGENERATED_DEVICE_NAME,
|
||||
FALSE,
|
||||
&Fdo);
|
||||
|
||||
// zerofill device extension
|
||||
DeviceExtension = (PHUB_DEVICE_EXTENSION)Fdo->DeviceExtension;
|
||||
RtlZeroMemory(DeviceExtension, sizeof(HUB_DEVICE_EXTENSION));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Usbhub: IoCreateDevice() failed with status 0x%08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Get a pointer to the linux structure created by the USB controller,
|
||||
* by sending IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO to lower device.
|
||||
*/
|
||||
Status = GetRootHubPointer(Pdo, (PVOID*)&DeviceExtension->dev);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Usbhub: GetRootHubPointer() failed with status 0x%08lx\n", Status);
|
||||
IoDeleteDevice(Fdo);
|
||||
return Status;
|
||||
}
|
||||
DeviceExtension->dev->dev.dev_ext = Pdo;
|
||||
// zerofill device extension
|
||||
DeviceExtension = (PHUB_DEVICE_EXTENSION)Fdo->DeviceExtension;
|
||||
RtlZeroMemory(DeviceExtension, sizeof(HUB_DEVICE_EXTENSION));
|
||||
|
||||
DeviceExtension->IsFDO = TRUE;
|
||||
Fdo->Flags |= DO_POWER_PAGABLE;
|
||||
Status = IoAttachDeviceToDeviceStackSafe(Fdo, Pdo, &DeviceExtension->LowerDevice);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Usbhub: IoAttachDeviceToDeviceStackSafe() failed with status 0x%08lx\n", Status);
|
||||
IoDeleteDevice(Fdo);
|
||||
return Status;
|
||||
}
|
||||
Fdo->Flags |= DO_BUFFERED_IO;
|
||||
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||
DeviceExtension->IsFDO = TRUE;
|
||||
Fdo->Flags |= DO_POWER_PAGABLE;
|
||||
//Status = IoAttachDeviceToDeviceStackSafe(Fdo, Pdo, &DeviceExtension->LowerDevice);
|
||||
DeviceExtension->LowerDevice = IoAttachDeviceToDeviceStack(Fdo, Pdo);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Usbhub: IoAttachDeviceToDeviceStackSafe() failed with status 0x%08lx\n", Status);
|
||||
IoDeleteDevice(Fdo);
|
||||
return Status;
|
||||
}
|
||||
Fdo->Flags |= DO_BUFFERED_IO;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS NTAPI
|
||||
IrpStub(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
NTSTATUS Status;
|
||||
|
||||
if (((PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
|
||||
{
|
||||
DPRINT1("Usbhub: FDO stub for major function 0x%lx\n",
|
||||
IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
|
||||
if (((PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
|
||||
{
|
||||
DPRINT1("Usbhub: FDO stub for major function 0x%lx\n",
|
||||
IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
|
||||
return ForwardIrpAndForget(DeviceObject, Irp);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We can't forward request to the lower driver, because
|
||||
* we are a Pdo, so we don't have lower driver...
|
||||
*/
|
||||
DPRINT1("Usbhub: PDO stub for major function 0x%lx\n",
|
||||
IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
|
||||
#ifndef NDEBUG
|
||||
DbgBreakPoint();
|
||||
DbgBreakPoint();
|
||||
#endif
|
||||
return ForwardIrpAndForget(DeviceObject, Irp);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We can't forward request to the lower driver, because
|
||||
* we are a Pdo, so we don't have lower driver...
|
||||
*/
|
||||
DPRINT1("Usbhub: PDO stub for major function 0x%lx\n",
|
||||
IoGetCurrentIrpStackLocation(Irp)->MajorFunction);
|
||||
#ifndef NDEBUG
|
||||
DbgBreakPoint();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Status = Irp->IoStatus.Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
Status = Irp->IoStatus.Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
}
|
||||
|
||||
static NTSTATUS NTAPI
|
||||
DispatchDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
if (((PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
|
||||
return UsbhubDeviceControlFdo(DeviceObject, Irp);
|
||||
else
|
||||
return IrpStub(DeviceObject, Irp);
|
||||
DPRINT1("Usbhub: DispatchDeviceControl\n");
|
||||
if (((PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
|
||||
return UsbhubDeviceControlFdo(DeviceObject, Irp);
|
||||
else
|
||||
return IrpStub(DeviceObject, Irp);
|
||||
}
|
||||
|
||||
static NTSTATUS NTAPI
|
||||
DispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
if (((PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
|
||||
return IrpStub(DeviceObject, Irp);
|
||||
else
|
||||
return UsbhubInternalDeviceControlPdo(DeviceObject, Irp);
|
||||
DPRINT1("Usbhub: DispatchInternalDeviceControl\n");
|
||||
if (((PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
|
||||
return IrpStub(DeviceObject, Irp);
|
||||
else
|
||||
return UsbhubInternalDeviceControlPdo(DeviceObject, Irp);
|
||||
}
|
||||
|
||||
static NTSTATUS NTAPI
|
||||
DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
if (((PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
|
||||
return UsbhubPnpFdo(DeviceObject, Irp);
|
||||
else
|
||||
return UsbhubPnpPdo(DeviceObject, Irp);
|
||||
DPRINT1("Usbhub: DispatchPnp\n");
|
||||
if (((PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
|
||||
return UsbhubPnpFdo(DeviceObject, Irp);
|
||||
else
|
||||
return UsbhubPnpPdo(DeviceObject, Irp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -186,23 +136,24 @@ DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
*/
|
||||
NTSTATUS NTAPI
|
||||
DriverEntry(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PUNICODE_STRING RegistryPath)
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PUNICODE_STRING RegistryPath)
|
||||
{
|
||||
ULONG i;
|
||||
ULONG i;
|
||||
|
||||
DriverObject->DriverExtension->AddDevice = UsbhubAddDevice;
|
||||
DriverObject->DriverExtension->AddDevice = UsbhubAddDevice;
|
||||
DPRINT1("Usbhub: DriverEntry\n");
|
||||
|
||||
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
|
||||
DriverObject->MajorFunction[i] = IrpStub;
|
||||
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
|
||||
DriverObject->MajorFunction[i] = IrpStub;
|
||||
|
||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = UsbhubCreate;
|
||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = UsbhubClose;
|
||||
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = UsbhubCleanup;
|
||||
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DispatchDeviceControl;
|
||||
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = DispatchInternalDeviceControl;
|
||||
DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp;
|
||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = UsbhubCreate;
|
||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = UsbhubClose;
|
||||
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = UsbhubCleanup;
|
||||
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DispatchDeviceControl;
|
||||
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = DispatchInternalDeviceControl;
|
||||
DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,85 +1,176 @@
|
|||
#include <debug.h>
|
||||
|
||||
#include <ntddk.h>
|
||||
#include <hubbusif.h>
|
||||
#include <usbbusif.h>
|
||||
#include <usbioctl.h>
|
||||
|
||||
#include "../miniport/usb_wrapper.h"
|
||||
#include "../usbport/hub.h"
|
||||
#include <usb.h>
|
||||
#include <debug.h>
|
||||
//BROKEN: #include <usbprotocoldefs.h>
|
||||
|
||||
#define USB_HUB_TAG 'hbsu'
|
||||
#define USB_MAXCHILDREN 127
|
||||
|
||||
/* Lifted from broken header above */
|
||||
#define C_HUB_LOCAL_POWER 0
|
||||
#define C_HUB_OVER_CURRENT 1
|
||||
#define PORT_CONNECTION 0
|
||||
#define PORT_ENABLE 1
|
||||
#define PORT_SUSPEND 2
|
||||
#define PORT_OVER_CURRENT 3
|
||||
#define PORT_RESET 4
|
||||
#define PORT_POWER 8
|
||||
#define PORT_LOW_SPEED 9
|
||||
#define C_PORT_CONNECTION 16
|
||||
#define C_PORT_ENABLE 17
|
||||
#define C_PORT_SUSPEND 18
|
||||
#define C_PORT_OVER_CURRENT 19
|
||||
#define C_PORT_RESET 20
|
||||
#define PORT_TEST 21
|
||||
#define PORT_INDICATOR 22
|
||||
|
||||
typedef struct _USB_ENDPOINT
|
||||
{
|
||||
ULONG Flags;
|
||||
LIST_ENTRY UrbList;
|
||||
struct _USB_INTERFACE *Interface;
|
||||
USB_ENDPOINT_DESCRIPTOR EndPointDescriptor;
|
||||
} USB_ENDPOINT, *PUSB_ENDPOINT;
|
||||
|
||||
typedef struct _USB_INTERFACE
|
||||
{
|
||||
struct _USB_CONFIGURATION *Config;
|
||||
USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
|
||||
USB_ENDPOINT *EndPoints[];
|
||||
} USB_INTERFACE, *PUSB_INTERFACE;
|
||||
|
||||
typedef struct _USB_CONFIGURATION
|
||||
{
|
||||
struct _USB_DEVICE *Device;
|
||||
USB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor;
|
||||
USB_INTERFACE *Interfaces[];
|
||||
} USB_CONFIGURATION, *PUSB_CONFIGURATION;
|
||||
|
||||
typedef struct _USB_DEVICE
|
||||
{
|
||||
UCHAR Address;
|
||||
ULONG Port;
|
||||
PVOID ParentDevice;
|
||||
BOOLEAN IsHub;
|
||||
USB_DEVICE_SPEED DeviceSpeed;
|
||||
USB_DEVICE_TYPE DeviceType;
|
||||
USB_DEVICE_DESCRIPTOR DeviceDescriptor;
|
||||
USB_CONFIGURATION *ActiveConfig;
|
||||
USB_INTERFACE *ActiveInterface;
|
||||
USB_CONFIGURATION **Configs;
|
||||
} USB_DEVICE, *PUSB_DEVICE;
|
||||
|
||||
typedef struct _HUB_CHILDDEVICE_EXTENSION
|
||||
{
|
||||
BOOLEAN IsFDO;
|
||||
PDEVICE_OBJECT Parent;
|
||||
PWCHAR DeviceId; // REG_SZ
|
||||
PWCHAR InstanceId; // REG_SZ
|
||||
PWCHAR HardwareIds; // REG_MULTI_SZ
|
||||
PWCHAR CompatibleIds; // REG_MULTI_SZ
|
||||
PWCHAR TextDescription;
|
||||
UNICODE_STRING SymbolicLinkName;
|
||||
} HUB_CHILDDEVICE_EXTENSION, *PHUB_CHILDDEVICE_EXTENSION;
|
||||
|
||||
typedef struct _HUB_DEVICE_EXTENSION
|
||||
{
|
||||
BOOLEAN IsFDO;
|
||||
struct usb_device* dev;
|
||||
PDEVICE_OBJECT LowerDevice;
|
||||
BOOLEAN IsFDO;
|
||||
USB_DEVICE* dev;
|
||||
PDEVICE_OBJECT LowerDevice;
|
||||
ULONG ChildCount;
|
||||
PDEVICE_OBJECT Children[USB_MAXCHILDREN];
|
||||
|
||||
PDEVICE_OBJECT Children[USB_MAXCHILDREN];
|
||||
PUSB_DEVICE UsbChildren[USB_MAXCHILDREN];
|
||||
|
||||
/* Fields valid only when IsFDO == FALSE */
|
||||
UNICODE_STRING DeviceId; // REG_SZ
|
||||
UNICODE_STRING InstanceId; // REG_SZ
|
||||
UNICODE_STRING HardwareIds; // REG_MULTI_SZ
|
||||
UNICODE_STRING CompatibleIds; // REG_MULTI_SZ
|
||||
UNICODE_STRING SymbolicLinkName;
|
||||
PUSB_DEVICE RootHubUsbDevice;
|
||||
|
||||
PDEVICE_OBJECT RootHubPdo;
|
||||
PDEVICE_OBJECT RootHubFdo;
|
||||
|
||||
ULONG HubCount;
|
||||
|
||||
USHORT PortStatus[256];
|
||||
|
||||
USB_BUS_INTERFACE_HUB_V5 HubInterface;
|
||||
USB_BUS_INTERFACE_USBDI_V2 UsbDInterface;
|
||||
|
||||
USB_HUB_DESCRIPTOR HubDescriptor;
|
||||
USB_DEVICE_DESCRIPTOR HubDeviceDescriptor;
|
||||
|
||||
USB_CONFIGURATION_DESCRIPTOR HubConfigDescriptor;
|
||||
USB_INTERFACE_DESCRIPTOR HubInterfaceDescriptor;
|
||||
USB_ENDPOINT_DESCRIPTOR HubEndPointDescriptor;
|
||||
|
||||
USB_EXTHUB_INFORMATION_0 UsbExtHubInfo;
|
||||
USB_DEVICE_INFORMATION_0 DeviceInformation;
|
||||
|
||||
WORK_QUEUE_ITEM WorkItem;
|
||||
|
||||
USBD_CONFIGURATION_HANDLE ConfigurationHandle;
|
||||
USBD_PIPE_HANDLE PipeHandle;
|
||||
|
||||
UNICODE_STRING SymbolicLinkName;
|
||||
} HUB_DEVICE_EXTENSION, *PHUB_DEVICE_EXTENSION;
|
||||
|
||||
/* createclose.c */
|
||||
NTSTATUS NTAPI
|
||||
UsbhubCreate(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS NTAPI
|
||||
UsbhubClose(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS NTAPI
|
||||
UsbhubCleanup(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
/* fdo.c */
|
||||
NTSTATUS NTAPI
|
||||
UsbhubPnpFdo(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS
|
||||
UsbhubDeviceControlFdo(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
/* misc.c */
|
||||
NTSTATUS
|
||||
ForwardIrpAndWait(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS NTAPI
|
||||
ForwardIrpAndForget(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS
|
||||
UsbhubDuplicateUnicodeString(
|
||||
OUT PUNICODE_STRING Destination,
|
||||
IN PUNICODE_STRING Source,
|
||||
IN POOL_TYPE PoolType);
|
||||
OUT PUNICODE_STRING Destination,
|
||||
IN PUNICODE_STRING Source,
|
||||
IN POOL_TYPE PoolType);
|
||||
|
||||
NTSTATUS
|
||||
UsbhubInitMultiSzString(
|
||||
OUT PUNICODE_STRING Destination,
|
||||
... /* list of PCSZ */);
|
||||
OUT PUNICODE_STRING Destination,
|
||||
.../* list of PCSZ */);
|
||||
|
||||
/* pdo.c */
|
||||
NTSTATUS NTAPI
|
||||
UsbhubPnpPdo(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS
|
||||
UsbhubInternalDeviceControlPdo(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
|
||||
<module name="usbhub" type="kernelmodedriver" installbase="system32/drivers" installname="usbhub.sys">
|
||||
<include>../miniport/linux</include>
|
||||
<library>sys_base</library>
|
||||
<library>ntoskrnl</library>
|
||||
<library>hal</library>
|
||||
<library>usbport</library>
|
||||
<file>createclose.c</file>
|
||||
<file>fdo.c</file>
|
||||
<file>misc.c</file>
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
*/
|
||||
|
||||
#include "videoprt.h"
|
||||
#include "internal/i386/v86m.h"
|
||||
|
||||
/* PRIVATE FUNCTIONS **********************************************************/
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ HalInitSystem(IN ULONG BootPhase,
|
|||
/* Fill out the dispatch tables */
|
||||
HalQuerySystemInformation = HaliQuerySystemInformation;
|
||||
HalSetSystemInformation = HaliSetSystemInformation;
|
||||
HalInitPnpDriver = NULL; // FIXME: TODO
|
||||
HalInitPnpDriver = HaliInitPnpDriver;
|
||||
#ifndef _MINIHAL_
|
||||
HalGetDmaAdapter = HalpGetDmaAdapter;
|
||||
#else
|
||||
|
|
|
@ -20,9 +20,6 @@ _HalpPerfCounterLow: .long 0
|
|||
_HalpPerfCounterHigh: .long 0
|
||||
_HalpSystemHardwareFlags: .long 0
|
||||
|
||||
_UnhandledMsg:
|
||||
.asciz "\n\x7\x7!!! Unhandled or Unexpected Code at line: %lx!!!\n"
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
.global _HalpCalibrateStallExecution@0
|
||||
|
@ -389,6 +386,9 @@ LoopPostInt:
|
|||
/* Read 8254 timer */
|
||||
mov al, 0
|
||||
out 0x43, al
|
||||
in al, 0x92
|
||||
or al, _HalpPerfCounterCutoff
|
||||
out 0x92, al
|
||||
jmp $+2
|
||||
in al, 0x40
|
||||
jmp $+2
|
||||
|
|
|
@ -678,10 +678,10 @@ ShowSize(ULONG x)
|
|||
|
||||
VOID
|
||||
NTAPI
|
||||
HalpDebugPciBus(IN ULONG i,
|
||||
IN ULONG j,
|
||||
IN ULONG k,
|
||||
IN PPCI_COMMON_CONFIG PciData)
|
||||
HalpDebugPciDumpBus(IN ULONG i,
|
||||
IN ULONG j,
|
||||
IN ULONG k,
|
||||
IN PPCI_COMMON_CONFIG PciData)
|
||||
{
|
||||
extern CHAR ClassTable[3922];
|
||||
extern CHAR VendorTable[642355];
|
||||
|
@ -933,7 +933,7 @@ HalpInitializePciBus(VOID)
|
|||
if (PciData->VendorID == PCI_INVALID_VENDORID) continue;
|
||||
|
||||
/* Print out the entry */
|
||||
HalpDebugPciBus(i, j, k, PciData);
|
||||
HalpDebugPciDumpBus(i, j, k, PciData);
|
||||
|
||||
/* Check if this is a Cardbus bridge */
|
||||
if (PCI_CONFIGURATION_TYPE(PciData) == PCI_CARDBUS_BRIDGE_TYPE)
|
||||
|
|
|
@ -56,6 +56,14 @@ HalpIs16BitPortDecodeSupported(VOID)
|
|||
return (HalpBusType == MACHINE_TYPE_EISA) ? CM_RESOURCE_PORT_16_BIT_DECODE : 0;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
HaliInitPnpDriver(VOID)
|
||||
{
|
||||
/* On PC-AT, this will interface with the PCI driver */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
|
|
|
@ -301,13 +301,14 @@ HalHandleNMI(IN PVOID NmiInfo)
|
|||
// Halt the system
|
||||
//
|
||||
InbvDisplayString("\n*** The system has halted ***\n");
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Enter the debugger if possible
|
||||
//
|
||||
KiBugCheckData[0] = (ULONG_PTR)KeServiceDescriptorTable; /* NMI Corruption? */
|
||||
//if (!(KdDebuggerNotPresent) && (KdDebuggerEnabled)) KeEnterKernelDebugger();
|
||||
|
||||
#endif
|
||||
//
|
||||
// Freeze the system
|
||||
//
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
ULONG HalpPerfCounterCutoff;
|
||||
BOOLEAN HalpClockSetMSRate;
|
||||
ULONG HalpCurrentTimeIncrement;
|
||||
ULONG HalpCurrentRollOver;
|
||||
|
@ -71,34 +72,26 @@ HalpInitializeClock(VOID)
|
|||
Flags = __readeflags();
|
||||
_disable();
|
||||
|
||||
//
|
||||
// Program the PIT for binary mode
|
||||
//
|
||||
/* Program the PIT for binary mode */
|
||||
TimerControl.BcdMode = FALSE;
|
||||
|
||||
//
|
||||
// Program the PIT to generate a normal rate wave (Mode 3) on channel 0.
|
||||
// Channel 0 is used for the IRQ0 clock interval timer, and channel
|
||||
// 1 is used for DRAM refresh.
|
||||
//
|
||||
// Mode 2 gives much better accuracy than Mode 3.
|
||||
//
|
||||
/*
|
||||
* Program the PIT to generate a normal rate wave (Mode 3) on channel 0.
|
||||
* Channel 0 is used for the IRQ0 clock interval timer, and channel
|
||||
* 1 is used for DRAM refresh.
|
||||
*
|
||||
* Mode 2 gives much better accuracy than Mode 3.
|
||||
*/
|
||||
TimerControl.OperatingMode = PitOperatingMode2;
|
||||
TimerControl.Channel = PitChannel0;
|
||||
|
||||
//
|
||||
// Set the access mode that we'll use to program the reload value.
|
||||
//
|
||||
/* Set the access mode that we'll use to program the reload value */
|
||||
TimerControl.AccessMode = PitAccessModeLowHigh;
|
||||
|
||||
//
|
||||
// Now write the programming bits
|
||||
//
|
||||
/* Now write the programming bits */
|
||||
__outbyte(TIMER_CONTROL_PORT, TimerControl.Bits);
|
||||
|
||||
//
|
||||
// Next we write the reload value for channel 0
|
||||
//
|
||||
/* Next we write the reload value for channel 0 */
|
||||
__outbyte(TIMER_CHANNEL0_DATA_PORT, RollOver & 0xFF);
|
||||
__outbyte(TIMER_CHANNEL0_DATA_PORT, RollOver >> 8);
|
||||
|
||||
|
@ -125,6 +118,7 @@ HalpClockInterruptHandler(IN PKTRAP_FRAME TrapFrame)
|
|||
{
|
||||
/* Update the performance counter */
|
||||
HalpPerfCounter.QuadPart += HalpCurrentRollOver;
|
||||
HalpPerfCounterCutoff = KiEnableTimerWatchdog;
|
||||
|
||||
/* Check if someone changed the time rate */
|
||||
if (HalpClockSetMSRate)
|
||||
|
|
|
@ -9,16 +9,15 @@
|
|||
<define name="_BLDR_" />
|
||||
<define name="_MINIHAL_" />
|
||||
<directory name="generic">
|
||||
<directory name="legacy">
|
||||
<directory name="bus">
|
||||
<file>bushndlr.c</file>
|
||||
<file>cmosbus.c</file>
|
||||
<file>isabus.c</file>
|
||||
<file>pcibus.c</file>
|
||||
<file>pcidata.c</file>
|
||||
<file>sysbus.c</file>
|
||||
</directory>
|
||||
<file>bussupp.c</file>
|
||||
<directory name="legacy">
|
||||
<directory name="bus">
|
||||
<file>bushndlr.c</file>
|
||||
<file>cmosbus.c</file>
|
||||
<file>isabus.c</file>
|
||||
<file>pcibus.c</file>
|
||||
<file>sysbus.c</file>
|
||||
</directory>
|
||||
<file>bussupp.c</file>
|
||||
</directory>
|
||||
<file>beep.c</file>
|
||||
<file>bios.c</file>
|
||||
|
|
|
@ -795,6 +795,21 @@ HalpInitBusHandlers(
|
|||
VOID
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
HaliInitPnpDriver(
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
HalpDebugPciDumpBus(
|
||||
IN ULONG i,
|
||||
IN ULONG j,
|
||||
IN ULONG k,
|
||||
IN PPCI_COMMON_CONFIG PciData
|
||||
);
|
||||
|
||||
#ifdef _M_AMD64
|
||||
#define KfLowerIrql KeLowerIrql
|
||||
#ifndef CONFIG_SMP
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#endif
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
#define __MINGW_MSC_PREREQ(major, minor) ((major * 100 + minor * 10) >= _MSC_VER)
|
||||
#define __MINGW_MSC_PREREQ(major, minor) (_MSC_VER >= (major * 100 + minor * 10))
|
||||
#else
|
||||
#define __MINGW_MSC_PREREQ(major, minor) 0
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef DECLSPEC_EXPORT
|
||||
#define DECLSPEC_EXPORT __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
typedef struct _USBD_INTERFACE_LIST_ENTRY {
|
||||
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
|
||||
PUSBD_INTERFACE_INFORMATION Interface;
|
||||
|
|
|
@ -67,29 +67,6 @@ Author:
|
|||
#define KGDT_NMI_TSS (0x58)
|
||||
#endif
|
||||
|
||||
//
|
||||
// KV86M_REGISTERS Offsets
|
||||
//
|
||||
#define KV86M_REGISTERS_EBP 0x0
|
||||
#define KV86M_REGISTERS_EDI 0x4
|
||||
#define KV86M_REGISTERS_ESI 0x8
|
||||
#define KV86M_REGISTERS_EDX 0xC
|
||||
#define KV86M_REGISTERS_ECX 0x10
|
||||
#define KV86M_REGISTERS_EBX 0x14
|
||||
#define KV86M_REGISTERS_EAX 0x18
|
||||
#define KV86M_REGISTERS_DS 0x1C
|
||||
#define KV86M_REGISTERS_ES 0x20
|
||||
#define KV86M_REGISTERS_FS 0x24
|
||||
#define KV86M_REGISTERS_GS 0x28
|
||||
#define KV86M_REGISTERS_EIP 0x2C
|
||||
#define KV86M_REGISTERS_CS 0x30
|
||||
#define KV86M_REGISTERS_EFLAGS 0x34
|
||||
#define KV86M_REGISTERS_ESP 0x38
|
||||
#define KV86M_REGISTERS_SS 0x3C
|
||||
#define TF_SAVED_EXCEPTION_STACK 0x8C
|
||||
#define TF_REGS 0x90
|
||||
#define TF_ORIG_EBP 0x94
|
||||
|
||||
//
|
||||
// TSS Offsets
|
||||
//
|
||||
|
|
|
@ -108,16 +108,18 @@ Author:
|
|||
#define KI_EXCEPTION_INTERNAL 0x10000000
|
||||
#define KI_EXCEPTION_ACCESS_VIOLATION (KI_EXCEPTION_INTERNAL | 0x04)
|
||||
|
||||
#ifndef NTOS_MODE_USER
|
||||
//
|
||||
// Number of dispatch codes supported by KINTERRUPT
|
||||
//
|
||||
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
|
||||
#define KINTERRUPT_DISPATCH_CODES 135
|
||||
#define DISPATCH_LENGTH 135
|
||||
#else
|
||||
#define KINTERRUPT_DISPATCH_CODES 106
|
||||
#define DISPATCH_LENGTH 106
|
||||
#endif
|
||||
|
||||
#ifdef NTOS_MODE_USER
|
||||
#define SharedUserdata ((KUSER_SHARED_DATA *CONST)(USER_SHARED_DATA|KSEG0_BASE))
|
||||
#else
|
||||
|
||||
//
|
||||
// KPROCESSOR_MODE Type
|
||||
|
@ -643,7 +645,7 @@ typedef struct _KINTERRUPT
|
|||
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
|
||||
ULONGLONG Rsvd1;
|
||||
#endif
|
||||
ULONG DispatchCode[KINTERRUPT_DISPATCH_CODES];
|
||||
ULONG DispatchCode[DISPATCH_LENGTH];
|
||||
} KINTERRUPT;
|
||||
|
||||
//
|
||||
|
@ -1026,6 +1028,8 @@ extern ULONG NTSYSAPI KeMaximumIncrement;
|
|||
extern ULONG NTSYSAPI KeMinimumIncrement;
|
||||
extern ULONG NTSYSAPI KeDcacheFlushCount;
|
||||
extern ULONG NTSYSAPI KeIcacheFlushCount;
|
||||
extern ULONG_PTR NTSYSAPI KiBugCheckData[];
|
||||
extern BOOLEAN NTSYSAPI KiEnableTimerWatchdog;
|
||||
|
||||
//
|
||||
// Exported System Service Descriptor Tables
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#ifndef __WINE_D3D9TYPES_H
|
||||
#define __WINE_D3D9TYPES_H
|
||||
|
||||
#if(DIRECT3D_VERSION >= 0x0900)
|
||||
|
||||
#pragma pack(push, 4)
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -1586,4 +1588,6 @@ typedef enum _D3DCOMPOSERECTSOP{
|
|||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif /* DIRECT3D_VERSION >= 0x0900 */
|
||||
|
||||
#endif /* __WINE_D3D9TYPES_H */
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
|
||||
/* #include <windows.h> FIXME: Need to include for compatibility. Inclusion caused compile fail */
|
||||
|
||||
#if (DIRECT3D_VERSION >= 0x0800)
|
||||
#error "You should not include d3dtypes.h when compiling for DX8 or newer."
|
||||
#endif
|
||||
|
||||
#include <float.h>
|
||||
#include <ddraw.h>
|
||||
|
||||
|
|
|
@ -269,6 +269,7 @@ extern "C" {
|
|||
#define BS_MULTILINE 0x2000
|
||||
#define BS_NOTIFY 0x4000
|
||||
#define BS_OWNERDRAW 0xb
|
||||
#define BS_TYPEMASK 0xFL
|
||||
#define BS_PUSHBUTTON 0
|
||||
#define BS_PUSHLIKE 4096
|
||||
#define BS_RADIOBUTTON 4
|
||||
|
|
|
@ -528,10 +528,9 @@ char *
|
|||
gai_strerrorA(
|
||||
IN int ecode)
|
||||
{
|
||||
DWORD dwMsgLen;
|
||||
static char buff[GAI_STRERROR_BUFFER_SIZE + 1];
|
||||
|
||||
dwMsgLen = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM
|
||||
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM
|
||||
|FORMAT_MESSAGE_IGNORE_INSERTS
|
||||
|FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
||||
NULL,
|
||||
|
@ -549,10 +548,9 @@ WCHAR *
|
|||
gai_strerrorW(
|
||||
IN int ecode)
|
||||
{
|
||||
DWORD dwMsgLen;
|
||||
static WCHAR buff[GAI_STRERROR_BUFFER_SIZE + 1];
|
||||
|
||||
dwMsgLen = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
|
||||
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
|
||||
|FORMAT_MESSAGE_IGNORE_INSERTS
|
||||
|FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
||||
NULL,
|
||||
|
|
108
include/reactos/drivers/serial/ns16550.h
Normal file
108
include/reactos/drivers/serial/ns16550.h
Normal file
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* PROJECT: ReactOS ComPort Library
|
||||
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
||||
* FILE: include/reactos/drivers/serial/ns16550.h
|
||||
* PURPOSE: Header for National Semiconductor 16550 UART
|
||||
* PROGRAMMERS: ReactOS Portable Systems Group
|
||||
*/
|
||||
|
||||
/* INCLUDES *******************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/* Note: These definitions are the internal definitions used by Microsoft serial
|
||||
driver (see src/kernel/serial/serial.h in WDK source code). Linux uses its own, as
|
||||
do most other OS.
|
||||
*/
|
||||
|
||||
#if !defined(SERIAL_REGISTER_STRIDE)
|
||||
#define SERIAL_REGISTER_STRIDE 1
|
||||
#endif
|
||||
|
||||
#define RECEIVE_BUFFER_REGISTER ((ULONG)((0x00)*SERIAL_REGISTER_STRIDE))
|
||||
#define TRANSMIT_HOLDING_REGISTER ((ULONG)((0x00)*SERIAL_REGISTER_STRIDE))
|
||||
#define INTERRUPT_ENABLE_REGISTER ((ULONG)((0x01)*SERIAL_REGISTER_STRIDE))
|
||||
#define INTERRUPT_IDENT_REGISTER ((ULONG)((0x02)*SERIAL_REGISTER_STRIDE))
|
||||
#define FIFO_CONTROL_REGISTER ((ULONG)((0x02)*SERIAL_REGISTER_STRIDE))
|
||||
#define LINE_CONTROL_REGISTER ((ULONG)((0x03)*SERIAL_REGISTER_STRIDE))
|
||||
#define MODEM_CONTROL_REGISTER ((ULONG)((0x04)*SERIAL_REGISTER_STRIDE))
|
||||
#define LINE_STATUS_REGISTER ((ULONG)((0x05)*SERIAL_REGISTER_STRIDE))
|
||||
#define MODEM_STATUS_REGISTER ((ULONG)((0x06)*SERIAL_REGISTER_STRIDE))
|
||||
#define DIVISOR_LATCH_LSB ((ULONG)((0x00)*SERIAL_REGISTER_STRIDE))
|
||||
#define DIVISOR_LATCH_MSB ((ULONG)((0x01)*SERIAL_REGISTER_STRIDE))
|
||||
#define SERIAL_REGISTER_SPAN ((ULONG)(7*SERIAL_REGISTER_STRIDE))
|
||||
#define SERIAL_STATUS_LENGTH ((ULONG)(1*SERIAL_REGISTER_STRIDE))
|
||||
|
||||
#define SERIAL_DATA_LENGTH_5 0x00
|
||||
#define SERIAL_DATA_LENGTH_6 0x01
|
||||
#define SERIAL_DATA_LENGTH_7 0x02
|
||||
#define SERIAL_DATA_LENGTH_8 0x03
|
||||
|
||||
#define SERIAL_IER_RDA 0x01
|
||||
#define SERIAL_IER_THR 0x02
|
||||
#define SERIAL_IER_RLS 0x04
|
||||
#define SERIAL_IER_MS 0x08
|
||||
|
||||
#define SERIAL_IIR_RLS 0x06
|
||||
#define SERIAL_IIR_RDA 0x04
|
||||
#define SERIAL_IIR_CTI 0x0c
|
||||
#define SERIAL_IIR_THR 0x02
|
||||
#define SERIAL_IIR_MS 0x00
|
||||
#define SERIAL_IIR_FIFOS_ENABLED 0xc0
|
||||
#define SERIAL_IIR_NO_INTERRUPT_PENDING 0x01
|
||||
#define SERIAL_IIR_MUST_BE_ZERO 0x30
|
||||
|
||||
#define SERIAL_FCR_ENABLE ((UCHAR)0x01)
|
||||
#define SERIAL_FCR_RCVR_RESET ((UCHAR)0x02)
|
||||
#define SERIAL_FCR_TXMT_RESET ((UCHAR)0x04)
|
||||
|
||||
#define SERIAL_1_BYTE_HIGH_WATER ((UCHAR)0x00)
|
||||
#define SERIAL_4_BYTE_HIGH_WATER ((UCHAR)0x40)
|
||||
#define SERIAL_8_BYTE_HIGH_WATER ((UCHAR)0x80)
|
||||
#define SERIAL_14_BYTE_HIGH_WATER ((UCHAR)0xc0)
|
||||
|
||||
#define SERIAL_LCR_DLAB 0x80
|
||||
#define SERIAL_LCR_BREAK 0x40
|
||||
|
||||
#define SERIAL_5_DATA ((UCHAR)0x00)
|
||||
#define SERIAL_6_DATA ((UCHAR)0x01)
|
||||
#define SERIAL_7_DATA ((UCHAR)0x02)
|
||||
#define SERIAL_8_DATA ((UCHAR)0x03)
|
||||
#define SERIAL_DATA_MASK ((UCHAR)0x03)
|
||||
|
||||
#define SERIAL_1_STOP ((UCHAR)0x00)
|
||||
#define SERIAL_1_5_STOP ((UCHAR)0x04) // Only valid for 5 data bits
|
||||
#define SERIAL_2_STOP ((UCHAR)0x04) // Not valid for 5 data bits
|
||||
#define SERIAL_STOP_MASK ((UCHAR)0x04)
|
||||
|
||||
#define SERIAL_NONE_PARITY ((UCHAR)0x00)
|
||||
#define SERIAL_ODD_PARITY ((UCHAR)0x08)
|
||||
#define SERIAL_EVEN_PARITY ((UCHAR)0x18)
|
||||
#define SERIAL_MARK_PARITY ((UCHAR)0x28)
|
||||
#define SERIAL_SPACE_PARITY ((UCHAR)0x38)
|
||||
#define SERIAL_PARITY_MASK ((UCHAR)0x38)
|
||||
|
||||
#define SERIAL_MCR_DTR 0x01
|
||||
#define SERIAL_MCR_RTS 0x02
|
||||
#define SERIAL_MCR_OUT1 0x04
|
||||
#define SERIAL_MCR_OUT2 0x08
|
||||
#define SERIAL_MCR_LOOP 0x10
|
||||
#define SERIAL_MCR_TL16C550CAFE 0x20
|
||||
|
||||
#define SERIAL_LSR_DR 0x01
|
||||
#define SERIAL_LSR_OE 0x02
|
||||
#define SERIAL_LSR_PE 0x04
|
||||
#define SERIAL_LSR_FE 0x08
|
||||
#define SERIAL_LSR_BI 0x10
|
||||
#define SERIAL_LSR_THRE 0x20
|
||||
#define SERIAL_LSR_TEMT 0x40
|
||||
#define SERIAL_LSR_FIFOERR 0x80
|
||||
|
||||
#define SERIAL_MSR_DCTS 0x01
|
||||
#define SERIAL_MSR_DDSR 0x02
|
||||
#define SERIAL_MSR_TERI 0x04
|
||||
#define SERIAL_MSR_DDCD 0x08
|
||||
#define SERIAL_MSR_CTS 0x10
|
||||
#define SERIAL_MSR_DSR 0x20
|
||||
#define SERIAL_MSR_RI 0x40
|
||||
#define SERIAL_MSR_DCD 0x80
|
74
include/reactos/libs/cportlib/cportlib.h
Normal file
74
include/reactos/libs/cportlib/cportlib.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* PROJECT: ReactOS ComPort Library
|
||||
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
||||
* FILE: include/reactos/lib/cportlib/cportlib.h
|
||||
* PURPOSE: Header for the ComPort Library
|
||||
* PROGRAMMERS: ReactOS Portable Systems Group
|
||||
*/
|
||||
|
||||
/* INCLUDES *******************************************************************/
|
||||
|
||||
#include <ntdef.h>
|
||||
|
||||
#define CP_GET_SUCCESS 0
|
||||
#define CP_GET_NODATA 1
|
||||
#define CP_GET_ERROR 2
|
||||
|
||||
#define CPPORT_FLAG_MODEM_CONTROL 0x02
|
||||
typedef struct _CPPORT
|
||||
{
|
||||
PUCHAR Address;
|
||||
ULONG Baud;
|
||||
USHORT Flags;
|
||||
} CPPORT, *PCPPORT;
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CpInitialize(
|
||||
IN PCPPORT Port,
|
||||
IN PUCHAR Address,
|
||||
IN ULONG Rate
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CpEnableFifo(
|
||||
IN PUCHAR Address,
|
||||
IN BOOLEAN Enable
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
CpDoesPortExist(
|
||||
IN PUCHAR Address
|
||||
);
|
||||
|
||||
UCHAR
|
||||
NTAPI
|
||||
CpReadLsr(
|
||||
IN PCPPORT Port,
|
||||
IN UCHAR ExpectedValue
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CpSetBaud(
|
||||
IN PCPPORT Port,
|
||||
IN ULONG Rate
|
||||
);
|
||||
|
||||
USHORT
|
||||
NTAPI
|
||||
CpGetByte(
|
||||
IN PCPPORT Port,
|
||||
IN PUCHAR Byte,
|
||||
IN BOOLEAN Wait,
|
||||
IN BOOLEAN Poll
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CpPutByte(
|
||||
IN PCPPORT Port,
|
||||
IN UCHAR Byte
|
||||
);
|
2
lib/3rdparty/freetype/freetype.def
vendored
2
lib/3rdparty/freetype/freetype.def
vendored
|
@ -49,7 +49,7 @@ EXPORTS
|
|||
FT_Get_Char_Index
|
||||
FT_Get_Charmap_Index
|
||||
FT_Get_CID_From_Glyph_Index
|
||||
FT_Get_CID_Is_Internally_CID_keyed
|
||||
FT_Get_CID_Is_Internally_CID_Keyed
|
||||
FT_Get_CID_Registry_Ordering_Supplement
|
||||
FT_Get_First_Char
|
||||
FT_Get_FSType_Flags
|
||||
|
|
227
lib/cportlib/cport.c
Normal file
227
lib/cportlib/cport.c
Normal file
|
@ -0,0 +1,227 @@
|
|||
/*
|
||||
* PROJECT: ReactOS ComPort Library
|
||||
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
||||
* FILE: lib/reactos/cportlib/cport.c
|
||||
* PURPOSE: Provides a serial port library for KDCOM, INIT, and FREELDR
|
||||
* PROGRAMMERS: ReactOS Portable Systems Group
|
||||
*/
|
||||
|
||||
/* NOTE: This library follows the precise serial port intialization steps documented
|
||||
* by Microsoft in some of their Server hardware guidance. Because they've clearly
|
||||
* documented their serial algorithms, we use the same ones to stay "compliant".
|
||||
* Do not change this code to "improve" it. It's done this way on purpose, at least on x86.
|
||||
* -- sir_richard
|
||||
*/
|
||||
|
||||
/* NOTE: This code is used by Headless Support (Ntoskrnl.exe and Osloader.exe) and
|
||||
Kdcom.dll in Windows. It may be that WinDBG depends on some of these quirks.
|
||||
*/
|
||||
|
||||
/* NOTE: The original code supports Modem Control. We currently do not */
|
||||
|
||||
/* FIXMEs:
|
||||
- Make this serial-port specific (NS16550 vs other serial port types)
|
||||
- Get x64 KDCOM, KDBG, FREELDR, and other current code to use this
|
||||
*/
|
||||
|
||||
/* INCLUDES *******************************************************************/
|
||||
|
||||
#include <cportlib/cportlib.h>
|
||||
#include <drivers/serial/ns16550.h>
|
||||
#include <intrin.h>
|
||||
#include <ioaccess.h>
|
||||
#include <debug.h>
|
||||
|
||||
/* GLOBALS ********************************************************************/
|
||||
|
||||
UCHAR RingIndicator;
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CpInitialize(IN PCPPORT Port,
|
||||
IN PUCHAR Address,
|
||||
IN ULONG Rate)
|
||||
{
|
||||
/* Reset port data */
|
||||
Port->Address = Address;
|
||||
Port->Baud = 0;
|
||||
|
||||
/* Set the baud rate */
|
||||
CpSetBaud(Port, Rate);
|
||||
|
||||
/* Enable on DTR and RTS */
|
||||
WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER,
|
||||
SERIAL_MCR_DTR | SERIAL_MCR_RTS);
|
||||
|
||||
/* Disable interrupts */
|
||||
WRITE_PORT_UCHAR(Address + INTERRUPT_ENABLE_REGISTER, 0);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CpEnableFifo(IN PUCHAR Address,
|
||||
IN BOOLEAN Enable)
|
||||
{
|
||||
/* Set FIFO */
|
||||
WRITE_PORT_UCHAR(Address + FIFO_CONTROL_REGISTER, Enable ? SERIAL_FCR_ENABLE : 0);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
CpDoesPortExist(IN PUCHAR Address)
|
||||
{
|
||||
UCHAR Old;
|
||||
/*
|
||||
* See "Building Hardware and Firmware to Complement Microsoft Windows Headless Operation"
|
||||
* Out-of-Band Management Port Device Requirements:
|
||||
* The device must act as a 16550 or 16450 UART.
|
||||
* Windows Server 2003 will test this device using the following process.
|
||||
* 1. Save off the current modem status register.
|
||||
* 2. Place the UART into diagnostic mode (The UART is placed into loopback mode
|
||||
* by writing SERIAL_MCR_LOOP to the modem control register).
|
||||
* 3. The modem status register is read and the high bits are checked. This means
|
||||
* SERIAL_MSR_CTS, SERIAL_MSR_DSR, SERIAL_MSR_RI and SERIAL_MSR_DCD should
|
||||
* all be clear.
|
||||
* 4. Place the UART in diagnostic mode and turn on OUTPUT (Loopback Mode and
|
||||
* OUTPUT are both turned on by writing (SERIAL_MCR_LOOP | SERIAL_MCR_OUT1)
|
||||
* to the modem control register).
|
||||
* 5. The modem status register is read and the ring indicator is checked.
|
||||
* This means SERIAL_MSR_RI should be set.
|
||||
* 6. Restore original modem status register.
|
||||
*/
|
||||
Old = READ_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER);
|
||||
WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, SERIAL_MCR_LOOP);
|
||||
WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, SERIAL_MCR_LOOP);
|
||||
if (!(READ_PORT_UCHAR(Address + MODEM_STATUS_REGISTER) &
|
||||
(SERIAL_MSR_CTS | SERIAL_MSR_DSR | SERIAL_MSR_RI | SERIAL_MSR_DCD)))
|
||||
{
|
||||
WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER,
|
||||
(SERIAL_MCR_OUT1 | SERIAL_MCR_LOOP));
|
||||
if (READ_PORT_UCHAR(Address + MODEM_STATUS_REGISTER) & SERIAL_MSR_RI)
|
||||
{
|
||||
WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, Old);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
WRITE_PORT_UCHAR(Address + MODEM_CONTROL_REGISTER, Old);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UCHAR
|
||||
NTAPI
|
||||
CpReadLsr(IN PCPPORT Port,
|
||||
IN UCHAR ExpectedValue)
|
||||
{
|
||||
UCHAR Lsr, Msr;
|
||||
|
||||
/* Read the LSR and check if the expected value is present */
|
||||
Lsr = READ_PORT_UCHAR(Port->Address + LINE_STATUS_REGISTER);
|
||||
if (!(Lsr & ExpectedValue))
|
||||
{
|
||||
/* Check the MSR for ring indicator toggle */
|
||||
Msr = READ_PORT_UCHAR(Port->Address + MODEM_STATUS_REGISTER);
|
||||
|
||||
/* If the indicator reaches 3, we've seen this on/off twice */
|
||||
RingIndicator |= (Msr & SERIAL_MSR_RI) ? 1 : 2;
|
||||
if (RingIndicator == 3) Port->Flags |= CPPORT_FLAG_MODEM_CONTROL;
|
||||
}
|
||||
|
||||
return Lsr;
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CpSetBaud(IN PCPPORT Port,
|
||||
IN ULONG Rate)
|
||||
{
|
||||
UCHAR Lcr;
|
||||
USHORT Mode;
|
||||
|
||||
/* Add DLAB */
|
||||
Lcr = READ_PORT_UCHAR(Port->Address + LINE_CONTROL_REGISTER);
|
||||
WRITE_PORT_UCHAR(Port->Address + LINE_CONTROL_REGISTER, Lcr | SERIAL_LCR_DLAB);
|
||||
|
||||
/* Set baud rate */
|
||||
Mode = 115200 / Rate;
|
||||
WRITE_PORT_UCHAR(Port->Address + DIVISOR_LATCH_MSB, (UCHAR)((Mode >> 8) & 0xff));
|
||||
WRITE_PORT_UCHAR(Port->Address + DIVISOR_LATCH_LSB, (UCHAR)(Mode & 0xff));
|
||||
|
||||
/* Reset DLAB and set 8 data bits, 1 stop bit, no parity, no break */
|
||||
WRITE_PORT_UCHAR(Port->Address + LINE_CONTROL_REGISTER,
|
||||
SERIAL_8_DATA | SERIAL_1_STOP | SERIAL_NONE_PARITY);
|
||||
|
||||
/* Save baud rate in port */
|
||||
Port->Baud = Rate;
|
||||
}
|
||||
|
||||
USHORT
|
||||
NTAPI
|
||||
CpGetByte(IN PCPPORT Port,
|
||||
IN PUCHAR Byte,
|
||||
IN BOOLEAN Wait,
|
||||
IN BOOLEAN Poll)
|
||||
{
|
||||
UCHAR Lsr;
|
||||
ULONG i;
|
||||
|
||||
/* Handle early read-before-init */
|
||||
if (!Port->Address) return CP_GET_NODATA;
|
||||
|
||||
/* If "wait" mode enabled, spin many times, otherwise attempt just once */
|
||||
i = Wait ? 204800 : 1;
|
||||
while (i--)
|
||||
{
|
||||
/* Read LSR for data ready */
|
||||
Lsr = CpReadLsr(Port, SERIAL_LSR_DR);
|
||||
if ((Lsr & SERIAL_LSR_DR) == SERIAL_LSR_DR)
|
||||
{
|
||||
/* If an error happened, clear the byte and fail */
|
||||
if (Lsr & (SERIAL_LSR_FE | SERIAL_LSR_PE))
|
||||
{
|
||||
*Byte = 0;
|
||||
return CP_GET_ERROR;
|
||||
}
|
||||
|
||||
/* If only polling was requested by caller, return now */
|
||||
if (Poll) return CP_GET_SUCCESS;
|
||||
|
||||
/* Otherwise read the byte and return it */
|
||||
*Byte = READ_PORT_UCHAR(Port->Address + RECEIVE_BUFFER_REGISTER);
|
||||
|
||||
/* Handle CD if port is in modem control mode */
|
||||
if (Port->Flags & CPPORT_FLAG_MODEM_CONTROL)
|
||||
{
|
||||
/* Not implemented yet */
|
||||
DPRINT1("CP: CPPORT_FLAG_MODEM_CONTROL unexpected\n");
|
||||
}
|
||||
|
||||
/* Byte was read */
|
||||
return CP_GET_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset LSR, no data was found */
|
||||
CpReadLsr(Port, 0);
|
||||
return CP_GET_NODATA;
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CpPutByte(IN PCPPORT Port,
|
||||
IN UCHAR Byte)
|
||||
{
|
||||
/* Check if port is in modem control to handle CD */
|
||||
while (Port->Flags & CPPORT_FLAG_MODEM_CONTROL)
|
||||
{
|
||||
/* Not implemented yet */
|
||||
DPRINT1("CP: CPPORT_FLAG_MODEM_CONTROL unexpected\n");
|
||||
}
|
||||
|
||||
/* Wait for LSR to say we can go ahead */
|
||||
while (!(CpReadLsr(Port, SERIAL_LSR_THRE) & SERIAL_LSR_THRE));
|
||||
|
||||
/* Send the byte */
|
||||
WRITE_PORT_UCHAR(Port->Address + RECEIVE_BUFFER_REGISTER, Byte);
|
||||
}
|
8
lib/cportlib/cportlib.rbuild
Normal file
8
lib/cportlib/cportlib.rbuild
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module SYSTEM "../../tools/rbuild/project.dtd">
|
||||
<group>
|
||||
<module name="cportlib" type="staticlibrary">
|
||||
<include base="cportlib">.</include>
|
||||
<file>cport.c</file>
|
||||
</module>
|
||||
</group>
|
|
@ -163,7 +163,7 @@ PIP_INTERFACE IPCreateInterface(
|
|||
TcpipInitializeSpinLock(&IF->Lock);
|
||||
|
||||
IF->TCPContext = ExAllocatePoolWithTag
|
||||
( NonPagedPool, sizeof(OSK_IFADDR) + 2 * sizeof( struct sockaddr_in ),
|
||||
( NonPagedPool, sizeof(OSK_IFADDR) + 3 * sizeof( struct sockaddr_in ),
|
||||
OSKITTCP_CONTEXT_TAG );
|
||||
if (!IF->TCPContext) {
|
||||
ExFreePoolWithTag(IF, IP_INTERFACE_TAG);
|
||||
|
|
|
@ -35,20 +35,17 @@ POSK_IFADDR TCPGetInterfaceData( PIP_INTERFACE IF ) {
|
|||
POSK_IFADDR ifaddr = IF->TCPContext;
|
||||
struct sockaddr_in *addr_in;
|
||||
struct sockaddr_in *dstaddr_in;
|
||||
struct sockaddr_in *netmask_in;
|
||||
ASSERT(ifaddr);
|
||||
|
||||
RtlZeroMemory(ifaddr, sizeof(OSK_IFADDR) + 2 * sizeof( struct sockaddr_in ));
|
||||
RtlZeroMemory(ifaddr, sizeof(OSK_IFADDR) + 3 * sizeof( struct sockaddr_in ));
|
||||
|
||||
addr_in = (struct sockaddr_in *)&ifaddr[1];
|
||||
dstaddr_in = (struct sockaddr_in *)&addr_in[1];
|
||||
netmask_in = (struct sockaddr_in *)&dstaddr_in[1];
|
||||
|
||||
TI_DbgPrint(DEBUG_TCPIF,("Called\n"));
|
||||
|
||||
ifaddr->ifa_dstaddr = (struct sockaddr *)dstaddr_in;
|
||||
|
||||
/* XXX - Point-to-point interfaces not supported yet */
|
||||
memset( &ifaddr->ifa_dstaddr, 0, sizeof( struct sockaddr ) );
|
||||
|
||||
ifaddr->ifa_addr = (struct sockaddr *)addr_in;
|
||||
Status = GetInterfaceIPv4Address( IF,
|
||||
ADE_UNICAST,
|
||||
|
@ -56,10 +53,24 @@ POSK_IFADDR TCPGetInterfaceData( PIP_INTERFACE IF ) {
|
|||
|
||||
ASSERT(NT_SUCCESS(Status));
|
||||
|
||||
ifaddr->ifa_dstaddr = (struct sockaddr *)dstaddr_in;
|
||||
Status = GetInterfaceIPv4Address(IF,
|
||||
ADE_POINTOPOINT,
|
||||
(PULONG)&dstaddr_in->sin_addr.s_addr );
|
||||
|
||||
ASSERT(NT_SUCCESS(Status));
|
||||
|
||||
ifaddr->ifa_netmask = (struct sockaddr *)netmask_in;
|
||||
Status = GetInterfaceIPv4Address(IF,
|
||||
ADE_ADDRMASK,
|
||||
(PULONG)&netmask_in->sin_addr.s_addr );
|
||||
|
||||
ASSERT(NT_SUCCESS(Status));
|
||||
|
||||
TI_DbgPrint(DEBUG_TCPIF,("interface %x : addr %x\n",
|
||||
IF, addr_in->sin_addr.s_addr));
|
||||
|
||||
ifaddr->ifa_flags = 0; /* XXX what goes here? */
|
||||
ifaddr->ifa_flags = 0;
|
||||
ifaddr->ifa_refcnt = 0; /* Anachronistic */
|
||||
ifaddr->ifa_metric = 1; /* We can get it like in ninfo.c, if we want */
|
||||
ifaddr->ifa_mtu = IF->MTU;
|
||||
|
|
|
@ -151,6 +151,9 @@ int OskitTCPRecv( void *connection,
|
|||
struct iovec iov = { 0 };
|
||||
int error = 0;
|
||||
int tcp_flags = 0;
|
||||
|
||||
if (!connection)
|
||||
return OSK_ESHUTDOWN;
|
||||
|
||||
OS_DbgPrint(OSK_MID_TRACE,
|
||||
("so->so_state %x\n", ((struct socket *)connection)->so_state));
|
||||
|
@ -218,14 +221,12 @@ int OskitTCPConnect( void *socket, void *nam, OSK_UINT namelen ) {
|
|||
struct sockaddr addr;
|
||||
|
||||
OS_DbgPrint(OSK_MID_TRACE,("Called, socket = %08x\n", socket));
|
||||
|
||||
OSKLock();
|
||||
if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) {
|
||||
error = EALREADY;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!socket)
|
||||
return OSK_ESHUTDOWN;
|
||||
|
||||
OS_DbgPrint(OSK_MIN_TRACE,("Nam: %x\n", nam));
|
||||
|
||||
if( nam )
|
||||
addr = *((struct sockaddr *)nam);
|
||||
|
||||
|
@ -236,26 +237,12 @@ int OskitTCPConnect( void *socket, void *nam, OSK_UINT namelen ) {
|
|||
addr.sa_family = addr.sa_len;
|
||||
addr.sa_len = sizeof(struct sockaddr);
|
||||
|
||||
OSKLock();
|
||||
error = soconnect(so, &sabuf);
|
||||
|
||||
if (error == EINPROGRESS)
|
||||
goto done;
|
||||
else if (error)
|
||||
goto bad;
|
||||
|
||||
if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) {
|
||||
error = EINPROGRESS;
|
||||
goto done;
|
||||
}
|
||||
|
||||
bad:
|
||||
so->so_state &= ~SS_ISCONNECTING;
|
||||
|
||||
if (error == ERESTART)
|
||||
error = EINTR;
|
||||
|
||||
done:
|
||||
OSKUnlock();
|
||||
|
||||
if (error == 0) error = OSK_EINPROGRESS;
|
||||
|
||||
OS_DbgPrint(OSK_MID_TRACE,("Ending: %08x\n", error));
|
||||
return (error);
|
||||
}
|
||||
|
@ -347,14 +334,12 @@ int OskitTCPAccept( void *socket,
|
|||
if (!socket)
|
||||
return OSK_ESHUTDOWN;
|
||||
|
||||
if (!new_socket || !AddrOut)
|
||||
if (!new_socket)
|
||||
return OSK_EINVAL;
|
||||
|
||||
OS_DbgPrint(OSK_MID_TRACE,("OSKITTCP: Doing accept (Finish %d)\n",
|
||||
FinishAccepting));
|
||||
|
||||
*OutAddrLen = AddrLen;
|
||||
|
||||
if (name)
|
||||
/* that's a copyin actually */
|
||||
namelen = *OutAddrLen;
|
||||
|
@ -363,19 +348,17 @@ int OskitTCPAccept( void *socket,
|
|||
|
||||
s = splnet();
|
||||
|
||||
#if 0
|
||||
if ((head->so_options & SO_ACCEPTCONN) == 0) {
|
||||
OS_DbgPrint(OSK_MID_TRACE,("OSKITTCP: head->so_options = %x, wanted bit %x\n",
|
||||
head->so_options, SO_ACCEPTCONN));
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
||||
OS_DbgPrint(OSK_MID_TRACE,("head->so_q = %x, head->so_state = %x\n",
|
||||
head->so_q, head->so_state));
|
||||
|
||||
if ((head->so_state & SS_NBIO) && head->so_q == NULL) {
|
||||
if (head->so_q == NULL) {
|
||||
error = EWOULDBLOCK;
|
||||
goto out;
|
||||
}
|
||||
|
@ -395,8 +378,6 @@ int OskitTCPAccept( void *socket,
|
|||
|
||||
OS_DbgPrint(OSK_MID_TRACE,("error = %d\n", error));
|
||||
if( FinishAccepting && so ) {
|
||||
head->so_q = so->so_q;
|
||||
head->so_qlen--;
|
||||
|
||||
mnam.m_data = (char *)&sa;
|
||||
mnam.m_len = sizeof(sa);
|
||||
|
@ -405,12 +386,9 @@ int OskitTCPAccept( void *socket,
|
|||
if (error)
|
||||
goto out;
|
||||
|
||||
InitializeSocketFlags(so);
|
||||
so->so_state |= SS_ISCONNECTED;
|
||||
so->so_q = so->so_q0 = NULL;
|
||||
so->so_qlen = so->so_q0len = 0;
|
||||
so->so_head = 0;
|
||||
soqremque(so, 1);
|
||||
so->so_connection = context;
|
||||
soisconnected(so);
|
||||
|
||||
*newso = so;
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
<directory name="cmlib">
|
||||
<xi:include href="cmlib/cmlib.rbuild" />
|
||||
</directory>
|
||||
<directory name="cportlib">
|
||||
<xi:include href="cportlib/cportlib.rbuild" />
|
||||
</directory>
|
||||
<directory name="debugsup">
|
||||
<xi:include href="debugsup/debugsup.rbuild" />
|
||||
</directory>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue