ReactOS  0.4.14-dev-297-g23e575c
hardware.cpp File Reference
#include "usbuhci.h"
#include <debug.h>
Include dependency graph for hardware.cpp:

Go to the source code of this file.

Classes

class  CUSBHardwareDevice
 

Macros

#define NDEBUG
 

Typedefs

typedef VOID __stdcall HD_INIT_CALLBACK(IN PVOID CallBackContext)
 

Functions

BOOLEAN NTAPI InterruptServiceRoutine (IN PKINTERRUPT Interrupt, IN PVOID ServiceContext)
 
VOID NTAPI UhciDeferredRoutine (IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
 
VOID NTAPI TimerDpcRoutine (IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
 
VOID NTAPI StatusChangeWorkItemRoutine (PVOID Context)
 
NTSTATUS NTAPI CreateUSBHardware (PUSBHARDWAREDEVICE *OutHardware)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file hardware.cpp.

Typedef Documentation

◆ HD_INIT_CALLBACK

typedef VOID __stdcall HD_INIT_CALLBACK(IN PVOID CallBackContext)

Definition at line 16 of file hardware.cpp.

Function Documentation

◆ CreateUSBHardware()

NTSTATUS NTAPI CreateUSBHardware ( PUSBHARDWAREDEVICE OutHardware)

Definition at line 1500 of file hardware.cpp.

1502 {
1504 
1506 
1507  if (!This)
1509 
1510  This->AddRef();
1511 
1512  // return result
1513  *OutHardware = (PUSBHARDWAREDEVICE)This;
1514 
1515  return STATUS_SUCCESS;
1516 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
IUSBHardwareDevice * PUSBHARDWAREDEVICE
#define TAG_USBUHCI
Definition: usbuhci.h:26
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ InterruptServiceRoutine()

BOOLEAN NTAPI InterruptServiceRoutine ( IN PKINTERRUPT  Interrupt,
IN PVOID  ServiceContext 
)

Definition at line 1214 of file hardware.cpp.

1217 {
1219  USHORT Status, Acknowledge;
1220 
1221  //
1222  // get context
1223  //
1225 
1226  //
1227  // read register
1228  //
1229  Status = This->ReadRegister16(UHCI_USBSTS);
1230  DPRINT("InterruptServiceRoutine %x\n", Status);
1231 
1232  //
1233  // check if the interrupt signaled are from us
1234  //
1235  if ((Status & This->m_InterruptMask) == 0)
1236  {
1237  if (Status != 0)
1238  {
1239  //
1240  // FIXME: received unexpected interrupt
1241  //
1242  DPRINT1("[USBUHCI] Unexpected interrupt %x\n", Status);
1243  This->WriteRegister16(UHCI_USBSTS, Status);
1244  }
1245 
1246  //
1247  // shared interrupt
1248  //
1249  return FALSE;
1250  }
1251 
1252  //
1253  // check for the interrupt cause
1254  //
1255  Acknowledge = 0;
1256 
1257  if (Status & UHCI_USBSTS_USBINT)
1258  {
1259  //
1260  // transfer finished
1261  //
1262  Acknowledge |= UHCI_USBSTS_USBINT;
1263  }
1264 
1265  if (Status & UHCI_USBSTS_ERRINT)
1266  {
1267  //
1268  // error interrupt
1269  //
1270  Acknowledge |= UHCI_USBSTS_ERRINT;
1271  DPRINT("[UHCI] Error interrupt\n");
1272  }
1273 
1274  if (Status & UHCI_USBSTS_RESDET)
1275  {
1276  //
1277  // resume detected
1278  //
1279  DPRINT("[UHCI] Resume detected\n");
1280  Acknowledge |= UHCI_USBSTS_RESDET;
1281  }
1282 
1283  if (Status & UHCI_USBSTS_HOSTERR)
1284  {
1285  //
1286  // host system error
1287  //
1288  DPRINT("[UHCI] Host System Error\n");
1289  Acknowledge |= UHCI_USBSTS_HOSTERR;
1290  }
1291 
1292  if (Status & UHCI_USBSTS_HCPRERR)
1293  {
1294  //
1295  // processing error
1296  //
1297  DPRINT("[UHCI] Process Error\n");
1298  Acknowledge |= UHCI_USBSTS_HCPRERR;
1299  }
1300 
1301  if (Status & UHCI_USBSTS_HCHALT)
1302  {
1303  //
1304  // controller halted
1305  //
1306  DPRINT("[UHCI] Host controller halted\n");
1307 
1308  //
1309  // disable interrupts
1310  //
1311  This->WriteRegister16(UHCI_USBINTR, 0);
1312  This->m_InterruptMask = 0;
1313  }
1314 
1315  //
1316  // do we have something to acknowledge
1317  //
1318  if (Acknowledge)
1319  {
1320  //
1321  // acknowledge interrupt
1322  //
1323  This->WriteRegister16(UHCI_USBSTS, Acknowledge);
1324 
1325  //
1326  // queue dpc
1327  //
1328  KeInsertQueueDpc(&This->m_IntDpcObject, UlongToPtr(Status), NULL);
1329  }
1330 
1331  //
1332  // interrupt handled
1333  //
1334  return TRUE;
1335 }
#define TRUE
Definition: types.h:120
#define UHCI_USBINTR
Definition: hardware.h:29
BOOLEAN NTAPI KeInsertQueueDpc(IN PKDPC Dpc, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: dpc.c:724
#define UHCI_USBSTS_USBINT
Definition: hardware.h:47
#define UHCI_USBSTS_HOSTERR
Definition: hardware.h:50
smooth NULL
Definition: ftsmooth.c:416
#define UHCI_USBSTS_HCPRERR
Definition: hardware.h:51
void DPRINT(...)
Definition: polytest.cpp:61
#define UlongToPtr(u)
Definition: config.h:106
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID ServiceContext
Definition: iofuncs.h:798
#define UHCI_USBSTS_RESDET
Definition: hardware.h:49
#define UHCI_USBSTS
Definition: hardware.h:28
#define UHCI_USBSTS_HCHALT
Definition: hardware.h:52
Status
Definition: gdiplustypes.h:24
unsigned short USHORT
Definition: pedump.c:61
#define DPRINT1
Definition: precomp.h:8
#define UHCI_USBSTS_ERRINT
Definition: hardware.h:48

◆ StatusChangeWorkItemRoutine()

VOID NTAPI StatusChangeWorkItemRoutine ( PVOID  Context)

Definition at line 1477 of file hardware.cpp.

1479 {
1480  //
1481  // cast to hardware object
1482  //
1484 
1485  //
1486  // is there a callback
1487  //
1488  if (This->m_SCECallBack)
1489  {
1490  //
1491  // issue callback
1492  //
1493  This->m_SCECallBack(This->m_SCEContext);
1494  }
1495 
1496 }

◆ TimerDpcRoutine()

VOID NTAPI TimerDpcRoutine ( IN PKDPC  Dpc,
IN PVOID  DeferredContext,
IN PVOID  SystemArgument1,
IN PVOID  SystemArgument2 
)

Definition at line 1443 of file hardware.cpp.

1448 {
1450  USHORT PortStatus = 0;
1451  USHORT PortChange = 0;
1452 
1453  // get parameters
1455 
1456  // check port 0
1457  This->GetPortStatus(0, &PortStatus, &PortChange);
1458  if (PortChange)
1459  {
1460  // invoke status change work item routine
1462  return;
1463  }
1464 
1465  // check port 1
1466  This->GetPortStatus(1, &PortStatus, &PortChange);
1467  if (PortChange)
1468  {
1469  // invoke status change work item routine
1471  }
1472 }
VOID NTAPI StatusChangeWorkItemRoutine(PVOID Context)
Definition: hardware.cpp:1447
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT PortStatus
Definition: hubbusif.h:40
unsigned short USHORT
Definition: pedump.c:61
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:675

◆ UhciDeferredRoutine()

VOID NTAPI UhciDeferredRoutine ( IN PKDPC  Dpc,
IN PVOID  DeferredContext,
IN PVOID  SystemArgument1,
IN PVOID  SystemArgument2 
)

Definition at line 1406 of file hardware.cpp.

1411 {
1413  ULONG Status;
1414 
1415  //
1416  // get parameters
1417  //
1419 
1420  DPRINT("UhciDeferredRoutine\n");
1421 
1422  //
1423  // get status
1424  //
1427  {
1428  //
1429  // a transfer finished, inform the queue
1430  //
1431  This->m_UsbQueue->TransferInterrupt(Status & UHCI_USBSTS_USBINT);
1432  return;
1433  }
1434 
1435  //
1436  // other event
1437  //
1438  DPRINT1("[USBUHCI] Status %x not handled\n", Status);
1439 }
#define UHCI_USBSTS_USBINT
Definition: hardware.h:47
void DPRINT(...)
Definition: polytest.cpp:61
#define PtrToUlong(u)
Definition: config.h:107
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8
#define UHCI_USBSTS_ERRINT
Definition: hardware.h:48
unsigned int ULONG
Definition: retypes.h:1
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:675