#ifdef ALLOC_PRAGMA
-// Make the initialization routines discardable, so that they
+// Make the initialization routines discardable, so that they
// don't waste space
#pragma alloc_text(init, DriverEntry)
NTSTATUS
STDCALL
ACPIDispatchDeviceControl(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
{
PIO_STACK_LOCATION IrpSp;
NTSTATUS Status;
* -------------
* Either fixed-feature or generic (namespace) types.
*/
- if (strncmp(device->id.hid, BN_HID_POWER_BUTTON,
+ if (strncmp(device->id.hid, BN_HID_POWER_BUTTON,
sizeof(BM_DEVICE_HID)) == 0) {
if (device->id.type == BM_TYPE_FIXED_BUTTON) {
/* Register for fixed-feature events. */
status = acpi_install_fixed_event_handler(
- ACPI_EVENT_POWER_BUTTON, bn_notify_fixed,
+ ACPI_EVENT_POWER_BUTTON, bn_notify_fixed,
(void*)button);
}
else {
* -------------
* Either fixed-feature or generic (namespace) types.
*/
- else if (strncmp( device->id.hid, BN_HID_SLEEP_BUTTON,
+ else if (strncmp( device->id.hid, BN_HID_SLEEP_BUTTON,
sizeof(BM_DEVICE_HID)) == 0) {
if (device->id.type == BM_TYPE_FIXED_BUTTON) {
/* Register for fixed-feature events. */
status = acpi_install_fixed_event_handler(
- ACPI_EVENT_SLEEP_BUTTON, bn_notify_fixed,
+ ACPI_EVENT_SLEEP_BUTTON, bn_notify_fixed,
(void*)button);
}
else {
* LID Switch?
* -----------
*/
- else if (strncmp( device->id.hid, BN_HID_LID_SWITCH,
+ else if (strncmp( device->id.hid, BN_HID_LID_SWITCH,
sizeof(BM_DEVICE_HID)) == 0) {
button->type = BN_TYPE_LID_SWITCH;
*/
MEMCPY(criteria.hid, BN_HID_LID_SWITCH, sizeof(BN_HID_LID_SWITCH));
status = bm_register_driver(&criteria, &driver);
-
+
if (status == AE_NOT_FOUND)
status = AE_OK;
case BN_TYPE_POWER_BUTTON_FIXED:
DEBUG_PRINT(ACPI_INFO, ("Fixed-feature button status change event detected.\n"));
- /*bm_generate_event(button->device_handle, BN_PROC_ROOT,
+ /*bm_generate_event(button->device_handle, BN_PROC_ROOT,
BN_PROC_POWER_BUTTON, BN_NOTIFY_STATUS_CHANGE, 0);*/
break;
case BN_TYPE_SLEEP_BUTTON_FIXED:
DEBUG_PRINT(ACPI_INFO, ("Fixed-feature button status change event detected.\n"));
- /*bm_generate_event(button->device_handle, BN_PROC_ROOT,
+ /*bm_generate_event(button->device_handle, BN_PROC_ROOT,
BN_PROC_SLEEP_BUTTON, BN_NOTIFY_STATUS_CHANGE, 0);*/
break;
case BM_NOTIFY_DEVICE_ADDED:
status = bn_add_device(device_handle, context);
break;
-
+
case BM_NOTIFY_DEVICE_REMOVED:
status = bn_remove_device(context);
break;
-
+
case BN_NOTIFY_STATUS_CHANGE:
DEBUG_PRINT(ACPI_INFO, ("Button status change event detected.\n"));
case BN_TYPE_POWER_BUTTON:
case BN_TYPE_POWER_BUTTON_FIXED:
- /*bm_generate_event(device_handle, BN_PROC_ROOT,
+ /*bm_generate_event(device_handle, BN_PROC_ROOT,
BN_PROC_POWER_BUTTON, notify_type, 0);*/
break;
* Evaluate _STA:
* --------------
*/
- status = bm_evaluate_simple_integer(device->acpi_handle, "_STA",
+ status = bm_evaluate_simple_integer(device->acpi_handle, "_STA",
&(device->status));
return status;
}
if (info.valid & ACPI_VALID_UID) {
- MEMCPY((void*)device->id.uid, (void*)info.unique_id,
+ MEMCPY((void*)device->id.uid, (void*)info.unique_id,
sizeof(BM_DEVICE_UID));
}
if (info.valid & ACPI_VALID_HID) {
- MEMCPY((void*)device->id.hid, (void*)info.hardware_id,
+ MEMCPY((void*)device->id.hid, (void*)info.hardware_id,
sizeof(BM_DEVICE_HID));
}
/*
* Presence of _DCK indicates a docking station.
*/
- if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
+ if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
"_DCK", &acpi_handle))) {
device->flags |= BM_FLAGS_DOCKING_STATION;
}
* Presence of _EJD and/or _EJx indicates 'ejectable'.
* TODO: _EJx...
*/
- if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
+ if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
"_EJD", &acpi_handle))) {
device->flags |= BM_FLAGS_EJECTABLE;
}
/*
* Presence of _PR0 or _PS0 indicates 'power manageable'.
*/
- if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
+ if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
"_PR0", &acpi_handle)) ||
- ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
+ ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
"_PS0", &acpi_handle))) {
device->flags |= BM_FLAGS_POWER_CONTROL;
}
/*
* Presence of _CRS indicates 'configurable'.
*/
- if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
+ if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
"_CRS", &acpi_handle))) {
device->flags |= BM_FLAGS_CONFIGURABLE;
}
/*
* Presence of _HID or _ADR indicates 'identifiable'.
*/
- if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
+ if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
"_HID", &acpi_handle)) ||
- ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
+ ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
"_ADR", &acpi_handle))) {
device->flags |= BM_FLAGS_IDENTIFIABLE;
}
/*
* Presence of _STA indicates 'dynamic status'.
*/
- if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
+ if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle,
"_STA", &acpi_handle))) {
device->flags |= BM_FLAGS_DYNAMIC_STATUS;
}
/*
* Device Type:
* ------------
- */
+ */
switch (acpi_type) {
case INTERNAL_TYPE_SCOPE:
device->id.type = BM_TYPE_SCOPE;
/*
* Power Management:
* -----------------
- * If this node doesn't provide direct power control
+ * If this node doesn't provide direct power control
* then we inherit PM capabilities from its parent.
*
* TODO: Inherit!
if (ACPI_SUCCESS(status)) {
/*
- * TODO: This is a hack to get around the problem
- * identifying scope objects. Scopes
+ * TODO: This is a hack to get around the problem
+ * identifying scope objects. Scopes
* somehow need to be uniquely identified.
*/
status = acpi_get_type(child_handle, &acpi_type);
else {
level--;
child_handle = parent_handle;
- acpi_get_parent(parent_handle,
+ acpi_get_parent(parent_handle,
&parent_handle);
if (parent) {
node->device.acpi_handle = ACPI_ROOT_OBJECT;
node->device.id.type = BM_TYPE_FIXED_BUTTON;
if (device_hid) {
- MEMCPY((void*)node->device.id.hid, device_hid,
+ MEMCPY((void*)node->device.id.hid, device_hid,
sizeof(node->device.id.hid));
}
node->device.flags = BM_FLAGS_FIXED_FEATURE;
*/
DEBUG_PRINT(ACPI_INFO, ("Registering for all device notifications.\n"));
- status = acpi_install_notify_handler(ACPI_ROOT_OBJECT,
+ status = acpi_install_notify_handler(ACPI_ROOT_OBJECT,
ACPI_SYSTEM_NOTIFY, &bm_notify, NULL);
if (ACPI_FAILURE(status)) {
DEBUG_PRINT(ACPI_ERROR, ("Unable to register for standard notifications.\n"));
return_ACPI_STATUS(status);
}
- status = acpi_install_notify_handler(ACPI_ROOT_OBJECT,
+ status = acpi_install_notify_handler(ACPI_ROOT_OBJECT,
ACPI_DEVICE_NOTIFY, &bm_notify, NULL);
if (ACPI_FAILURE(status)) {
DEBUG_PRINT(ACPI_ERROR, ("Unable to register for device-specific notifications.\n"));
DEBUG_PRINT(ACPI_INFO, ("Unregistering for device notifications.\n"));
- status = acpi_remove_notify_handler(ACPI_ROOT_OBJECT,
+ status = acpi_remove_notify_handler(ACPI_ROOT_OBJECT,
ACPI_SYSTEM_NOTIFY, &bm_notify);
if (ACPI_FAILURE(status)) {
DEBUG_PRINT(ACPI_ERROR, ("Unable to un-register for standard notifications.\n"));
}
- status = acpi_remove_notify_handler(ACPI_ROOT_OBJECT,
+ status = acpi_remove_notify_handler(ACPI_ROOT_OBJECT,
ACPI_DEVICE_NOTIFY, &bm_notify);
if (ACPI_FAILURE(status)) {
DEBUG_PRINT(ACPI_ERROR, ("Unable to un-register for device-specific notifications.\n"));
DEBUG_PRINT(ACPI_INFO, ("Sending notify [0x%02x] to device [0x%02x].\n", notify_type, node->device.handle));
- if (!(node->device.flags & BM_FLAGS_DRIVER_CONTROL) ||
+ if (!(node->device.flags & BM_FLAGS_DRIVER_CONTROL) ||
!(node->driver.notify)) {
DEBUG_PRINT(ACPI_WARN, ("No driver installed for device [0x%02x].\n", node->device.handle));
return_ACPI_STATUS(AE_NOT_EXIST);
}
- status = node->driver.notify(notify_type, node->device.handle,
+ status = node->driver.notify(notify_type, node->device.handle,
&(node->driver.context));
return_ACPI_STATUS(status);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
-
+
if (old_status == node->device.status) {
return_ACPI_STATUS(AE_OK);
}
if (status_change) {
*status_change = TRUE;
}
-
+
/*
* Device Insertion?
* -----------------
*/
- if ((device->status & BM_STATUS_PRESENT) &&
+ if ((device->status & BM_STATUS_PRESENT) &&
!(old_status & BM_STATUS_PRESENT)) {
/* TODO: Make sure driver is loaded, and if not, load. */
status = bm_generate_notify(node, BM_NOTIFY_DEVICE_ADDED);
* Device Removal?
* ---------------
*/
- else if (!(device->status & BM_STATUS_PRESENT) &&
+ else if (!(device->status & BM_STATUS_PRESENT) &&
(old_status & BM_STATUS_PRESENT)) {
/* TODO: Unload driver if last device instance. */
status = bm_generate_notify(node, BM_NOTIFY_DEVICE_REMOVED);
/*
* Device-Specific or Standard?
* ----------------------------
- * Device-specific notifies are forwarded to the control module's
+ * Device-specific notifies are forwarded to the control module's
* notify() function for processing. Standard notifies are handled
* internally.
*/
/*
* Calculate Power State:
* ----------------------
- * Try to infer the devices's power state by checking the state of
- * the devices's power resources. We start by evaluating _PR0
- * (resource requirements at D0) and work through _PR1 and _PR2.
- * We know the current devices power state when all resources (for
- * a give Dx state) are ON. If no power resources are on then the
+ * Try to infer the devices's power state by checking the state of
+ * the devices's power resources. We start by evaluating _PR0
+ * (resource requirements at D0) and work through _PR1 and _PR2.
+ * We know the current devices power state when all resources (for
+ * a give Dx state) are ON. If no power resources are on then the
* device is assumed to be off (D3).
*/
for (i=ACPI_STATE_D0; i<ACPI_STATE_D3; i++) {
- status = bm_evaluate_reference_list(device->acpi_handle,
+ status = bm_evaluate_reference_list(device->acpi_handle,
object_name, &pr_list);
if (ACPI_SUCCESS(status)) {
- status = bm_pr_list_get_state(&pr_list,
+ status = bm_pr_list_get_state(&pr_list,
&list_state);
if (ACPI_SUCCESS(status)) {
device->power.state = ACPI_STATE_UNKNOWN;
if (device->flags & BM_FLAGS_POWER_STATE) {
- status = bm_evaluate_simple_integer(device->acpi_handle,
+ status = bm_evaluate_simple_integer(device->acpi_handle,
"_PSC", &(device->power.state));
}
else {
/*
* Get Resources:
* --------------
- * Get the power resources associated with the device's current
+ * Get the power resources associated with the device's current
* and target power states.
*/
if (device->power.state != ACPI_STATE_UNKNOWN) {
object_name[3] = '0' + device->power.state;
- bm_evaluate_reference_list(device->acpi_handle,
+ bm_evaluate_reference_list(device->acpi_handle,
object_name, ¤t_list);
}
object_name[3] = '0' + state;
- bm_evaluate_reference_list(device->acpi_handle, object_name,
+ bm_evaluate_reference_list(device->acpi_handle, object_name,
&target_list);
/*
* Transition Resources:
* ---------------------
- * Transition all power resources referenced by this device to
- * the correct power state (taking into consideration sequencing
+ * Transition all power resources referenced by this device to
+ * the correct power state (taking into consideration sequencing
* and dependencies to other devices).
*/
if (current_list.count || target_list.count) {
/*
* Execute _PSx:
* -------------
- * Execute the _PSx method corresponding to the target Dx state,
+ * Execute the _PSx method corresponding to the target Dx state,
* if it exists.
*/
object_name[2] = 'S';
* Power Management Flags:
* -----------------------
*/
- if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PSC",
+ if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PSC",
&acpi_handle))) {
device->power.flags |= BM_FLAGS_POWER_STATE;
}
- if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_IRC",
+ if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_IRC",
&acpi_handle))) {
device->power.flags |= BM_FLAGS_INRUSH_CURRENT;
}
- if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PRW",
+ if (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PRW",
&acpi_handle))) {
device->power.flags |= BM_FLAGS_WAKE_CAPABLE;
}
* Figure out which Dx states are supported by this device for the
* S0 (working) state. Note that D0 and D3 are required (assumed).
*/
- device->power.dx_supported[ACPI_STATE_S0] = BM_FLAGS_D0_SUPPORT |
+ device->power.dx_supported[ACPI_STATE_S0] = BM_FLAGS_D0_SUPPORT |
BM_FLAGS_D3_SUPPORT;
- if ((ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PR1",
- &acpi_handle))) ||
- (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PS1",
+ if ((ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PR1",
+ &acpi_handle))) ||
+ (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PS1",
&acpi_handle)))) {
- device->power.dx_supported[ACPI_STATE_S0] |=
+ device->power.dx_supported[ACPI_STATE_S0] |=
BM_FLAGS_D1_SUPPORT;
}
- if ((ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PR2",
- &acpi_handle))) ||
- (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PS2",
+ if ((ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PR2",
+ &acpi_handle))) ||
+ (ACPI_SUCCESS(acpi_get_handle(device->acpi_handle, "_PS2",
&acpi_handle)))) {
- device->power.dx_supported[ACPI_STATE_S0] |=
+ device->power.dx_supported[ACPI_STATE_S0] |=
BM_FLAGS_D2_SUPPORT;
}
/*
* Evalute _SxD:
* -------------
- * Which returns the highest (power) Dx state supported in
- * this system (Sx) state. We convert this value to a bit
+ * Which returns the highest (power) Dx state supported in
+ * this system (Sx) state. We convert this value to a bit
* mask of supported states (conceptually simpler).
*/
- status = bm_evaluate_simple_integer(device->acpi_handle,
+ status = bm_evaluate_simple_integer(device->acpi_handle,
object_name, &dx_supported);
if (ACPI_SUCCESS(status)) {
switch (dx_supported) {
case 0:
- device->power.dx_supported[i] |=
+ device->power.dx_supported[i] |=
BM_FLAGS_D0_SUPPORT;
/* fall through */
case 1:
- device->power.dx_supported[i] |=
+ device->power.dx_supported[i] |=
BM_FLAGS_D1_SUPPORT;
/* fall through */
case 2:
- device->power.dx_supported[i] |=
+ device->power.dx_supported[i] |=
BM_FLAGS_D2_SUPPORT;
/* fall through */
case 3:
- device->power.dx_supported[i] |=
+ device->power.dx_supported[i] |=
BM_FLAGS_D3_SUPPORT;
break;
}
/*
* Validate:
* ---------
- * Mask of any states that _Sx_d falsely advertises
- * (e.g.claims D1 support but neither _PR2 or _PS2
- * exist). In other words, S1-S5 can't offer a Dx
+ * Mask of any states that _Sx_d falsely advertises
+ * (e.g.claims D1 support but neither _PR2 or _PS2
+ * exist). In other words, S1-S5 can't offer a Dx
* state that isn't supported by S0.
*/
- device->power.dx_supported[i] &=
+ device->power.dx_supported[i] &=
device->power.dx_supported[ACPI_STATE_S0];
}
* TODO:
* -----
* 1. Sequencing of power resource list transitions.
- * 2. Global serialization of power resource transtions (see ACPI
+ * 2. Global serialization of power resource transtions (see ACPI
* spec section 7.1.2/7.1.3).
* 3. Better error handling.
*/
BM_NOTIFY notify_type,
BM_HANDLE device_handle,
void **context);
-
+
ACPI_STATUS
bm_pr_request (
BM_REQUEST *request,
void *context);
-
+
/****************************************************************************
* Internal Functions
****************************************************************************/
pr->state = ACPI_STATE_UNKNOWN;
- /*
+ /*
* Evaluate _STA:
* --------------
* Evalute _STA to determine whether the power resource is ON or OFF.
}
/*
- * Mask off all bits but the first as some systems return non-standard
+ * Mask off all bits but the first as some systems return non-standard
* values (e.g. 0x51).
*/
switch (device_status & 0x01) {
* -----------------------------
* The current state of a list of power resources is ON if all
* power resources are currently in the ON state. In other words,
- * if any power resource in the list is OFF then the collection
+ * if any power resource in the list is OFF then the collection
* isn't fully ON.
*/
for (i = 0; i < pr_list->count; i++) {
/*
* Reference Target:
* -----------------
- * Reference all resources for the target power state first (so
- * the device doesn't get turned off while transitioning). Power
+ * Reference all resources for the target power state first (so
+ * the device doesn't get turned off while transitioning). Power
* resources that aren't on (new reference count of 1) are turned on.
*/
for (i = 0; i < target_list->count; i++) {
- status = bm_get_device_context(target_list->handles[i],
+ status = bm_get_device_context(target_list->handles[i],
(BM_DRIVER_CONTEXT*)(&pr));
if (ACPI_FAILURE(status)) {
DEBUG_PRINT(ACPI_WARN, ("Invalid reference to power resource [0x%02X].\n", target_list->handles[i]));
* Dereference Current:
* --------------------
* Dereference all resources for the current power state. Power
- * resources no longer referenced (new reference count of 0) are
+ * resources no longer referenced (new reference count of 0) are
* turned off.
*/
for (i = 0; i < current_list->count; i++) {
- status = bm_get_device_context(current_list->handles[i],
+ status = bm_get_device_context(current_list->handles[i],
(BM_DRIVER_CONTEXT*)(&pr));
if (ACPI_FAILURE(status)) {
DEBUG_PRINT(ACPI_WARN, ("Invalid reference to power resource [0x%02X].\n", target_list->handles[i]));
pr->device_handle = device->handle;
pr->acpi_handle = device->acpi_handle;
- /*
+ /*
* Get information on this power resource.
*/
status = acpi_evaluate_object(pr->acpi_handle, NULL, NULL, &buffer);
DEBUG_PRINT(ACPI_INFO, ("Sending request [0x%02x] to device [0x%02x].\n", request->command, node->device.handle));
- if (!(node->device.flags & BM_FLAGS_DRIVER_CONTROL) ||
+ if (!(node->device.flags & BM_FLAGS_DRIVER_CONTROL) ||
!(node->driver.request)) {
DEBUG_PRINT(ACPI_WARN, ("No driver installed for device [0x%02x].\n", node->device.handle));
return_ACPI_STATUS(AE_NOT_EXIST);
if (ACPI_FAILURE(status)) {
break;
}
- status = bm_copy_to_buffer(&(request->buffer),
+ status = bm_copy_to_buffer(&(request->buffer),
&(device->power.state), sizeof(BM_POWER_STATE));
break;
{
BM_POWER_STATE *power_state = NULL;
- status = bm_cast_buffer(&(request->buffer),
+ status = bm_cast_buffer(&(request->buffer),
(void**)&power_state, sizeof(BM_POWER_STATE));
if (ACPI_FAILURE(status)) {
break;
return AE_BAD_PARAMETER;
}
- /*
+ /*
* Present?
* --------
* We're only going to match on devices that are present.
return AE_NOT_FOUND;
}
- /*
+ /*
* type?
*/
if (criteria->type && !(criteria->type & device->id.type)) {
return AE_NOT_FOUND;
}
- /*
+ /*
* hid?
*/
- if ((criteria->hid[0]) && (0 != STRNCMP(criteria->hid,
+ if ((criteria->hid[0]) && (0 != STRNCMP(criteria->hid,
device->id.hid, sizeof(BM_DEVICE_HID)))) {
return AE_NOT_FOUND;
}
- /*
+ /*
* adr?
*/
if ((criteria->adr) && (criteria->adr != device->id.adr)) {
if (node->scope.head) {
status = bm_compare(&(node->device), criteria);
if (ACPI_SUCCESS(status)) {
- results->handles[results->count++] =
+ results->handles[results->count++] =
node->device.handle;
}
node = node->scope.head;
else {
status = bm_compare(&(node->device), criteria);
if (ACPI_SUCCESS(status)) {
- results->handles[results->count++] =
+ results->handles[results->count++] =
node->device.handle;
}
/*
* Locate Next Device:
* -------------------
- * The next node is either a peer at this level
- * (node->next is valid), or we work are way back
- * up the tree until we either find a non-parsed
+ * The next node is either a peer at this level
+ * (node->next is valid), or we work are way back
+ * up the tree until we either find a non-parsed
* peer or hit the top (node->parent is NULL).
*/
while (!node->next && node->parent) {
if (!package || (package->type != ACPI_TYPE_PACKAGE) ||
(package->package.count == 0) || !package_format ||
- (package_format->length < 1) ||
+ (package_format->length < 1) ||
(!package_format->pointer) || !buffer) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
tail_offset += sizeof(ACPI_INTEGER);
break;
case 'S':
- size_required += sizeof(u8*) +
+ size_required += sizeof(u8*) +
sizeof(ACPI_INTEGER) + 1;
tail_offset += sizeof(ACPI_INTEGER);
break;
case ACPI_TYPE_BUFFER:
switch (format[i]) {
case 'S':
- size_required += sizeof(u8*) +
+ size_required += sizeof(u8*) +
element->string.length + 1;
tail_offset += sizeof(u8*);
break;
case 'B':
- size_required += sizeof(u8*) +
+ size_required += sizeof(u8*) +
element->buffer.length;
tail_offset += sizeof(u8*);
break;
case ACPI_TYPE_INTEGER:
switch (format[i]) {
case 'N':
- *((ACPI_INTEGER*)head) =
+ *((ACPI_INTEGER*)head) =
element->integer.value;
head += sizeof(ACPI_INTEGER);
break;
case 'S':
pointer = (u8**)head;
*pointer = tail;
- *((ACPI_INTEGER*)tail) =
+ *((ACPI_INTEGER*)tail) =
element->integer.value;
head += sizeof(ACPI_INTEGER*);
tail += sizeof(ACPI_INTEGER);
case 'S':
pointer = (u8**)head;
*pointer = tail;
- memcpy(tail, element->string.pointer,
+ memcpy(tail, element->string.pointer,
element->string.length);
head += sizeof(u8*);
tail += element->string.length;
case 'B':
pointer = (u8**)head;
*pointer = tail;
- memcpy(tail, element->buffer.pointer,
+ memcpy(tail, element->buffer.pointer,
element->buffer.length);
head += sizeof(u8*);
tail += element->buffer.length;
* PARAMETERS: <TBD>
*
* RETURN: AE_OK
- * AE_BUFFER_OVERFLOW Evaluated object returned data, but
+ * AE_BUFFER_OVERFLOW Evaluated object returned data, but
* caller did not provide buffer.
*
* DESCRIPTION: Helper for acpi_evaluate_object that handles buffer
- * allocation. Note that the caller is responsible for
+ * allocation. Note that the caller is responsible for
* freeing buffer->pointer!
*
****************************************************************************/
/*
* Evalute Object:
* ---------------
- * The first attempt is just to get the size of the object data
- * (that is unless there's no return data, e.g. _INI); the second
+ * The first attempt is just to get the size of the object data
+ * (that is unless there's no return data, e.g. _INI); the second
* gets the data.
*/
status = acpi_evaluate_object(acpi_handle, pathname, arguments, buffer);
}
/* Re-evaluate -- this time it should work */
- status = acpi_evaluate_object(acpi_handle, pathname,
+ status = acpi_evaluate_object(acpi_handle, pathname,
arguments, buffer);
}
if (ACPI_FAILURE(status)) {
DEBUG_EVAL_ERROR(ACPI_WARN, acpi_handle, pathname, status);
if (buffer && buffer->pointer) {
- acpi_os_free(buffer->pointer);
+ acpi_os_free(buffer->pointer);
buffer->pointer = NULL;
buffer->length = 0;
}
* Validate Data:
* --------------
*/
- status = bm_cast_buffer(&buffer, (void**)&element,
+ status = bm_cast_buffer(&buffer, (void**)&element,
sizeof(ACPI_OBJECT));
if (ACPI_FAILURE(status)) {
DEBUG_EVAL_ERROR(ACPI_WARN, acpi_handle, pathname, status);
* Validate Package:
* -----------------
*/
- status = bm_cast_buffer(&buffer, (void**)&package,
+ status = bm_cast_buffer(&buffer, (void**)&package,
sizeof(ACPI_OBJECT));
if (ACPI_FAILURE(status)) {
DEBUG_EVAL_ERROR(ACPI_WARN, acpi_handle, pathname, status);
* Resolve reference string (e.g. "\_PR_.CPU_") to an
* ACPI_HANDLE.
*/
- status = acpi_get_handle(acpi_handle,
+ status = acpi_get_handle(acpi_handle,
element->string.pointer, &reference_handle);
if (ACPI_FAILURE(status)) {
status = AE_BAD_DATA;
/*
* Resolve ACPI_HANDLE to BM_HANDLE.
*/
- status = bm_get_handle(reference_handle,
+ status = bm_get_handle(reference_handle,
&(reference_list->handles[i]));
if (ACPI_FAILURE(status)) {
status = AE_BAD_DATA;
if (!BM_NODE_PRESENT(node->parent)) {
return_ACPI_STATUS(AE_OK);
}
-
+
/*
* Dynamic Status?
* ---------------
* Evaluate _STA:
* --------------
*/
- status = bm_evaluate_simple_integer(node->device.acpi_handle, "_STA",
+ status = bm_evaluate_simple_integer(node->device.acpi_handle, "_STA",
&(node->device.status));
if (ACPI_SUCCESS(status)) {
*device_status = node->device.status;
/*
* Install driver:
* ----------------
- * For each match, record the driver information and execute the
+ * For each match, record the driver information and execute the
* driver's Notify() funciton (if present) to notify the driver
* of the device's presence.
*/
DEBUG_PRINT(ACPI_INFO, ("Registering driver for device [0x%02x].\n", node->device.handle));
/* Notify driver of new device. */
- status = driver->notify(BM_NOTIFY_DEVICE_ADDED,
+ status = driver->notify(BM_NOTIFY_DEVICE_ADDED,
node->device.handle, &(node->driver.context));
if (ACPI_SUCCESS(status)) {
node->driver.notify = driver->notify;
DEBUG_PRINT(ACPI_INFO, ("Unregistering driver for device [0x%02x].\n", node->device.handle));
/* Notify driver of device removal. */
- status = node->driver.notify(BM_NOTIFY_DEVICE_REMOVED,
+ status = node->driver.notify(BM_NOTIFY_DEVICE_REMOVED,
node->device.handle, &(node->driver.context));
node->device.flags &= ~BM_FLAGS_DRIVER_CONTROL;
RESOURCE* resource;
ULONG i;
KIRQL Dirql;
-
+
/* Count number of resources */
Done = FALSE;
resource = resources;
}
resource = (RESOURCE *) ((NATIVE_UINT) resource + (NATIVE_UINT) resource->length);
}
-
+
/* Allocate memory */
*ResourceListSize = sizeof(CM_RESOURCE_LIST) + sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * (NumberOfResources - 1);
ResourceList = (PCM_RESOURCE_LIST)ExAllocatePool(PagedPool, *ResourceListSize);
ResourceList->List[0].PartialResourceList.Revision = 1;
ResourceList->List[0].PartialResourceList.Count = NumberOfResources;
ResourceDescriptor = ResourceList->List[0].PartialResourceList.PartialDescriptors;
-
+
/* Fill resources list structure */
Done = FALSE;
resource = resources;
for (i = 0; i < irq_data->number_of_interrupts; i++)
{
ResourceDescriptor->Type = CmResourceTypeInterrupt;
-
+
ResourceDescriptor->ShareDisposition =
(irq_data->shared_exclusive == SHARED ? CmResourceShareShared : CmResourceShareDeviceExclusive);
ResourceDescriptor->Flags =
}
resource = (RESOURCE *) ((NATIVE_UINT) resource + (NATIVE_UINT) resource->length);
}
-
+
acpi_rs_dump_resource_list(resource);
return TRUE;
}
#define BM_HID_SLEEP_BUTTON "PNP0C0E"
/*
- * BM_DEVICE_CID:
+ * BM_DEVICE_CID:
* The compatibility ID can be a string with 44 characters
* The extra pad is in case there is a change. It also
* provides 8 byte alignment for the BM_DEVICE_ID structure.
ACPI_STATUS
bm_pr_terminate (void);
-
+
/* bmutils.c */
ACPI_STATUS
* Hardware IDs:
* -------------
* TODO: Power and Sleep button HIDs also exist in <bm.h>. Should all
- * HIDs (ACPI well-known devices) exist in one place (e.g.
+ * HIDs (ACPI well-known devices) exist in one place (e.g.
* acpi_hid.h)?
*/
#define BN_HID_POWER_BUTTON "PNP0C0C"
*virt = MmMapIoSpace(Address, size, MmNonCached);
if (!*virt)
return AE_ERROR;
-
+
return AE_OK;
}
DPRINT("acpi_os_delete_semaphore(handle 0x%X)\n", handle);
- if (!Mutex)
+ if (!Mutex)
return AE_BAD_PARAMETER;
ExFreePool(Mutex);
ACPI_STATUS
acpi_os_signal_semaphore(
- ACPI_HANDLE handle,
+ ACPI_HANDLE handle,
u32 units)
{
PFAST_MUTEX Mutex = (PFAST_MUTEX)handle;
{
PPDO_DEVICE_EXTENSION DeviceExtension;
PCM_RESOURCE_LIST ResourceList;
-
+
DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
+
if (DeviceExtension->ResourceListSize == 0)
{
return Irp->IoStatus.Status;
}
-
+
ResourceList = ExAllocatePool(PagedPool, DeviceExtension->ResourceListSize);
if (!ResourceList)
{
Irp->IoStatus.Information = 0;
return STATUS_INSUFFICIENT_RESOURCES;
}
-
+
RtlCopyMemory(ResourceList, DeviceExtension->ResourceList, DeviceExtension->ResourceListSize);
Irp->IoStatus.Information = (ULONG_PTR)ResourceList;
return STATUS_SUCCESS;
#ifdef ALLOC_PRAGMA
-// Make the initialization routines discardable, so that they
+// Make the initialization routines discardable, so that they
// don't waste space
#pragma alloc_text(init, DriverEntry)
*Size -= size1;
/* Clean whitespace from end of string */
- while ((size1 > 0) && (Buffer[--size1] == ' '))
+ while ((size1 > 0) && (Buffer[--size1] == ' '))
Buffer[size1] = '\0';
DPRINT("ANSI name: %s\n", Buffer);
case ISAPNP_SRIN_CDEVICE_ID:
if ((Size == 4) && (compat < MAX_COMPATIBLE_ID)) {
Peek(tmp, 4);
- LogicalDevice->CVendorId[compat] = UCHAR2USHORT(tmp[0], tmp[1]);
+ LogicalDevice->CVendorId[compat] = UCHAR2USHORT(tmp[0], tmp[1]);
LogicalDevice->CDeviceId[compat] = UCHAR2USHORT(tmp[2], tmp[3]);
compat++;
Size = 0;
size = 0;
}
break;
-
+
case ISAPNP_SRIN_CDEVICE_ID:
/* FIXME: Parse compatible IDs */
break;
DeviceExtension = (PISAPNP_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
if (Irp->IoStatus.Information) {
- /* FIXME: Another bus driver has already created a DEVICE_RELATIONS
+ /* FIXME: Another bus driver has already created a DEVICE_RELATIONS
structure so we must merge this structure with our own */
}
NTSTATUS
STDCALL
DriverEntry(
- IN PDRIVER_OBJECT DriverObject,
+ IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
{
DbgPrint("ISA Plug and Play Bus Driver\n");
DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
if (Irp->IoStatus.Information) {
- /* FIXME: Another bus driver has already created a DEVICE_RELATIONS
+ /* FIXME: Another bus driver has already created a DEVICE_RELATIONS
structure so we must merge this structure with our own */
}
#ifdef ALLOC_PRAGMA
-// Make the initialization routines discardable, so that they
+// Make the initialization routines discardable, so that they
// don't waste space
#pragma alloc_text(init, DriverEntry)
NTSTATUS
STDCALL
PciDispatchDeviceControl(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
{
PIO_STACK_LOCATION IrpSp;
NTSTATUS Status;
#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */
#define PCI_STATUS_PARITY 0x100 /* Detected parity error */
#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */
-#define PCI_STATUS_DEVSEL_FAST 0x000
+#define PCI_STATUS_DEVSEL_FAST 0x000
#define PCI_STATUS_DEVSEL_MEDIUM 0x200
#define PCI_STATUS_DEVSEL_SLOW 0x400
#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */
/*
* Base addresses specify locations in memory or I/O space.
- * Decoded size can be determined by writing a value of
- * 0xffffffff to the register, and reading it back. Only
+ * Decoded size can be determined by writing a value of
+ * 0xffffffff to the register, and reading it back. Only
* 1 bits are decoded.
*/
#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */
/* Header type 0 (normal devices) */
#define PCI_CARDBUS_CIS 0x28
#define PCI_SUBSYSTEM_VENDOR_ID 0x2c
-#define PCI_SUBSYSTEM_ID 0x2e
+#define PCI_SUBSYSTEM_ID 0x2e
#define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */
#define PCI_ROM_ADDRESS_ENABLE 0x01
#define PCI_ROM_ADDRESS_MASK (~0x7ffUL)
if (DeviceCapabilities->Version != 1)
return STATUS_UNSUCCESSFUL;
-
+
DeviceCapabilities->UniqueID = FALSE;
DeviceCapabilities->Address = DeviceExtension->SlotNumber.u.AsULONG;
DeviceCapabilities->UINumber = (ULONG)-1; /* FIXME */
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Serial enumerator driver
* FILE: drivers/bus/serenum/detect.c
* PURPOSE: Detection of serial devices
- *
+ *
* PROGRAMMERS: Jason Filby (jasonfilby@yahoo.com)
* Filip Navara (xnavara@volny.cz)
* Hervé Poussineau (hpoussin@reactos.com)
PIRP Irp;
IO_STATUS_BLOCK IoStatus;
NTSTATUS Status;
-
+
KeInitializeEvent (&Event, NotificationEvent, FALSE);
-
+
Irp = IoBuildDeviceIoControlRequest(CtlCode,
DeviceObject,
InputBuffer,
DPRINT("Serenum: IoBuildDeviceIoControlRequest() failed\n");
return STATUS_INSUFFICIENT_RESOURCES;
}
-
+
Status = IoCallDriver(DeviceObject, Irp);
-
+
if (Status == STATUS_PENDING)
{
DPRINT("Serenum: Operation pending\n");
KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
Status = IoStatus.Status;
}
-
+
if (OutputBufferSize)
{
*OutputBufferSize = IoStatus.Information;
}
-
+
return Status;
}
KEVENT event;
LARGE_INTEGER zero;
NTSTATUS Status;
-
+
KeInitializeEvent(&event, NotificationEvent, FALSE);
zero.QuadPart = 0;
Irp = IoBuildSynchronousFsdRequest(
&ioStatus);
if (!Irp)
return FALSE;
-
+
Status = IoCallDriver(LowerDevice, Irp);
if (Status == STATUS_PENDING)
{
PPDO_DEVICE_EXTENSION PdoDeviceExtension = NULL;
PFDO_DEVICE_EXTENSION FdoDeviceExtension;
NTSTATUS Status;
-
+
DPRINT("Serenum: SerenumReportDetectedDevice() called with %wZ (%wZ) detected\n", DeviceId, DeviceDescription);
-
+
Status = IoCreateDevice(
DeviceObject->DriverObject,
sizeof(PDO_DEVICE_EXTENSION),
FALSE,
&Pdo);
if (!NT_SUCCESS(Status)) goto ByeBye;
-
+
Pdo->Flags |= DO_BUS_ENUMERATED_DEVICE;
Pdo->Flags |= DO_POWER_PAGABLE;
PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)Pdo->DeviceExtension;
if (!NT_SUCCESS(Status)) goto ByeBye;
Status = SerenumDuplicateUnicodeString(&PdoDeviceExtension->CompatibleIds, CompatibleIds, PagedPool);
if (!NT_SUCCESS(Status)) goto ByeBye;
-
+
/* Device attached to serial port (Pdo) may delegate work to
* serial port stack (Fdo = DeviceObject variable) */
Pdo->StackSize = DeviceObject->StackSize + 1;
-
+
FdoDeviceExtension->AttachedPdo = Pdo;
PdoDeviceExtension->AttachedFdo = DeviceObject;
-
+
Pdo->Flags |= DO_BUFFERED_IO;
Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
-
+
return STATUS_SUCCESS;
ByeBye:
{
KTIMER Timer;
LARGE_INTEGER DueTime;
-
+
DueTime.QuadPart = milliseconds * -10;
KeInitializeTimer(&Timer);
KeSetTimer(&Timer, DueTime, NULL);
SERIAL_TIMEOUTS Timeouts;
SERIALPERF_STATS PerfStats;
NTSTATUS Status;
-
+
/* 1. COM port initialization, check for device enumerate */
CHECKPOINT;
Status = SerenumDeviceIoControl(LowerDevice, IOCTL_SERIAL_CLR_DTR,
NULL, 0, &Msr, &Size);
if (!NT_SUCCESS(Status)) return Status;
if ((Msr & SR_MSR_DSR) == 0) goto SerenumDisconnectIdle;
-
+
/* 2. COM port setup, 1st phase */
CHECKPOINT;
BaudRate = SERIAL_BAUD_1200;
NULL, 0, NULL, NULL);
if (!NT_SUCCESS(Status)) return Status;
SerenumWait(200);
-
+
/* 3. Wait for response, 1st phase */
CHECKPOINT;
Status = SerenumDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_RTS,
Status = ReadBytes(LowerDevice, Buffer, sizeof(Buffer), &Size);
if (!NT_SUCCESS(Status)) return Status;
if (Size != 0) goto SerenumCollectPnpComDeviceId;
-
+
/* 4. COM port setup, 2nd phase */
CHECKPOINT;
Status = SerenumDeviceIoControl(LowerDevice, IOCTL_SERIAL_CLR_DTR,
&Purge, 0, NULL, NULL);
if (!NT_SUCCESS(Status)) return Status;
SerenumWait(200);
-
+
/* 5. Wait for response, 2nd phase */
CHECKPOINT;
Status = SerenumDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_DTR,
NULL, 0, &Msr, &Size);
if (!NT_SUCCESS(Status)) return Status;
if ((Msr & SR_MSR_DSR) == 0) goto SerenumVerifyDisconnect; else goto SerenumConnectIdle;
-
+
/* 6. Collect PnP COM device ID */
SerenumCollectPnpComDeviceId:
CHECKPOINT;
NULL, 0, &Msr, &Size);
if (!NT_SUCCESS(Status)) return Status;
if ((Msr & SR_MSR_DSR) == 0) goto SerenumVerifyDisconnect;
-
+
/* 7. Verify disconnect */
SerenumVerifyDisconnect:
CHECKPOINT;
if (!NT_SUCCESS(Status)) return Status;
SerenumWait(5000);
goto SerenumDisconnectIdle;
-
+
/* 8. Connect idle */
SerenumConnectIdle:
CHECKPOINT;
return STATUS_DEVICE_NOT_CONNECTED;
else
return STATUS_SUCCESS;
-
+
/* 9. Disconnect idle */
SerenumDisconnectIdle:
CHECKPOINT;
UNICODE_STRING HardwareIds;
UNICODE_STRING CompatibleIds;
NTSTATUS Status;
-
+
DPRINT("Serenum: SerenumDetectLegacyDevice(DeviceObject %p, LowerDevice %p)\n",
DeviceObject,
LowerDevice);
-
+
RtlZeroMemory(Buffer, sizeof(Buffer));
-
+
/* Reset UART */
CHECKPOINT;
Mcr = 0; /* MCR: DTR/RTS/OUT2 off */
Status = SerenumDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_MODEM_CONTROL,
- &Mcr, sizeof(Mcr), NULL, NULL);
+ &Mcr, sizeof(Mcr), NULL, NULL);
if (!NT_SUCCESS(Status)) return Status;
-
+
/* Set communications parameters */
CHECKPOINT;
/* DLAB off */
Status = SerenumDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_LINE_CONTROL,
&LCR, sizeof(LCR), NULL, NULL);
if (!NT_SUCCESS(Status)) return Status;
-
+
/* Flush receive buffer */
CHECKPOINT;
Command = SERIAL_PURGE_RXCLEAR;
if (!NT_SUCCESS(Status)) return Status;
/* Wait 100 ms */
SerenumWait(100);
-
+
/* Enable DTR/RTS */
CHECKPOINT;
Status = SerenumDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_DTR,
Status = SerenumDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_RTS,
NULL, 0, NULL, NULL);
if (!NT_SUCCESS(Status)) return Status;
-
+
/* Set timeout to 500 microseconds */
CHECKPOINT;
Timeouts.ReadIntervalTimeout = 100;
Status = SerenumDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_TIMEOUTS,
&Timeouts, sizeof(Timeouts), NULL, NULL);
if (!NT_SUCCESS(Status)) return Status;
-
+
/* Fill the read buffer */
CHECKPOINT;
Status = ReadBytes(LowerDevice, Buffer, sizeof(Buffer)/sizeof(Buffer[0]), &Count);
if (!NT_SUCCESS(Status)) return Status;
-
+
for (i = 0; i < Count; i++)
{
if (Buffer[i] == 'B')
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Serial enumerator driver
* FILE: drivers/bus/serenum/fdo.c
* PURPOSE: IRP_MJ_PNP operations for FDOs
- *
+ *
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.com)
*/
PDEVICE_OBJECT Fdo;
PFDO_DEVICE_EXTENSION DeviceExtension;
NTSTATUS Status;
-
+
DPRINT("Serenum: SerenumAddDevice called. Pdo = %p\n", Pdo);
-
+
/* Create new device object */
Status = IoCreateDevice(DriverObject,
sizeof(FDO_DEVICE_EXTENSION),
}
DeviceExtension = (PFDO_DEVICE_EXTENSION)Fdo->DeviceExtension;
RtlZeroMemory(DeviceExtension, sizeof(FDO_DEVICE_EXTENSION));
-
+
/* Register device interface */
Status = IoRegisterDeviceInterface(
Pdo,
IoDeleteDevice(Fdo);
return Status;
}
-
+
DeviceExtension->Common.IsFDO = TRUE;
DeviceExtension->Common.PnpState = dsStopped;
DeviceExtension->Pdo = Pdo;
}
Fdo->Flags |= DO_BUFFERED_IO;
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
-
+
return STATUS_SUCCESS;
}
{
PFDO_DEVICE_EXTENSION DeviceExtension;
NTSTATUS Status;
-
+
DPRINT("Serenum: SerenumFdoStartDevice() called\n");
DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
+
ASSERT(DeviceExtension->Common.PnpState == dsStopped);
-
+
Status = IoSetDeviceInterfaceState(&DeviceExtension->SerenumInterfaceName, TRUE);
if (!NT_SUCCESS(Status))
{
DPRINT("Serenum: IoSetDeviceInterfaceState() failed with status 0x%08lx\n", Status);
return Status;
}
-
+
DeviceExtension->Common.PnpState = dsStarted;
-
+
return STATUS_SUCCESS;
}
ULONG NumPDO;
ULONG i;
NTSTATUS Status = STATUS_SUCCESS;
-
+
DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
ASSERT(DeviceExtension->Common.IsFDO);
-
+
/* Do enumeration if needed */
if (!(DeviceExtension->Flags & FLAG_ENUMERATION_DONE))
{
DeviceExtension->Flags |= FLAG_ENUMERATION_DONE;
}
NumPDO = (DeviceExtension->AttachedPdo != NULL ? 1 : 0);
-
+
DeviceRelations = (PDEVICE_RELATIONS)ExAllocatePoolWithTag(
PagedPool,
sizeof(DEVICE_RELATIONS) + sizeof(PDEVICE_OBJECT) * (NumPDO - 1),
SERENUM_TAG);
if (!DeviceRelations)
return STATUS_INSUFFICIENT_RESOURCES;
-
+
/* Fill returned structure */
DeviceRelations->Count = NumPDO;
for (i = 0; i < NumPDO; i++)
ObReferenceObject(DeviceExtension->AttachedPdo);
DeviceRelations->Objects[i] = DeviceExtension->AttachedPdo;
}
-
+
*pDeviceRelations = DeviceRelations;
return Status;
}
PIO_STACK_LOCATION Stack;
ULONG_PTR Information = 0;
NTSTATUS Status;
-
+
Stack = IoGetCurrentIrpStackLocation(Irp);
MinorFunction = Stack->MinorFunction;
-
+
switch (MinorFunction)
{
/* FIXME: do all these minor functions
break;
}
default:
- DPRINT1("Serenum: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
+ DPRINT1("Serenum: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
Stack->Parameters.QueryDeviceRelations.Type);
return ForwardIrpAndForget(DeviceObject, Irp);
}
return ForwardIrpAndForget(DeviceObject, Irp);
}
}
-
+
Irp->IoStatus.Information = Information;
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Serial enumerator driver
* FILE: drivers/dd/serenum/misc.c
* PURPOSE: Misceallenous operations
- *
+ *
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.com)
*/
IN POOL_TYPE PoolType)
{
ASSERT(Destination);
-
+
if (Source == NULL)
{
RtlInitUnicodeString(Destination, NULL);
return STATUS_SUCCESS;
}
-
+
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);
-
+
return STATUS_SUCCESS;
}
UNICODE_STRING UnicodeString;
ULONG DestinationSize = 0;
NTSTATUS Status = STATUS_SUCCESS;
-
+
ASSERT(Destination);
-
+
/* Calculate length needed for destination unicode string */
va_start(args, Destination);
Source = va_arg(args, PCSZ);
RtlInitUnicodeString(Destination, NULL);
return STATUS_SUCCESS;
}
-
+
/* Initialize destination string */
DestinationSize += sizeof(WCHAR); // final NULL
Destination->Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool, DestinationSize, SERENUM_TAG);
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 */
PDEVICE_OBJECT LowerDevice;
KEVENT Event;
NTSTATUS Status;
-
+
ASSERT(((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO);
LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
-
+
ASSERT(LowerDevice);
-
+
KeInitializeEvent(&Event, NotificationEvent, FALSE);
IoCopyCurrentIrpStackLocationToNext(Irp);
-
+
DPRINT("Serenum: Calling lower device %p [%wZ]\n", LowerDevice, &LowerDevice->DriverObject->DriverName);
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
-
+
Status = IoCallDriver(LowerDevice, Irp);
if (Status == STATUS_PENDING)
{
if (NT_SUCCESS(Status))
Status = Irp->IoStatus.Status;
}
-
+
return Status;
}
{
PFDO_DEVICE_EXTENSION DeviceExtension;
PDEVICE_OBJECT LowerDevice;
-
+
DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
ASSERT(DeviceExtension->Common.IsFDO);
-
+
LowerDevice = DeviceExtension->LowerDevice;
ASSERT(LowerDevice);
DPRINT("Serenum: calling lower device 0x%p [%wZ]\n",
{
PPDO_DEVICE_EXTENSION DeviceExtension;
PDEVICE_OBJECT Fdo;
-
+
DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
ASSERT(!DeviceExtension->Common.IsFDO);
-
+
Fdo = DeviceExtension->AttachedFdo;
ASSERT(Fdo);
DPRINT("Serenum: calling attached Fdo 0x%p [%wZ]\n",
IN PIRP Irp)
{
PDEVICE_OBJECT LowerDevice;
-
+
ASSERT(((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO);
LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
ASSERT(LowerDevice);
-
+
IoSkipCurrentIrpStackLocation(Irp);
return IoCallDriver(LowerDevice, Irp);
}
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Serial enumerator driver
* FILE: drivers/bus/serenum/pdo.c
* PURPOSE: IRP_MJ_PNP operations for PDOs
- *
+ *
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.com)
*/
IN PDEVICE_OBJECT DeviceObject)
{
PPDO_DEVICE_EXTENSION DeviceExtension;
-
+
DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
+
ASSERT(DeviceExtension->Common.PnpState == dsStopped);
-
+
DeviceExtension->Common.PnpState = dsStarted;
return STATUS_SUCCESS;
}
PUNICODE_STRING SourceString;
UNICODE_STRING String;
NTSTATUS Status;
-
+
IdType = IoGetCurrentIrpStackLocation(Irp)->Parameters.QueryId.IdType;
DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
RtlInitUnicodeString(&String, NULL);
-
+
switch (IdType)
{
case BusQueryDeviceID:
DPRINT1("Serenum: IRP_MJ_PNP / IRP_MN_QUERY_ID / unknown query id type 0x%lx\n", IdType);
return STATUS_NOT_SUPPORTED;
}
-
+
Status = SerenumDuplicateUnicodeString(
&String,
SourceString,
{
PFDO_DEVICE_EXTENSION DeviceExtension;
PDEVICE_RELATIONS DeviceRelations;
-
+
DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
ASSERT(DeviceExtension->Common.IsFDO);
-
+
DeviceRelations = (PDEVICE_RELATIONS)ExAllocatePoolWithTag(
PagedPool,
sizeof(DEVICE_RELATIONS),
SERENUM_TAG);
if (!DeviceRelations)
return STATUS_INSUFFICIENT_RESOURCES;
-
+
ObReferenceObject(DeviceObject);
DeviceRelations->Count = 1;
DeviceRelations->Objects[0] = DeviceObject;
-
+
*pDeviceRelations = DeviceRelations;
return STATUS_SUCCESS;
}
PIO_STACK_LOCATION Stack;
ULONG_PTR Information = 0;
NTSTATUS Status;
-
+
Stack = IoGetCurrentIrpStackLocation(Irp);
MinorFunction = Stack->MinorFunction;
-
+
switch (MinorFunction)
{
/* FIXME: do all these minor functions
}
default:
{
- DPRINT1("Serenum: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
+ DPRINT1("Serenum: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
Stack->Parameters.QueryDeviceRelations.Type);
Status = STATUS_NOT_IMPLEMENTED;
break;
PDEVICE_CAPABILITIES DeviceCapabilities;
ULONG i;
DPRINT("Serenum: IRP_MJ_PNP / IRP_MN_QUERY_CAPABILITIES\n");
-
+
DeviceCapabilities = (PDEVICE_CAPABILITIES)Stack->Parameters.DeviceCapabilities.Capabilities;
/* FIXME: capabilities can change with connected device */
DeviceCapabilities->LockSupported = FALSE;
PUNICODE_STRING Source;
PWSTR Description;
DPRINT("Serenum: IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription\n");
-
+
Source = &((PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->DeviceDescription;
Description = ExAllocatePool(PagedPool, Source->Length + sizeof(WCHAR));
if (!Description)
{
PPNP_BUS_INFORMATION BusInfo;
DPRINT("Serenum: IRP_MJ_PNP / IRP_MN_QUERY_BUS_INFORMATION\n");
-
+
BusInfo = (PPNP_BUS_INFORMATION)ExAllocatePool(PagedPool, sizeof(PNP_BUS_INFORMATION));
if (!BusInfo)
Status = STATUS_INSUFFICIENT_RESOURCES;
Status = Irp->IoStatus.Status;
}
}
-
+
Irp->IoStatus.Information = Information;
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Serial enumerator driver
* FILE: drivers/bus/serenum/serenum.c
* PURPOSE: Serial enumeration driver entry point
- *
+ *
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.com)
*/
IN PIRP Irp)
{
NTSTATUS Status = STATUS_NOT_SUPPORTED;
-
+
if (((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO)
{
/* Forward some IRPs to lower device */
}
}
}
-
+
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
IN PUNICODE_STRING RegPath)
{
ULONG i;
-
+
DriverObject->DriverUnload = DriverUnload;
DriverObject->DriverExtension->AddDevice = SerenumAddDevice;
-
+
for (i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++)
DriverObject->MajorFunction[i] = IrpStub;
-
+
//DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = SerialQueryInformation;
DriverObject->MajorFunction[IRP_MJ_PNP] = SerenumPnp;
//DriverObject->MajorFunction[IRP_MJ_POWER] = SerialPower;
-
+
return STATUS_SUCCESS;
}
#include <ddk/ntddser.h>
#include <ddk/wdmguid.h>
#include <stdio.h>
-
+
#include <debug.h>
#define SR_MSR_DSR 0x20
#define ExFreePoolWithTag(p, tag) ExFreePool(p)
-
+
/* FIXME: these prototypes MUST NOT be here! */
NTSTATUS STDCALL
IoAttachDeviceToDeviceStackSafe(
IN PDEVICE_OBJECT SourceDevice,
IN PDEVICE_OBJECT TargetDevice,
OUT PDEVICE_OBJECT *AttachedToDeviceObject);
-
+
#elif defined(_MSC_VER)
#include <ntddk.h>
#include <ntddser.h>
#include <c:/progra~1/winddk/inc/ddk/wdm/wxp/wdmguid.h>
#include <stdio.h>
-
+
#define STDCALL
-
+
#define DPRINT1 DbgPrint("(%s:%d) ", __FILE__, __LINE__), DbgPrint
#define CHECKPOINT1 DbgPrint("(%s:%d)\n")
-
+
#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
-
+
NTSTATUS STDCALL
IoAttachDeviceToDeviceStackSafe(
IN PDEVICE_OBJECT SourceDevice,
IN PDEVICE_OBJECT TargetDevice,
OUT PDEVICE_OBJECT *AttachedToDeviceObject);
-
+
#define DPRINT DPRINT1
#define CHECKPOINT CHECKPOINT1
-
+
#define SR_MSR_DSR 0x20
#else
#error Unknown compiler!
typedef struct _FDO_DEVICE_EXTENSION
{
COMMON_DEVICE_EXTENSION Common;
-
+
PDEVICE_OBJECT LowerDevice;
PDEVICE_OBJECT Pdo;
IO_REMOVE_LOCK RemoveLock;
-
+
UNICODE_STRING SerenumInterfaceName;
-
+
PDEVICE_OBJECT AttachedPdo;
ULONG Flags;
} FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;
typedef struct _PDO_DEVICE_EXTENSION
{
COMMON_DEVICE_EXTENSION Common;
-
+
PDEVICE_OBJECT AttachedFdo;
-
+
UNICODE_STRING DeviceDescription; // REG_SZ
UNICODE_STRING DeviceId; // REG_SZ
UNICODE_STRING HardwareIds; // REG_MULTI_SZ
vidmem[(cursorx * 2) + (cursory * columns * 2)] = ' ';
vidmem[(cursorx * 2) + (cursory * columns * 2) + 1] = (char) DeviceExtension->CharAttribute;
break;
-
+
case '\n':
cursory++;
cursorx = 0;
break;
-
+
case '\r':
cursorx = 0;
break;
-
+
case '\t':
offset = TAB_WIDTH - (cursorx % TAB_WIDTH);
for (j = 0; j < offset; j++)
{
vidmem[(cursorx * 2) + (cursory * columns * 2)] = ' ';
cursorx++;
-
+
if (cursorx >= columns)
{
cursory++;
}
}
break;
-
+
default:
vidmem[(cursorx * 2) + (cursory * columns * 2)] = *pch;
vidmem[(cursorx * 2) + (cursory * columns * 2) + 1] = (char) DeviceExtension->CharAttribute;
}
}
}
-
+
/* Set the cursor position */
offset = (cursory * columns) + cursorx;
}
}
Buf->dwTransfered = Buf->nLength;
-
+
Irp->IoStatus.Information = 0;
Status = STATUS_SUCCESS;
}
BOOL STDCALL
VidResetDisplay(VOID)
{
- /*
+ /*
* We are only using standard VGA facilities so we can rely on the
* HAL 'int10mode3' reset to cleanup the hardware state.
*/
while ((j < bminfo->bV5SizeImage) && (k < (ULONG) (bminfo->bV5Width * bminfo->bV5Height)))
{
unsigned char b;
-
+
clen = BootimageBitmap[bfOffBits + j];
j++;
-
+
if (clen > 0)
{
/* Encoded mode */
-
+
b = BootimageBitmap[bfOffBits + j];
j++;
-
+
for (i = 0; i < (clen / 2); i++)
{
ImageData[k] = (b & 0xf0) >> 4;
/* Absolute mode */
b = BootimageBitmap[bfOffBits + j];
j++;
-
+
if (b == 0)
{
/* End of line */
{
DPRINT("Unaligned copy!\n");
}
-
+
clen = b;
for (i = 0; i < (clen / 2); i++)
{
b = BootimageBitmap[bfOffBits + j];
j++;
-
+
ImageData[k] = (b & 0xf0) >> 4;
k++;
ImageData[k] = b & 0xf;
InbvMapVideoMemory();
InbvInitVGAMode();
-
+
Status = PsCreateSystemThread(
&BitmapThreadHandle,
THREAD_ALL_ACCESS,
&BitmapThreadId,
InbvBitmapThreadMain,
NULL);
-
+
if (!NT_SUCCESS(Status))
{
return FALSE;
PIO_STACK_LOCATION IrpSp;
NTSTATUS Status;
NTBOOTVID_FUNCTION_TABLE* FunctionTable;
-
+
IrpSp = IoGetCurrentIrpStackLocation(Irp);
Status = STATUS_SUCCESS;
break;
case IOCTL_BOOTVID_CLEANUP:
- VidCleanUp();
+ VidCleanUp();
break;
default:
typedef struct tagCIEXYZ
{
- FXPT2DOT30 ciexyzX;
- FXPT2DOT30 ciexyzY;
- FXPT2DOT30 ciexyzZ;
+ FXPT2DOT30 ciexyzX;
+ FXPT2DOT30 ciexyzY;
+ FXPT2DOT30 ciexyzZ;
} CIEXYZ, *LPCIEXYZ;
typedef struct tagCIEXYZTRIPLE
{
- CIEXYZ ciexyzRed;
- CIEXYZ ciexyzGreen;
- CIEXYZ ciexyzBlue;
+ CIEXYZ ciexyzRed;
+ CIEXYZ ciexyzGreen;
+ CIEXYZ ciexyzBlue;
} CIEXYZTRIPLE, *LPCIEXYZTRIPLE;
-typedef struct {
- DWORD bV5Size;
- LONG bV5Width;
- LONG bV5Height;
- WORD bV5Planes;
- WORD bV5BitCount;
- DWORD bV5Compression;
- DWORD bV5SizeImage;
- LONG bV5XPelsPerMeter;
- LONG bV5YPelsPerMeter;
- DWORD bV5ClrUsed;
- DWORD bV5ClrImportant;
- DWORD bV5RedMask;
- DWORD bV5GreenMask;
- DWORD bV5BlueMask;
- DWORD bV5AlphaMask;
- DWORD bV5CSType;
- CIEXYZTRIPLE bV5Endpoints;
- DWORD bV5GammaRed;
- DWORD bV5GammaGreen;
- DWORD bV5GammaBlue;
- DWORD bV5Intent;
- DWORD bV5ProfileData;
- DWORD bV5ProfileSize;
- DWORD bV5Reserved;
-} BITMAPV5HEADER, *PBITMAPV5HEADER;
+typedef struct {
+ DWORD bV5Size;
+ LONG bV5Width;
+ LONG bV5Height;
+ WORD bV5Planes;
+ WORD bV5BitCount;
+ DWORD bV5Compression;
+ DWORD bV5SizeImage;
+ LONG bV5XPelsPerMeter;
+ LONG bV5YPelsPerMeter;
+ DWORD bV5ClrUsed;
+ DWORD bV5ClrImportant;
+ DWORD bV5RedMask;
+ DWORD bV5GreenMask;
+ DWORD bV5BlueMask;
+ DWORD bV5AlphaMask;
+ DWORD bV5CSType;
+ CIEXYZTRIPLE bV5Endpoints;
+ DWORD bV5GammaRed;
+ DWORD bV5GammaGreen;
+ DWORD bV5GammaBlue;
+ DWORD bV5Intent;
+ DWORD bV5ProfileData;
+ DWORD bV5ProfileSize;
+ DWORD bV5Reserved;
+} BITMAPV5HEADER, *PBITMAPV5HEADER;
/*
* Private driver structures
* NOTES:
* In your usermode application, do something like this:
*
- * DebugHandle = CreateFile("\\\\.\\DebugOut",
- * GENERIC_WRITE,
- * 0,
+ * DebugHandle = CreateFile("\\\\.\\DebugOut",
+ * GENERIC_WRITE,
+ * 0,
* NULL,
- * OPEN_EXISTING,
- * FILE_ATTRIBUTE_NORMAL,
+ * OPEN_EXISTING,
+ * FILE_ATTRIBUTE_NORMAL,
* NULL);
*
* and write to your hearts content to DebugHandle.
char Buf[513];
unsigned Remaining;
unsigned Length;
-
+
nErrCode = STATUS_SUCCESS;
switch(piosStack->MajorFunction)
{
}
-NTSTATUS STDCALL
+NTSTATUS STDCALL
DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
PDEVICE_OBJECT DebugOutDevice;
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS VT100 emulator
* FILE: drivers/dd/green/createclose.c
* PURPOSE: IRP_MJ_CREATE, IRP_MJ_CLOSE and IRP_MJ_CLEANUP operations
- *
+ *
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.com)
*/
IN PIRP Irp)
{
DPRINT("Green: IRP_MJ_CREATE\n");
-
+
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
IN PIRP Irp)
{
DPRINT("Green: IRP_MJ_CLOSE\n");
-
+
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS VT100 emulator
* FILE: drivers/dd/green/dispatch.c
* PURPOSE: Dispatch routines
- *
+ *
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.com)
*/
GREEN_DEVICE_TYPE DeviceType;
ULONG_PTR Information;
NTSTATUS Status;
-
+
MajorFunction = IoGetCurrentIrpStackLocation(Irp)->MajorFunction;
DeviceType = ((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Type;
-
+
Information = Irp->IoStatus.Information;
Status = Irp->IoStatus.Status;
-
+
DPRINT("Green: Dispatching major function 0x%lx, DeviceType %d\n",
MajorFunction, DeviceType);
-
+
if (MajorFunction == IRP_MJ_CREATE && DeviceType == Green)
return GreenCreate(DeviceObject, Irp);
else if (MajorFunction == IRP_MJ_CLOSE && DeviceType == Green)
DPRINT1("Green: unknown combination: MajorFunction 0x%lx, DeviceType %d\n",
MajorFunction, DeviceType);
}
-
+
Irp->IoStatus.Information = Information;
Irp->IoStatus.Status = Status;
IoCompleteRequest (Irp, IO_NO_INCREMENT);
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS VT100 emulator
* FILE: drivers/dd/green/green.c
* PURPOSE: Driver entry point
- *
+ *
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.com)
*/
IN PUNICODE_STRING RegPath)
{
ULONG i;
-
+
DriverObject->DriverUnload = DriverUnload;
DriverObject->DriverExtension->AddDevice = GreenAddDevice;
-
+
for (i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++)
DriverObject->MajorFunction[i] = GreenDispatch;
-
+
/* keyboard only */
//DriverObject->DriverStartIo = GreenStartIo;
-
+
/* keyboard and screen */
DriverObject->MajorFunction[IRP_MJ_CREATE] = GreenCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = GreenClose;
-
+
return STATUS_SUCCESS;
}
#include <ntos/halfuncs.h>
#include <ddk/ntddblue.h>
#include <ddk/ntddkbd.h> /* should be in kbdmou.h */
-
+
#include <debug.h>
-
+
/* FIXME: should be in kbdmou.h */
typedef struct _CONNECT_DATA {
PDEVICE_OBJECT ClassDeviceObject;
PVOID ClassService;
} CONNECT_DATA, *PCONNECT_DATA;
-
+
/* FIXME: should be in kbdmou.h */
#define IOCTL_INTERNAL_KEYBOARD_CONNECT \
CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0080, METHOD_NEITHER, FILE_ANY_ACCESS)
-
+
NTSTATUS STDCALL
ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
ULONG Attributes,
KPROCESSOR_MODE AccessMode,
PVOID ParseContext,
PVOID* ObjectPtr);
-
+
/* FIXME: should be in kbdmou.h */
typedef VOID (*PSERVICE_CALLBACK_ROUTINE)(PDEVICE_OBJECT, PKEYBOARD_INPUT_DATA, PKEYBOARD_INPUT_DATA, PULONG);
-
+
typedef struct _CLASS_INFORMATION
{
PDEVICE_OBJECT DeviceObject;
PVOID CallBack;
} CLASS_INFORMATION, *PCLASS_INFORMATION;
-
+
#define KEYBOARD_BUFFER_SIZE 100
-
+
#elif defined(_MSC_VER)
#include <ntddk.h>
#include <ntddser.h>
#include <kbdmou.h>
#define STDCALL
-
+
#define DPRINT1 DbgPrint("(%s:%d) ", __FILE__, __LINE__), DbgPrint
#define CHECKPOINT1 DbgPrint("(%s:%d)\n", __FILE__, __LINE__)
#define DPRINT DPRINT1
{
COMMON_DEVICE_EXTENSION Common;
PDEVICE_OBJECT Green;
-
+
CLASS_INFORMATION ClassInformation;
HANDLE WorkerThreadHandle;
KDPC KeyboardDpc;
-
+
ULONG ActiveQueue;
ULONG InputDataCount[2];
KEYBOARD_INPUT_DATA KeyboardInputData[2][KEYBOARD_BUFFER_SIZE];
{
COMMON_DEVICE_EXTENSION Common;
PDEVICE_OBJECT Green;
-
+
PUCHAR VideoMemory; /* Pointer to video memory */
USHORT CharAttribute; /* Current color attribute */
ULONG Mode;
UCHAR Rows; /* Number of rows */
UCHAR Columns; /* Number of columns */
UCHAR TabWidth;
-
+
ULONG LogicalOffset; /* Position of the cursor */
-
+
UCHAR SendBuffer[1024];
ULONG SendBufferPosition;
} SCREEN_DEVICE_EXTENSION, *PSCREEN_DEVICE_EXTENSION;
{
COMMON_DEVICE_EXTENSION Common;
PDEVICE_OBJECT Serial;
-
+
PDEVICE_OBJECT LowerDevice;
ULONG BaudRate;
SERIAL_LINE_CONTROL LineControl;
SERIAL_TIMEOUTS Timeouts;
-
+
PDEVICE_OBJECT Keyboard;
PDEVICE_OBJECT Screen;
} GREEN_DEVICE_EXTENSION, *PGREEN_DEVICE_EXTENSION;
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS VT100 emulator
* FILE: drivers/dd/green/keyboard.c
* PURPOSE: Keyboard part of green management
- *
+ *
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.com)
*/
{
BOOLEAN NormalKey = FALSE;
USHORT MakeCode;
-
+
if (InputBufferSize == 0)
return FALSE;
-
+
switch (*InputBuffer)
{
case 0x1b: MakeCode = 0x01; NormalKey = TRUE; break; /* ESC */
-
+
case '1': MakeCode = 0x02; NormalKey = TRUE; break;
case '2': MakeCode = 0x03; NormalKey = TRUE; break;
case '3': MakeCode = 0x04; NormalKey = TRUE; break;
case '-': MakeCode = 0x0c; NormalKey = TRUE; break;
case '=': MakeCode = 0x0d; NormalKey = TRUE; break;
case '\b': MakeCode = 0x0e; NormalKey = TRUE; break;
-
+
case '\t': MakeCode = 0x0f; NormalKey = TRUE; break;
case 'q': MakeCode = 0x10; NormalKey = TRUE; break;
case 'w': MakeCode = 0x11; NormalKey = TRUE; break;
case 'p': MakeCode = 0x19; NormalKey = TRUE; break;
case '[': MakeCode = 0x1a; NormalKey = TRUE; break;
case ']': MakeCode = 0x1b; NormalKey = TRUE; break;
-
+
case '\r': MakeCode = 0x1c; NormalKey = TRUE; break;
-
+
case 'a': MakeCode = 0x1e; NormalKey = TRUE; break;
case 's': MakeCode = 0x1f; NormalKey = TRUE; break;
case 'd': MakeCode = 0x20; NormalKey = TRUE; break;
case 'l': MakeCode = 0x26; NormalKey = TRUE; break;
case ';': MakeCode = 0x27; NormalKey = TRUE; break;
case '\'': MakeCode = 0x28; NormalKey = TRUE; break;
-
+
case '`': MakeCode = 0x29; NormalKey = TRUE; break;
-
+
case '\\': MakeCode = 0x2b; NormalKey = TRUE; break;
-
+
case 'z': MakeCode = 0x2c; NormalKey = TRUE; break;
case 'x': MakeCode = 0x2d; NormalKey = TRUE; break;
case 'c': MakeCode = 0x2e; NormalKey = TRUE; break;
case ',': MakeCode = 0x33; NormalKey = TRUE; break;
case '.': MakeCode = 0x34; NormalKey = TRUE; break;
case '/': MakeCode = 0x35; NormalKey = TRUE; break;
-
+
case ' ': MakeCode = 0x39; NormalKey = TRUE; break;
}
if (NormalKey && *OutputBufferSize >= 2)
*BytesConsumed = 2;
return TRUE;
}
-
+
/* Consume strange character by ignoring it */
DPRINT1("Green: strange byte received 0x%02x ('%c')\n",
*InputBuffer, *InputBuffer >= 32 ? *InputBuffer : '.');
PKEYBOARD_DEVICE_EXTENSION DeviceExtension;
UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\KeyboardClass1");
NTSTATUS Status;
-
+
DPRINT("Green: KeyboardInitialize() called\n");
-
+
Status = IoCreateDevice(DriverObject,
sizeof(KEYBOARD_DEVICE_EXTENSION),
&DeviceName, /* FIXME: don't hardcode string */
&Fdo);
if (!NT_SUCCESS(Status))
return Status;
-
+
DeviceExtension = (PKEYBOARD_DEVICE_EXTENSION)Fdo->DeviceExtension;
RtlZeroMemory(DeviceExtension, sizeof(KEYBOARD_DEVICE_EXTENSION));
DeviceExtension->Common.Type = Keyboard;
Fdo->Flags |= DO_POWER_PAGABLE | DO_BUFFERED_IO;
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
-
+
*KeyboardFdo = Fdo;
-
+
return STATUS_SUCCESS;
}
PKEYBOARD_DEVICE_EXTENSION DeviceExtension;
ULONG Queue;
ULONG InputDataConsumed;
-
+
DeviceExtension = (PKEYBOARD_DEVICE_EXTENSION)pDeviceExtension;
-
+
Queue = DeviceExtension->ActiveQueue % 2;
InterlockedIncrement((PLONG)&DeviceExtension->ActiveQueue);
(*(PSERVICE_CALLBACK_ROUTINE)DeviceExtension->ClassInformation.CallBack)(
DeviceExtension->KeyboardInputData[Queue],
&DeviceExtension->KeyboardInputData[Queue][DeviceExtension->InputDataCount[Queue]],
&InputDataConsumed);
-
+
DeviceExtension->InputDataCount[Queue] = 0;
}
static VOID STDCALL
ULONG BytesConsumed;
PKEYBOARD_INPUT_DATA Input;
NTSTATUS Status;
-
+
DPRINT("Green: KeyboardDeviceWorker() called\n");
-
+
DeviceObject = (PDEVICE_OBJECT)Context;
DeviceExtension = (PKEYBOARD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
GreenDeviceExtension = (PGREEN_DEVICE_EXTENSION)DeviceExtension->Green->DeviceExtension;
LowerDevice = GreenDeviceExtension->Serial;
BufferSize = sizeof(Buffer);
-
+
/* Initialize device extension */
DeviceExtension->ActiveQueue = 0;
DeviceExtension->InputDataCount[0] = 0;
DeviceExtension->InputDataCount[1] = 0;
KeInitializeDpc(&DeviceExtension->KeyboardDpc, KeyboardDpcSendData, DeviceExtension);
RtlZeroMemory(&DeviceExtension->KeyboardInputData, sizeof(DeviceExtension->KeyboardInputData));
-
+
/* main read loop */
while (TRUE)
{
KeStallExecutionProcessor(10);
continue;
}
-
+
Status = IoCallDriver(LowerDevice, Irp);
if (Status == STATUS_PENDING)
{
}
if (!NT_SUCCESS(Status))
continue;
-
+
/* Read all available data and process */
i = 0;
while (i < ioStatus.Information)
{
Queue = DeviceExtension->ActiveQueue % 2;
-
+
Input = &DeviceExtension->KeyboardInputData[Queue][DeviceExtension->InputDataCount[Queue]];
-
+
/* Translate current chars to scan codes */
SpaceInQueue = KEYBOARD_BUFFER_SIZE - DeviceExtension->InputDataCount[Queue];
if (TranslateCharToScanCodes(
{
DPRINT1("Green: got char 0x%02x (%c)\n", Buffer[i], Buffer[i] >= 32 ? Buffer[i] : ' ');
DeviceExtension->InputDataCount[Queue] += BytesConsumed;
-
+
/* Send the data to the keyboard class driver */
KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
KeInsertQueueDpc(&DeviceExtension->KeyboardDpc, NULL, NULL);
}
}
}
-
+
PsTerminateSystemThread(STATUS_SUCCESS);
}
OBJECT_ATTRIBUTES objectAttributes;
PDEVICE_OBJECT LowerDevice;
NTSTATUS Status;
-
+
Stack = IoGetCurrentIrpStackLocation(Irp);
Irp->IoStatus.Information = 0;
DeviceExtension = (PKEYBOARD_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
GreenDeviceExtension = (PGREEN_DEVICE_EXTENSION)DeviceExtension->Green->DeviceExtension;
LowerDevice = GreenDeviceExtension->Serial;
DPRINT1("Green: LowerDevice %p\n", LowerDevice);
-
+
switch (Stack->Parameters.DeviceIoControl.IoControlCode)
{
case IOCTL_INTERNAL_KEYBOARD_CONNECT:
{
ULONG Fcr;
-
+
DPRINT("Green: IRP_MJ_INTERNAL_DEVICE_CONTROL / IOCTL_INTERNAL_KEYBOARD_CONNECT\n");
if (Stack->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONNECT_DATA))
{
Status = STATUS_INVALID_PARAMETER;
break;
}
-
+
DeviceExtension->ClassInformation =
*((PCLASS_INFORMATION)Stack->Parameters.DeviceIoControl.Type3InputBuffer);
-
+
/* Initialize serial port */
Fcr = 0;
Status = GreenDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_FIFO_CONTROL,
Status = GreenDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_LINE_CONTROL,
&GreenDeviceExtension->LineControl, sizeof(GreenDeviceExtension->LineControl), NULL, NULL);
if (!NT_SUCCESS(Status)) break;
-
+
/* Set timeouts */
Status = GreenDeviceIoControl(LowerDevice, IOCTL_SERIAL_SET_TIMEOUTS,
&GreenDeviceExtension->Timeouts, sizeof(GreenDeviceExtension->Timeouts), NULL, NULL);
if (!NT_SUCCESS(Status)) break;
-
+
/* Start read loop */
InitializeObjectAttributes(&objectAttributes, NULL, OBJ_KERNEL_HANDLE, NULL, NULL);
Status = PsCreateSystemThread(
Status = STATUS_INVALID_DEVICE_REQUEST;
}
}
-
+
Irp->IoStatus.Status = Status;
IoCompleteRequest (Irp, IO_NO_INCREMENT);
return Status;
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS VT100 emulator
* FILE: drivers/dd/green/misc.c
* PURPOSE: Misceallenous operations
- *
+ *
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.com)
*/
PIRP Irp;
IO_STATUS_BLOCK IoStatus;
NTSTATUS Status;
-
+
KeInitializeEvent (&Event, NotificationEvent, FALSE);
-
+
Irp = IoBuildDeviceIoControlRequest(CtlCode,
DeviceObject,
InputBuffer,
DPRINT("Green: IoBuildDeviceIoControlRequest() failed\n");
return STATUS_INSUFFICIENT_RESOURCES;
}
-
+
Status = IoCallDriver(DeviceObject, Irp);
-
+
if (Status == STATUS_PENDING)
{
DPRINT("Green: Operation pending\n");
KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
Status = IoStatus.Status;
}
-
+
if (OutputBufferSize)
{
*OutputBufferSize = IoStatus.Information;
}
-
+
return Status;
}
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS VT100 emulator
* FILE: drivers/dd/green/pnp.c
* PURPOSE: IRP_MJ_PNP operations
- *
+ *
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.com)
*/
PGREEN_DEVICE_EXTENSION DeviceExtension;
UNICODE_STRING serialPortName;
NTSTATUS Status;
-
+
DPRINT("Green: AddDevice(DriverObject %p, Pdo %p)\n", DriverObject, Pdo);
-
+
/* Create green FDO */
Status = IoCreateDevice(DriverObject,
sizeof(GREEN_DEVICE_EXTENSION),
&Fdo);
if (!NT_SUCCESS(Status))
return Status;
-
+
DeviceExtension = (PGREEN_DEVICE_EXTENSION)Fdo->DeviceExtension;
RtlZeroMemory(DeviceExtension, sizeof(GREEN_DEVICE_EXTENSION));
DeviceExtension->Common.Type = Green;
-
+
Status = KeyboardInitialize(DriverObject, &DeviceExtension->Keyboard);
if (!NT_SUCCESS(Status))
{
return Status;
}
((PKEYBOARD_DEVICE_EXTENSION)DeviceExtension->Keyboard->DeviceExtension)->Green = Fdo;
-
+
Status = ScreenInitialize(DriverObject, &DeviceExtension->Screen);
if (!NT_SUCCESS(Status))
{
return Status;
}
((PSCREEN_DEVICE_EXTENSION)DeviceExtension->Screen->DeviceExtension)->Green = Fdo;
-
+
/* initialize green Fdo */
DeviceExtension->LowerDevice = IoAttachDeviceToDeviceStack(Fdo, Pdo);
DeviceExtension->LineControl.WordLength = 8;
DeviceExtension->Timeouts.ReadTotalTimeoutMultiplier = INFINITE;
DeviceExtension->Timeouts.WriteTotalTimeoutMultiplier = 0; /* FIXME */
DeviceExtension->Timeouts.WriteTotalTimeoutConstant = 0; /* FIXME */
-
+
/* open associated serial port */
RtlInitUnicodeString(&serialPortName, L"\\Device\\Serial1"); /* FIXME: don't hardcode string */
Status = ObReferenceObjectByName(
NULL,
(PVOID*)&DeviceExtension->Serial);
/* FIXME: we never ObDereferenceObject */
-
+
Fdo->Flags |= DO_POWER_PAGABLE | DO_BUFFERED_IO;
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
-
+
return Status;
}
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS VT100 emulator
* FILE: drivers/dd/green/screen.c
* PURPOSE: Screen part of green management
- *
+ *
* PROGRAMMERS: Eric Kohl (ekohl@abo.rhein-zeitung.de)
* Art Yerkes
* Hervé Poussineau (hpoussin@reactos.com)
int CurrentInt;
UCHAR CurrentChar;
NTSTATUS Status;
-
+
SizeLeft = sizeof(DeviceExtension->SendBuffer) - DeviceExtension->SendBufferPosition;
if (SizeLeft < NumberOfChars * 2 || NumberOfChars == 0)
{
DeviceExtension->SendBufferPosition = 0;
SizeLeft = sizeof(DeviceExtension->SendBuffer);
}
-
+
va_start(args, NumberOfChars);
while (NumberOfChars-- > 0)
{
if (CurrentInt > 0)
{
CurrentChar = (UCHAR)CurrentInt;
-
+
/* Why 0xff chars are printed on a 'dir' ? */
if (CurrentChar == 0xff) CurrentChar = ' ';
-
+
DeviceExtension->SendBuffer[DeviceExtension->SendBufferPosition++] = CurrentChar;
SizeLeft--;
}
PSCREEN_DEVICE_EXTENSION DeviceExtension;
UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\BlueScreen");
NTSTATUS Status;
-
+
DPRINT("Green: ScreenInitialize() called\n");
-
+
Status = IoCreateDevice(DriverObject,
sizeof(SCREEN_DEVICE_EXTENSION),
&DeviceName, /* FIXME: don't hardcode string */
&Fdo);
if (!NT_SUCCESS(Status))
return Status;
-
+
DeviceExtension = (PSCREEN_DEVICE_EXTENSION)Fdo->DeviceExtension;
RtlZeroMemory(DeviceExtension, sizeof(SCREEN_DEVICE_EXTENSION));
DeviceExtension->Common.Type = Screen;
return STATUS_INSUFFICIENT_RESOURCES;
}
DeviceExtension->TabWidth = 8;
-
+
/* more initialization */
DeviceExtension->Mode = ENABLE_PROCESSED_OUTPUT |
ENABLE_WRAP_AT_EOL_OUTPUT;
-
+
/* initialize screen at next write */
AddToSendBuffer(DeviceExtension, 2, ESC, 'c'); /* reset device */
AddToSendBuffer(DeviceExtension, 4, ESC, '[', '7', 'l'); /* disable line wrap */
AddToSendBuffer(DeviceExtension, 4, ESC, '[', '3', 'g'); /* clear all tabs */
-
+
Fdo->Flags |= DO_POWER_PAGABLE | DO_BUFFERED_IO;
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
-
+
*ScreenFdo = Fdo;
-
+
return STATUS_SUCCESS;
}
PSCREEN_DEVICE_EXTENSION DeviceExtension;
PUCHAR VideoMemory; /* FIXME: is it useful? */
ULONG VideoMemorySize; /* FIXME: is it useful? */
-
+
ULONG Columns, Rows;
ULONG CursorX, CursorY;
ULONG i, j;
NTSTATUS Status;
-
+
DPRINT("Green: IRP_MJ_WRITE\n");
-
+
Stack = IoGetCurrentIrpStackLocation (Irp);
Buffer = Irp->UserBuffer;
DeviceExtension = (PSCREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
VideoMemory = DeviceExtension->VideoMemory;
-
+
Columns = DeviceExtension->Columns;
Rows = DeviceExtension->Rows;
CursorX = (DeviceExtension->LogicalOffset / 2) % Columns + 1;
for (i = 0; i < Stack->Parameters.Write.Length; i++)
DbgPrint(" 0x%02x", Buffer[i]);
DbgPrint("\n");
-
+
if (!(DeviceExtension->Mode & ENABLE_PROCESSED_OUTPUT))
{
/* raw output mode */
CHECKPOINT;
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
IoCompleteRequest (Irp, IO_NO_INCREMENT);
-
+
return STATUS_NOT_SUPPORTED;
}
else
DPRINT1("Y: %lu -> %lu\n", CursorY, CursorY + 1);
CursorY++;
AddToSendBuffer(DeviceExtension, 6, ESC, '[', -(int)CursorY, ';', '1', 'H');
-
+
}
}
}
}
}
}
-
+
DeviceExtension->LogicalOffset = ((CursorX-1) + (CursorY-1) * Columns) * 2;
-
+
/* flush output buffer */
AddToSendBuffer(DeviceExtension, 0);
-
+
Status = STATUS_SUCCESS;
Irp->IoStatus.Status = Status;
IoCompleteRequest (Irp, IO_NO_INCREMENT);
-
+
return Status;
}
PIO_STACK_LOCATION Stack;
PSCREEN_DEVICE_EXTENSION DeviceExtension;
NTSTATUS Status;
-
+
Stack = IoGetCurrentIrpStackLocation(Irp);
DeviceExtension = (PSCREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
+
switch (Stack->Parameters.DeviceIoControl.IoControlCode)
{
case IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO:
{
PCONSOLE_SCREEN_BUFFER_INFO pcsbi;
DPRINT("Green: IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO\n");
-
+
pcsbi = (PCONSOLE_SCREEN_BUFFER_INFO)Irp->AssociatedIrp.SystemBuffer;
-
+
pcsbi->dwSize.X = DeviceExtension->Columns;
pcsbi->dwSize.Y = DeviceExtension->Rows;
-
+
pcsbi->dwCursorPosition.X = (SHORT)(DeviceExtension->LogicalOffset % DeviceExtension->Columns);
pcsbi->dwCursorPosition.Y = (SHORT)(DeviceExtension->LogicalOffset / DeviceExtension->Columns);
-
+
pcsbi->wAttributes = DeviceExtension->CharAttribute;
-
+
pcsbi->srWindow.Left = 1;
pcsbi->srWindow.Right = DeviceExtension->Columns;
pcsbi->srWindow.Top = 1;
pcsbi->srWindow.Bottom = DeviceExtension->Rows;
-
+
pcsbi->dwMaximumWindowSize.X = DeviceExtension->Columns;
pcsbi->dwMaximumWindowSize.Y = DeviceExtension->Rows;
-
+
Irp->IoStatus.Information = sizeof(CONSOLE_SCREEN_BUFFER_INFO);
Status = STATUS_SUCCESS;
break;
{
PCONSOLE_SCREEN_BUFFER_INFO pcsbi;
DPRINT("Green: IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO\n");
-
+
pcsbi = (PCONSOLE_SCREEN_BUFFER_INFO)Irp->AssociatedIrp.SystemBuffer;
/* FIXME: remove */ { pcsbi->dwCursorPosition.X++; }
/* FIXME: remove */ { pcsbi->dwCursorPosition.Y++; }
ASSERT(pcsbi->dwCursorPosition.Y >= 1);
ASSERT(pcsbi->dwCursorPosition.X <= DeviceExtension->Columns);
ASSERT(pcsbi->dwCursorPosition.Y <= DeviceExtension->Rows);
-
+
DeviceExtension->LogicalOffset = (
(pcsbi->dwCursorPosition.Y-1) * DeviceExtension->Columns +
(pcsbi->dwCursorPosition.X-1)) * 2;
AddToSendBuffer(DeviceExtension, 6, ESC, '[',
-(int)pcsbi->dwCursorPosition.Y, ';',
-(int)pcsbi->dwCursorPosition.X, 'H');
-
+
/* flush buffer */
AddToSendBuffer(DeviceExtension, 0);
-
+
DeviceExtension->CharAttribute = pcsbi->wAttributes;
-
+
Irp->IoStatus.Information = 0;
Status = STATUS_SUCCESS;
break;
{
PCONSOLE_CURSOR_INFO pcci = (PCONSOLE_CURSOR_INFO)Irp->AssociatedIrp.SystemBuffer;
DPRINT("Green: IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_GET_CURSOR_INFO\n");
-
+
pcci->dwSize = 1;
pcci->bVisible = TRUE;
-
+
Irp->IoStatus.Information = sizeof (CONSOLE_CURSOR_INFO);
Status = STATUS_SUCCESS;
break;
{
PCONSOLE_MODE pcm = (PCONSOLE_MODE)Irp->AssociatedIrp.SystemBuffer;
DPRINT("Green: IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_GET_MODE\n");
-
+
pcm->dwMode = DeviceExtension->Mode;
-
+
Irp->IoStatus.Information = sizeof(CONSOLE_MODE);
Status = STATUS_SUCCESS;
break;
{
PCONSOLE_MODE pcm = (PCONSOLE_MODE)Irp->AssociatedIrp.SystemBuffer;
DPRINT("Green: IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_SET_MODE\n");
-
+
DeviceExtension->Mode = pcm->dwMode;
-
+
Irp->IoStatus.Information = 0;
Status = STATUS_SUCCESS;
break;
case IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE:
{
DPRINT("Green: IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE\n");
-
+
DeviceExtension->CharAttribute = (WORD)*(PWORD)Irp->AssociatedIrp.SystemBuffer;
Irp->IoStatus.Information = 0;
Status = STATUS_SUCCESS;
ULONG x, y;
BOOLEAN DoOptimization = FALSE;
DPRINT("Green: IRP_MJ_DEVICE_CONTROL / IOCTL_CONSOLE_DRAW\n");
-
+
ConsoleDraw = (PCONSOLE_DRAW)MmGetSystemAddressForMdl(Irp->MdlAddress);
/* FIXME: remove */ { ConsoleDraw->X++; ConsoleDraw->CursorX++; }
/* FIXME: remove */ { ConsoleDraw->Y++; ConsoleDraw->CursorY++; }
ASSERT(ConsoleDraw->CursorY >= 1);
ASSERT(ConsoleDraw->CursorX <= DeviceExtension->Columns);
ASSERT(ConsoleDraw->CursorY <= DeviceExtension->Rows);
-
+
#if 0
if (ConsoleDraw->X == 1
&& ConsoleDraw->Y == 1
}
#endif
/* add here more optimizations if needed */
-
+
if (!DoOptimization)
{
for (y = 0; y < ConsoleDraw->SizeY; y++)
}
}
}
-
+
DeviceExtension->LogicalOffset = (
(ConsoleDraw->CursorY-1) * DeviceExtension->Columns +
(ConsoleDraw->CursorX-1)) * 2;
AddToSendBuffer(DeviceExtension, 6, ESC, '[',
-(int)(ConsoleDraw->CursorY), ';',
-(int)(ConsoleDraw->CursorX), 'H');
-
+
/* flush buffer */
AddToSendBuffer(DeviceExtension, 0);
-
+
Irp->IoStatus.Information = 0;
Status = STATUS_SUCCESS;
break;
Stack->Parameters.DeviceIoControl.IoControlCode);
Status = STATUS_NOT_IMPLEMENTED;
}
-
+
Irp->IoStatus.Status = Status;
IoCompleteRequest (Irp, IO_NO_INCREMENT);
return Status;
// Parameters = Instance->DriverObject->DriverExtension;
DPRINT("DeviceObject at 0x%x, DeviceExtension at 0x%x\n", DeviceObject, Parameters);
-
+
if (! Parameters)
{
DPRINT("NULL POINTER!\n");
Parameters->IRQ = DEFAULT_IRQ;
// Only to be enabled once we can get support for multiple cards working :)
-/*
+/*
DPRINT("Loading settings from: %S\n", RegistryPath);
-
+
s = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, RegistryPath, Table,
&Parameters, NULL);
*/
*/
{
DPRINT("MPU401Create() called!\n");
-
+
// Initialize the MPU-401?
// ... do stuff ...
NTSTATUS Status;
DPRINT("MPU401Close() called!\n");
-
+
DeviceExtension = DeviceObject->DeviceExtension;
Status = STATUS_SUCCESS;
DeviceExtension = DeviceObject->DeviceExtension;
Stack = IoGetCurrentIrpStackLocation(Irp);
-
+
DPRINT("Control code %d [0x%x]\n", Stack->Parameters.DeviceIoControl.IoControlCode,
Stack->Parameters.DeviceIoControl.IoControlCode);
Data = (PBYTE) Irp->AssociatedIrp.SystemBuffer;
DPRINT("Sending %d bytes of MIDI data to 0x%d:\n", Stack->Parameters.DeviceIoControl.InputBufferLength, DeviceExtension->Port);
-
+
for (ByteCount = 0; ByteCount < Stack->Parameters.DeviceIoControl.InputBufferLength; ByteCount ++)
{
DPRINT("0x%x ", Data[ByteCount]);
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
+
return(STATUS_SUCCESS);
}
}
-
+
return(STATUS_SUCCESS);
/*
BOOLEAN WaitToSend(UINT BasePort)
{
int TimeOut;
-
+
DbgPrint("WaitToSend ");
// Check if it's OK to send
DbgPrint("FAILED\n");
return FALSE;
}
-
+
DbgPrint("SUCCEEDED\n");
return TRUE;
DbgPrint("FAILED\n");
return FALSE;
}
-
+
DbgPrint("SUCCEEDED\n");
return TRUE;
{
PIO_STACK_LOCATION piosStack = IoGetCurrentIrpStackLocation(Irp);
NTSTATUS nErrCode;
-
+
nErrCode = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
}
/* TODO: \Device\Zero should be memory-mappable */
-NTSTATUS STDCALL
+NTSTATUS STDCALL
DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
PDEVICE_OBJECT pdoNullDevice;
* FILE: services/parallel/parallel.c
* PURPOSE: Parallel port driver
* PROGRAMMER: David Welch (welch@mcmail.com)
- * UPDATE HISTORY:
+ * UPDATE HISTORY:
* ??/??/??: Created
* 18/06/98: Made more NT like
*/
* ch = character to write
*/
{
-
+
int count=0;
int status;
int wait=0;
count++;
}
while ( count < 500000 && !(status & LP_PBUSY) );
-
+
if (count==500000)
{
DPRINT("printer_putchar(): timed out\n");
return;
}
-
+
WRITE_PORT_UCHAR((PUCHAR)LP_B,ch);
while (wait != 10000) { wait++; }
WRITE_PORT_UCHAR((PUCHAR)LP_C, (LP_PSELECP | LP_PINITP | LP_PSTROBE ));
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
NTSTATUS status;
int i;
-
+
switch (Stack->MajorFunction)
{
case IRP_MJ_CREATE:
Parallel_Reset();
status = STATUS_SUCCESS;
break;
-
+
case IRP_MJ_CLOSE:
status = STATUS_SUCCESS;
break;
-
+
case IRP_MJ_WRITE:
DPRINT("(Parallel Port Driver) Writing %d bytes\n",
Stack->Parameters.Write.Length);
}
status = STATUS_SUCCESS;
break;
-
+
default:
status = STATUS_NOT_IMPLEMENTED;
break;
}
-
+
Irp->IoStatus.Status = status;
Irp->IoStatus.Information = 0;
-
+
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(status);
}
PDEVICE_OBJECT DeviceObject;
UNICODE_STRING DeviceName = ROS_STRING_INITIALIZER(L"\\Device\\Parallel");
NTSTATUS Status;
-
+
DPRINT("Parallel Port Driver 0.0.1\n");
-
+
Status = IoCreateDevice(DriverObject,
0,
&DeviceName,
DriverObject->MajorFunction[IRP_MJ_CREATE] = Dispatch;
DriverObject->MajorFunction[IRP_MJ_WRITE] = Dispatch;
DriverObject->DriverUnload = NULL;
-
+
return(STATUS_SUCCESS);
}
* gets inverted, but it is also active low.
*/
-/*
+/*
* bit defines for 8255 status port
* base + 1
* accessed with LP_S(minor), which gets the byte...
#define LP_PSELECD 0x10 /* unchanged input, active high */
#define LP_PERRORP 0x08 /* unchanged input, active low */
-/*
+/*
* defines for 8255 control port
- * base + 2
+ * base + 2
* accessed with LP_C(minor)
*/
#define LP_PINTEN 0x10
#define LP_PAUTOLF 0x02 /* inverted output, active low */
#define LP_PSTROBE 0x01 /* inverted output, active low */
-/*
- * the value written to ports to test existence. PC-style ports will
+/*
+ * the value written to ports to test existence. PC-style ports will
* return the value written. AT-style ports will return 0. so why not
- * make them the same ?
+ * make them the same ?
*/
#define LP_DUMMY 0x00
Status = STATUS_INVALID_DEVICE_REQUEST;
}
Irp->IoStatus.Status = Status;
- IoCompleteRequest(Irp, NT_SUCCESS(Status) ? IO_DISK_INCREMENT : IO_NO_INCREMENT);
+ IoCompleteRequest(Irp, NT_SUCCESS(Status) ? IO_DISK_INCREMENT : IO_NO_INCREMENT);
return Status;
}
unsigned int dstlen = 1024 * 1440;
FILE_STANDARD_INFORMATION finfo;
DWORD err;
-
+
DPRINT("Ramdisk driver\n");
-
+
/* Export other driver entry points... */
DriverObject->MajorFunction[IRP_MJ_CREATE] = RamdrvDispatchOpenClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = RamdrvDispatchOpenClose;
DriverObject->MajorFunction[IRP_MJ_READ] = RamdrvDispatchReadWrite;
DriverObject->MajorFunction[IRP_MJ_WRITE] = RamdrvDispatchReadWrite;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = RamdrvDispatchDeviceControl;
-
-
+
+
// create device and symbolic link
Status = IoCreateDevice( DriverObject,
sizeof( RAMDRV_DEVICE_EXTENSION ),
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/dd/serial/circularbuffer.c
* PURPOSE: Operations on a circular buffer
- *
+ *
* PROGRAMMERS: Hervé Poussineau (poussine@freesurf.fr)
*/
IN ULONG NewBufferSize)
{
PUCHAR NewBuffer;
-
+
DPRINT("Serial: IncreaseCircularBufferSize(pBuffer %p, NewBufferSize %lu)\n", pBuffer, NewBufferSize);
ASSERT(pBuffer);
ASSERT(pBuffer->Length);
return STATUS_INVALID_PARAMETER;
else if (pBuffer->Length == NewBufferSize)
return STATUS_SUCCESS;
-
+
NewBuffer = (PUCHAR)ExAllocatePoolWithTag(NonPagedPool, NewBufferSize * sizeof(UCHAR), SERIAL_TAG);
if (!NewBuffer)
return STATUS_INSUFFICIENT_RESOURCES;
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/dd/serial/cleanup.c
* PURPOSE: Serial IRP_MJ_CLEANUP operations
- *
+ *
* PROGRAMMERS: Hervé Poussineau (poussine@freesurf.fr)
*/
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/dd/serial/close.c
* PURPOSE: Serial IRP_MJ_CLOSE operations
- *
+ *
* PROGRAMMERS: Hervé Poussineau (poussine@freesurf.fr)
*/
IN PIRP Irp)
{
PSERIAL_DEVICE_EXTENSION pDeviceExtension;
-
+
DPRINT("Serial: IRP_MJ_CLOSE\n");
pDeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
pDeviceExtension->IsOpened = FALSE;
-
+
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/dd/serial/create.c
* PURPOSE: Serial IRP_MJ_CREATE operations
- *
+ *
* PROGRAMMERS: Hervé Poussineau (poussine@freesurf.fr)
*/
PFILE_OBJECT FileObject;
PSERIAL_DEVICE_EXTENSION DeviceExtension;
NTSTATUS Status;
-
+
DPRINT("Serial: IRP_MJ_CREATE\n");
Stack = IoGetCurrentIrpStackLocation(Irp);
FileObject = Stack->FileObject;
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
+
ASSERT(FileObject);
-
+
if (Stack->Parameters.Create.Options & FILE_DIRECTORY_FILE)
{
CHECKPOINT;
Status = STATUS_NOT_A_DIRECTORY;
goto ByeBye;
}
-
- if (FileObject->FileName.Length != 0 ||
+
+ if (FileObject->FileName.Length != 0 ||
FileObject->RelatedFileObject != NULL)
{
CHECKPOINT;
Status = STATUS_ACCESS_DENIED;
goto ByeBye;
}
-
+
if(DeviceExtension->IsOpened)
{
DPRINT("Serial: COM%lu is already opened\n", DeviceExtension->ComPort);
Status = STATUS_ACCESS_DENIED;
goto ByeBye;
}
-
+
DPRINT("Serial: open COM%lu: successfull\n", DeviceExtension->ComPort);
DeviceExtension->IsOpened = TRUE;
Status = STATUS_SUCCESS;
-
+
ByeBye:
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/dd/serial/devctrl.c
* PURPOSE: Serial IRP_MJ_DEVICE_CONTROL operations
- *
+ *
* PROGRAMMERS: Hervé Poussineau (poussine@freesurf.fr)
*/
ASSERT(Irp);
ASSERT(BufferIn);
ASSERT(BufferOut);
-
+
switch (IO_METHOD_FROM_CTL_CODE(IoControlCode))
{
case METHOD_BUFFERED:
*BufferOut = Irp->UserBuffer;
return;
}
-
+
/* Should never happen */
}
PUCHAR ComPortBase = (PUCHAR)DeviceExtension->BaseAddress;
ULONG BaudRate;
NTSTATUS Status = STATUS_SUCCESS;
-
+
if (NewBaudRate & SERIAL_BAUD_USER)
{
BaudRate = NewBaudRate & ~SERIAL_BAUD_USER;
default: Status = STATUS_INVALID_PARAMETER;
}
}
-
+
if (NT_SUCCESS(Status))
{
Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, (PVOID)DeviceExtension->ComPort);
WRITE_PORT_UCHAR(SER_DLM(ComPortBase), divisor >> 8);
/* Switch back to normal registers */
WRITE_PORT_UCHAR(SER_LCR(ComPortBase), Lcr);
-
+
IoReleaseRemoveLock(&DeviceExtension->RemoveLock, (PVOID)DeviceExtension->ComPort);
}
}
-
+
if (NT_SUCCESS(Status))
DeviceExtension->BaudRate = BaudRate;
return Status;
PUCHAR ComPortBase;
UCHAR Lcr = 0;
NTSTATUS Status;
-
+
ASSERT(DeviceExtension);
ASSERT(NewSettings);
-
+
DPRINT("Serial: SerialSetLineControl(COM%lu, Settings { %lu %lu %lu })\n",
DeviceExtension->ComPort, NewSettings->StopBits, NewSettings->Parity, NewSettings->WordLength);
-
+
/* Verify parameters */
switch (NewSettings->WordLength)
{
case 8: Lcr |= SR_LCR_CS8; break;
default: return STATUS_INVALID_PARAMETER;
}
-
+
if (NewSettings->WordLength < 5 || NewSettings->WordLength > 8)
return STATUS_INVALID_PARAMETER;
-
+
switch (NewSettings->Parity)
{
case NO_PARITY: Lcr |= SR_LCR_PNO; break;
case SPACE_PARITY: Lcr |= SR_LCR_PSP; break;
default: return STATUS_INVALID_PARAMETER;
}
-
+
switch (NewSettings->StopBits)
{
case STOP_BIT_1:
default:
return STATUS_INVALID_PARAMETER;
}
-
+
/* Update current parameters */
ComPortBase = (PUCHAR)DeviceExtension->BaseAddress;
Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, (PVOID)DeviceExtension->ComPort);
if (!NT_SUCCESS(Status))
return Status;
WRITE_PORT_UCHAR(SER_LCR(ComPortBase), Lcr);
-
+
/* Read junk out of RBR */
READ_PORT_UCHAR(SER_RBR(ComPortBase));
IoReleaseRemoveLock(&DeviceExtension->RemoveLock, (PVOID)DeviceExtension->ComPort);
-
+
if (NT_SUCCESS(Status))
DeviceExtension->SerialLineControl = *NewSettings;
-
+
return Status;
}
IN PSERIAL_DEVICE_EXTENSION DeviceExtension)
{
ASSERT(DeviceExtension);
-
+
RtlZeroMemory(&DeviceExtension->SerialPerfStats, sizeof(SERIALPERF_STATS));
DeviceExtension->BreakInterruptErrorCount = 0;
return TRUE;
IN PSERIAL_DEVICE_EXTENSION DeviceExtension)
{
ASSERT(pCommProp);
-
+
RtlZeroMemory(pCommProp, sizeof(SERIAL_COMMPROP));
-
+
pCommProp->PacketLength = sizeof(SERIAL_COMMPROP);
pCommProp->PacketVersion = 2;
pCommProp->ServiceMask = SERIAL_SP_SERIALCOMM;
| SERIAL_PCF_XONXOFF;
pCommProp->SettableParams = SERIAL_SP_BAUD | SERIAL_SP_DATABITS | SERIAL_SP_HANDSHAKING
| SERIAL_SP_PARITY | SERIAL_SP_PARITY_CHECK | SERIAL_SP_STOPBITS;
-
+
/* SettableBaud is related to Uart type */
pCommProp->SettableBaud = SERIAL_BAUD_075 | SERIAL_BAUD_110 | SERIAL_BAUD_134_5
| SERIAL_BAUD_150 | SERIAL_BAUD_300 | SERIAL_BAUD_600 | SERIAL_BAUD_1200
pCommProp->SettableBaud |= SERIAL_BAUD_56K | SERIAL_BAUD_57600 | SERIAL_BAUD_115200 | SERIAL_BAUD_128K;
pCommProp->MaxBaud = SERIAL_BAUD_115200;
}
-
+
pCommProp->SettableData = SERIAL_DATABITS_5 | SERIAL_DATABITS_6 | SERIAL_DATABITS_7 | SERIAL_DATABITS_8;
pCommProp->SettableStopParity = SERIAL_STOPBITS_10 | SERIAL_STOPBITS_15 | SERIAL_STOPBITS_20
| SERIAL_PARITY_NONE | SERIAL_PARITY_ODD | SERIAL_PARITY_EVEN | SERIAL_PARITY_MARK | SERIAL_PARITY_SPACE;
-
+
return STATUS_SUCCESS;
}
IN PSERIAL_DEVICE_EXTENSION DeviceExtension)
{
KIRQL Irql;
-
+
ASSERT(pSerialStatus);
RtlZeroMemory(pSerialStatus, sizeof(SERIAL_STATUS));
-
+
pSerialStatus->Errors = 0;
if (DeviceExtension->BreakInterruptErrorCount)
pSerialStatus->Errors |= SERIAL_ERROR_BREAK;
pSerialStatus->Errors |= SERIAL_ERROR_QUEUEOVERRUN;
if (DeviceExtension->SerialPerfStats.ParityErrorCount)
pSerialStatus->Errors |= SERIAL_ERROR_PARITY;
-
+
pSerialStatus->HoldReasons = 0; /* FIXME */
-
+
KeAcquireSpinLock(&DeviceExtension->InputBufferLock, &Irql);
pSerialStatus->AmountInInQueue = (DeviceExtension->InputBuffer.WritePosition + DeviceExtension->InputBuffer.Length
- DeviceExtension->InputBuffer.ReadPosition) % DeviceExtension->InputBuffer.Length;
KeReleaseSpinLock(&DeviceExtension->InputBufferLock, Irql);
-
+
KeAcquireSpinLock(&DeviceExtension->OutputBufferLock, &Irql);
pSerialStatus->AmountInOutQueue = (DeviceExtension->OutputBuffer.WritePosition + DeviceExtension->OutputBuffer.Length
- DeviceExtension->OutputBuffer.ReadPosition) % DeviceExtension->OutputBuffer.Length;
KeReleaseSpinLock(&DeviceExtension->OutputBufferLock, Irql);
-
+
pSerialStatus->EofReceived = FALSE; /* always FALSE */
pSerialStatus->WaitForImmediate = FALSE; /* always FALSE */
-
+
return STATUS_SUCCESS;
}
PVOID BufferIn, BufferOut;
PUCHAR ComPortBase;
NTSTATUS Status;
-
+
DPRINT("Serial: IRP_MJ_DEVICE_CONTROL dispatch\n");
-
+
Stack = IoGetCurrentIrpStackLocation(Irp);
LengthIn = Stack->Parameters.DeviceIoControl.InputBufferLength;
LengthOut = Stack->Parameters.DeviceIoControl.OutputBufferLength;
ComPortBase = (PUCHAR)DeviceExtension->BaseAddress;
IoControlCode = Stack->Parameters.DeviceIoControl.IoControlCode;
SerialGetUserBuffers(Irp, IoControlCode, &BufferIn, &BufferOut);
-
+
/* FIXME: need to probe buffers */
/* FIXME: see http://www.osronline.com/ddkx/serial/serref_61bm.htm */
switch (IoControlCode)
case IOCTL_SERIAL_CLR_DTR:
{
DPRINT("Serial: IOCTL_SERIAL_CLR_DTR\n");
- /* FIXME: If the handshake flow control of the device is configured to
+ /* FIXME: If the handshake flow control of the device is configured to
* automatically use DTR, return STATUS_INVALID_PARAMETER */
Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, (PVOID)DeviceExtension->ComPort);
if (NT_SUCCESS(Status))
case IOCTL_SERIAL_CLR_RTS:
{
DPRINT("Serial: IOCTL_SERIAL_CLR_RTS\n");
- /* FIXME: If the handshake flow control of the device is configured to
+ /* FIXME: If the handshake flow control of the device is configured to
* automatically use RTS, return STATUS_INVALID_PARAMETER */
Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, (PVOID)DeviceExtension->ComPort);
if (NT_SUCCESS(Status))
else
{
ULONG PurgeMask = *(PULONG)BufferIn;
-
+
Status = STATUS_SUCCESS;
/* FIXME: use SERIAL_PURGE_RXABORT and SERIAL_PURGE_TXABORT flags */
if (PurgeMask & SERIAL_PURGE_RXCLEAR)
}
KeReleaseSpinLock(&DeviceExtension->InputBufferLock, Irql);
}
-
+
if (PurgeMask & SERIAL_PURGE_TXCLEAR)
{
KeAcquireSpinLock(&DeviceExtension->OutputBufferLock, &Irql);
}
case IOCTL_SERIAL_SET_DTR:
{
- /* FIXME: If the handshake flow control of the device is configured to
+ /* FIXME: If the handshake flow control of the device is configured to
* automatically use DTR, return STATUS_INVALID_PARAMETER */
DPRINT("Serial: IOCTL_SERIAL_SET_DTR\n");
if (!(DeviceExtension->MCR & SR_MCR_DTR))
}
case IOCTL_SERIAL_SET_RTS:
{
- /* FIXME: If the handshake flow control of the device is configured to
+ /* FIXME: If the handshake flow control of the device is configured to
* automatically use DTR, return STATUS_INVALID_PARAMETER */
DPRINT("Serial: IOCTL_SERIAL_SET_RTS\n");
if (!(DeviceExtension->MCR & SR_MCR_RTS))
return IoCallDriver(DeviceExtension->LowerDevice, Irp);
}
}
-
+
Irp->IoStatus.Information = Information;
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/dd/serial/info.c
* PURPOSE: Serial IRP_MJ_QUERY_INFORMATION operations
- *
+ *
* PROGRAMMERS: Hervé Poussineau (poussine@freesurf.fr)
*/
ULONG BufferLength;
ULONG_PTR Information = 0;
NTSTATUS Status;
-
+
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
Stack = IoGetCurrentIrpStackLocation(Irp);
SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
BufferLength = Stack->Parameters.QueryFile.Length;
-
+
switch (Stack->Parameters.QueryFile.FileInformationClass)
{
case FileStandardInformation:
{
PFILE_STANDARD_INFORMATION StandardInfo = (PFILE_STANDARD_INFORMATION)SystemBuffer;
-
+
DPRINT("Serial: IRP_MJ_QUERY_INFORMATION / FileStandardInformation\n");
if (BufferLength < sizeof(FILE_STANDARD_INFORMATION))
Status = STATUS_BUFFER_OVERFLOW;
case FilePositionInformation:
{
PFILE_POSITION_INFORMATION PositionInfo = (PFILE_POSITION_INFORMATION)SystemBuffer;
-
+
ASSERT(PositionInfo);
-
+
DPRINT("Serial: IRP_MJ_QUERY_INFORMATION / FilePositionInformation\n");
if (BufferLength < sizeof(PFILE_POSITION_INFORMATION))
Status = STATUS_BUFFER_OVERFLOW;
return ForwardIrpAndForget(DeviceObject, Irp);
}
}
-
+
Irp->IoStatus.Information = Information;
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/bus/serial/legacy.c
* PURPOSE: Legacy serial port enumeration
- *
+ *
* PROGRAMMERS: Hervé Poussineau (poussine@freesurf.fr)
* Mark Junker (mjscod@gmx.de)
*/
UCHAR OldScr, Scr5A, ScrA5;
BOOLEAN FifoEnabled;
UCHAR NewFifoStatus;
-
+
Lcr = READ_PORT_UCHAR(SER_LCR(BaseAddress));
WRITE_PORT_UCHAR(SER_LCR(BaseAddress), Lcr ^ 0xFF);
TestLcr = READ_PORT_UCHAR(SER_LCR(BaseAddress)) ^ 0xFF;
WRITE_PORT_UCHAR(SER_LCR(BaseAddress), Lcr);
-
+
/* Accessing the LCR must work for a usable serial port */
if (TestLcr != Lcr)
return UartUnknown;
-
+
/* Ensure that all following accesses are done as required */
READ_PORT_UCHAR(SER_RBR(BaseAddress));
READ_PORT_UCHAR(SER_IER(BaseAddress));
READ_PORT_UCHAR(SER_LSR(BaseAddress));
READ_PORT_UCHAR(SER_MSR(BaseAddress));
READ_PORT_UCHAR(SER_SCR(BaseAddress));
-
+
/* Test scratch pad */
OldScr = READ_PORT_UCHAR(SER_SCR(BaseAddress));
WRITE_PORT_UCHAR(SER_SCR(BaseAddress), 0x5A);
WRITE_PORT_UCHAR(SER_SCR(BaseAddress), 0xA5);
ScrA5 = READ_PORT_UCHAR(SER_SCR(BaseAddress));
WRITE_PORT_UCHAR(SER_SCR(BaseAddress), OldScr);
-
+
/* When non-functional, we have a 8250 */
if (Scr5A != 0x5A || ScrA5 != 0xA5)
return Uart8250;
-
+
/* Test FIFO type */
FifoEnabled = (READ_PORT_UCHAR(SER_IIR(BaseAddress)) & 0x80) != 0;
WRITE_PORT_UCHAR(SER_FCR(BaseAddress), SR_FCR_ENABLE_FIFO);
* with 0x80 */
return Uart16550;
}
-
+
/* FIFO is only functional for 16550A+ */
return Uart16550A;
}
PDEVICE_OBJECT Fdo;
KIRQL Dirql;
NTSTATUS Status;
-
+
/* Create resource list */
ResourceListSize = sizeof(CM_RESOURCE_LIST) + sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
ResourceList = (PCM_RESOURCE_LIST)ExAllocatePoolWithTag(PagedPool, ResourceListSize, SERIAL_TAG);
ResourceDescriptor->u.Port.Start.u.HighPart = 0;
ResourceDescriptor->u.Port.Start.u.LowPart = ComPortBase;
ResourceDescriptor->u.Port.Length = 8;
-
+
ResourceDescriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[1];
ResourceDescriptor->Type = CmResourceTypeInterrupt;
ResourceDescriptor->ShareDisposition = CmResourceShareShared;
&Dirql,
&ResourceDescriptor->u.Interrupt.Affinity);
ResourceDescriptor->u.Interrupt.Level = (ULONG)Dirql;
-
+
/* Report resource list */
Status = IoReportResourceForDetection(
DriverObject, ResourceList, ResourceListSize,
ExFreePoolWithTag(ResourceList, SERIAL_TAG);
return Status;
}
-
+
/* Test if port exists */
UartType = SerialDetectUartType((PUCHAR)ComPortBase);
-
+
/* Report device if detected... */
if (UartType != UartUnknown)
{
ULONG i;
NTSTATUS Status;
NTSTATUS ReturnedStatus = STATUS_SUCCESS;
-
+
for (i = 0; i < sizeof(ComPortBase)/sizeof(ComPortBase[0]); i++)
{
Status = DetectLegacyDevice(DriverObject, ComPortBase[i], Irq[i], &ComPortNumber[i]);
ReturnedStatus = Status;
DPRINT("Serial: Legacy device at 0x%x (IRQ %lu): status = 0x%08lx\n", ComPortBase[i], Irq[i], Status);
}
-
+
return ReturnedStatus;
}
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/dd/serial/misc.c
* PURPOSE: Misceallenous operations
- *
+ *
* PROGRAMMERS: Hervé Poussineau (poussine@freesurf.fr)
*/
/* FIXME: call IoAcquireRemoveLock/IoReleaseRemoveLock around each I/O operation */
PDEVICE_OBJECT LowerDevice = ((PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
KEVENT Event;
NTSTATUS Status;
-
+
ASSERT(LowerDevice);
-
+
KeInitializeEvent(&Event, NotificationEvent, FALSE);
IoCopyCurrentIrpStackLocationToNext(Irp);
-
+
DPRINT("Serial: Calling lower device %p [%wZ]\n", LowerDevice, &LowerDevice->DriverObject->DriverName);
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
-
+
Status = IoCallDriver(LowerDevice, Irp);
if (Status == STATUS_PENDING)
{
if (NT_SUCCESS(Status))
Status = Irp->IoStatus.Status;
}
-
+
return Status;
}
IN PIRP Irp)
{
PDEVICE_OBJECT LowerDevice = ((PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
-
+
ASSERT(LowerDevice);
-
+
IoSkipCurrentIrpStackLocation(Irp);
return IoCallDriver(LowerDevice, Irp);
}
KIRQL Irql;
UCHAR IER;
NTSTATUS Status;
-
+
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)pDeviceExtension;
ComPortBase = (PUCHAR)DeviceExtension->BaseAddress;
-
+
KeAcquireSpinLock(&DeviceExtension->InputBufferLock, &Irql);
while (READ_PORT_UCHAR(SER_LSR(ComPortBase)) & SR_LSR_DATA_RECEIVED)
{
}
KeSetEvent(&DeviceExtension->InputBufferNotEmpty, 0, FALSE);
KeReleaseSpinLock(&DeviceExtension->InputBufferLock, Irql);
-
+
/* allow new interrupts */
IER = READ_PORT_UCHAR(SER_IER(ComPortBase));
WRITE_PORT_UCHAR(SER_IER(ComPortBase), IER | SR_IER_DATA_RECEIVED);
KIRQL Irql;
UCHAR IER;
NTSTATUS Status;
-
+
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)pDeviceExtension;
ComPortBase = (PUCHAR)DeviceExtension->BaseAddress;
-
+
KeAcquireSpinLock(&DeviceExtension->OutputBufferLock, &Irql);
while (!IsCircularBufferEmpty(&DeviceExtension->OutputBuffer)
&& READ_PORT_UCHAR(SER_LSR(ComPortBase)) & SR_LSR_THR_EMPTY)
PSERIAL_DEVICE_EXTENSION DeviceExtension;
PUCHAR ComPortBase;
UCHAR Iir;
-
+
DeviceObject = (PDEVICE_OBJECT)ServiceContext;
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
ComPortBase = (PUCHAR)DeviceExtension->BaseAddress;
-
+
Iir = READ_PORT_UCHAR(SER_IIR(ComPortBase));
if (Iir == 0xff)
return TRUE;
Iir &= SR_IIR_ID_MASK;
if ((Iir & SR_IIR_SELF) != 0) { return FALSE; }
-
+
switch (Iir)
{
case SR_IIR_MSR_CHANGE:
{
UCHAR MSR, IER;
DPRINT("Serial: SR_IIR_MSR_CHANGE\n");
-
+
MSR = READ_PORT_UCHAR(SER_MSR(ComPortBase));
if (MSR & SR_MSR_CTS_CHANGED)
{
case SR_IIR_THR_EMPTY:
{
DPRINT("Serial: SR_IIR_THR_EMPTY\n");
-
+
KeInsertQueueDpc(&DeviceExtension->SendByteDpc, NULL, NULL);
return TRUE;
}
case SR_IIR_DATA_RECEIVED:
{
DPRINT("Serial: SR_IIR_DATA_RECEIVED\n");
-
+
KeInsertQueueDpc(&DeviceExtension->ReceivedByteDpc, NULL, NULL);
return TRUE;
}
{
UCHAR LSR;
DPRINT("Serial: SR_IIR_ERROR\n");
-
+
LSR = READ_PORT_UCHAR(SER_LSR(ComPortBase));
if (LSR & SR_LSR_OVERRUN_ERROR)
InterlockedIncrement(&DeviceExtension->SerialPerfStats.SerialOverrunErrorCount);
InterlockedIncrement(&DeviceExtension->SerialPerfStats.FrameErrorCount);
if (LSR & SR_LSR_BREAK_INT)
InterlockedIncrement(&DeviceExtension->BreakInterruptErrorCount);
-
+
return TRUE;
}
}
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/dd/serial/pnp.c
* PURPOSE: Serial IRP_MJ_PNP operations
- *
+ *
* PROGRAMMERS: Hervé Poussineau (poussine@freesurf.fr)
*/
/* FIXME: call IoAcquireRemoveLock/IoReleaseRemoveLock around each I/O operation */
UNICODE_STRING DeviceName;
static ULONG DeviceNumber = 0;
static ULONG ComPortNumber = 1;
-
+
DPRINT("Serial: SerialAddDeviceInternal called\n");
-
+
ASSERT(DeviceObject);
ASSERT(Pdo);
-
+
/* Create new device object */
swprintf(DeviceNameBuffer, L"\\Device\\Serial%lu", DeviceNumber);
RtlInitUnicodeString(&DeviceName, DeviceNameBuffer);
}
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)Fdo->DeviceExtension;
RtlZeroMemory(DeviceExtension, sizeof(SERIAL_DEVICE_EXTENSION));
-
+
/* Register device interface */
Status = IoRegisterDeviceInterface(Pdo, &GUID_DEVINTERFACE_COMPORT, NULL, &DeviceExtension->SerialInterfaceName);
if (!NT_SUCCESS(Status))
DPRINT("Serial: IoRegisterDeviceInterface() failed with status 0x%08x\n", Status);
goto ByeBye;
}
-
+
DeviceExtension->SerialPortNumber = DeviceNumber++;
if (pComPortNumber == NULL)
DeviceExtension->ComPort = ComPortNumber++;
{
*pFdo = Fdo;
}
-
+
return STATUS_SUCCESS;
ByeBye:
*/
if (Pdo == NULL)
return STATUS_SUCCESS;
-
+
/* We have here a PDO not null. It represents a real serial
* port. So call the internal AddDevice function.
*/
UNICODE_STRING KeyName;
HANDLE hKey;
NTSTATUS Status;
-
+
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
+
ASSERT(ResourceList);
ASSERT(DeviceExtension);
ASSERT(DeviceExtension->PnpState == dsStopped);
-
+
DeviceExtension->BaudRate = 19200 | SERIAL_BAUD_USER;
DeviceExtension->BaseAddress = 0;
Dirql = 0;
if (!Dirql)
return STATUS_INSUFFICIENT_RESOURCES;
ComPortBase = (PUCHAR)DeviceExtension->BaseAddress;
-
+
if (DeviceExtension->UartType == UartUnknown)
DeviceExtension->UartType = SerialDetectUartType(ComPortBase);
-
+
/* Get current settings */
DeviceExtension->MCR = READ_PORT_UCHAR(SER_MCR(ComPortBase));
DeviceExtension->MSR = READ_PORT_UCHAR(SER_MSR(ComPortBase));
DeviceExtension->WaitMask = 0;
-
+
/* Set baud rate */
Status = SerialSetBaudRate(DeviceExtension, DeviceExtension->BaudRate);
if (!NT_SUCCESS(Status))
DPRINT("Serial: SerialSetBaudRate() failed with status 0x%08x\n", Status);
return Status;
}
-
+
/* Set line control */
DeviceExtension->SerialLineControl.StopBits = STOP_BIT_1;
DeviceExtension->SerialLineControl.Parity = NO_PARITY;
DPRINT("Serial: SerialSetLineControl() failed with status 0x%08x\n", Status);
return Status;
}
-
+
/* Clear receive/transmit buffers */
if (DeviceExtension->UartType >= Uart16550A)
{
WRITE_PORT_UCHAR(SER_FCR(ComPortBase),
SR_FCR_CLEAR_RCVR | SR_FCR_CLEAR_XMIT);
}
-
+
/* Create link \DosDevices\COMX -> \Device\SerialX */
swprintf(DeviceNameBuffer, L"\\Device\\Serial%lu", DeviceExtension->SerialPortNumber);
swprintf(LinkNameBuffer, L"\\DosDevices\\COM%lu", DeviceExtension->ComPort);
DPRINT("Serial: IoCreateSymbolicLink() failed with status 0x%08x\n", Status);
return Status;
}
-
+
/* Activate serial interface */
Status = IoSetDeviceInterfaceState(&DeviceExtension->SerialInterfaceName, TRUE);
if (!NT_SUCCESS(Status))
IoDeleteSymbolicLink(&LinkName);
return Status;
}
-
+
/* Connect interrupt and enable them */
Status = IoConnectInterrupt(
&DeviceExtension->Interrupt, SerialInterruptService,
IoDeleteSymbolicLink(&LinkName);
return Status;
}
-
+
/* Write an entry value under HKLM\HARDWARE\DeviceMap\SERIALCOMM */
/* This step is not mandatory, so don't exit in case of error */
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\HARDWARE\\DeviceMap\\SERIALCOMM");
ZwSetValueKey(hKey, &DeviceName, 0, REG_SZ, &ComPortBuffer, ComPort.Length + sizeof(WCHAR));
ZwClose(hKey);
}
-
+
DeviceExtension->PnpState = dsStarted;
-
+
/* Activate interrupt modes */
IER = READ_PORT_UCHAR(SER_IER(ComPortBase));
IER |= SR_IER_DATA_RECEIVED | SR_IER_THR_EMPTY | SR_IER_LSR_CHANGE | SR_IER_MSR_CHANGE;
WRITE_PORT_UCHAR(SER_IER(ComPortBase), IER);
-
+
/* Activate DTR, RTS */
DeviceExtension->MCR |= SR_MCR_DTR | SR_MCR_RTS;
WRITE_PORT_UCHAR(SER_MCR(ComPortBase), DeviceExtension->MCR);
-
+
return STATUS_SUCCESS;
}
PIO_STACK_LOCATION Stack;
ULONG_PTR Information = 0;
NTSTATUS Status;
-
+
Stack = IoGetCurrentIrpStackLocation(Irp);
MinorFunction = Stack->MinorFunction;
-
+
switch (MinorFunction)
{
case IRP_MN_START_DEVICE:
{
BOOLEAN ConflictDetected;
DPRINT("Serial: IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
-
+
/* FIXME: first HACK: PnP manager can send multiple
* IRP_MN_START_DEVICE for one device
*/
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
-
+
/* Call lower driver */
Status = ForwardIrpAndWait(DeviceObject, Irp);
if (NT_SUCCESS(Status))
return ForwardIrpAndForget(DeviceObject, Irp);
}
}
-
+
Irp->IoStatus.Information = Information;
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/dd/serial/power.c
* PURPOSE: Serial IRP_MJ_POWER operations
- *
+ *
* PROGRAMMERS: Hervé Poussineau (poussine@freesurf.fr)
*/
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/dd/serial/create.c
* PURPOSE: Serial IRP_MJ_READ/IRP_MJ_WRITE operations
- *
+ *
* PROGRAMMERS: Hervé Poussineau (poussine@freesurf.fr)
*/
SerialGetUserBuffer(IN PIRP Irp)
{
ASSERT(Irp);
-
+
return Irp->AssociatedIrp.SystemBuffer;
}
PVOID ObjectsArray[2];
ULONG_PTR Information = 0;
NTSTATUS Status;
-
+
ASSERT(DeviceObject);
ASSERT(WorkItemData);
-
+
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
ComPortBase = (PUCHAR)DeviceExtension->BaseAddress;
Length = IoGetCurrentIrpStackLocation(Irp)->Parameters.Read.Length;
Buffer = SerialGetUserBuffer(Irp);
-
+
DPRINT("Serial: UseIntervalTimeout = %s, IntervalTimeout = %lu\n",
WorkItemData->UseIntervalTimeout ? "YES" : "NO",
WorkItemData->UseIntervalTimeout ? WorkItemData->IntervalTimeout.QuadPart : 0);
DPRINT("Serial: UseTotalTimeout = %s\n",
WorkItemData->UseTotalTimeout ? "YES" : "NO");
-
+
ObjectCount = 1;
ObjectsArray[0] = &DeviceExtension->InputBufferNotEmpty;
if (WorkItemData->UseTotalTimeout)
ObjectsArray[ObjectCount] = &TotalTimeoutTimer;
ObjectCount++;
}
-
+
/* while buffer is not fully filled */
while (Length > 0)
{
{
PopCircularBufferEntry(&DeviceExtension->InputBuffer, &ReceivedByte);
DPRINT("Serial: reading byte from buffer: 0x%02x\n", ReceivedByte);
-
+
Buffer[Information++] = ReceivedByte;
Length--;
}
KeClearEvent(&DeviceExtension->InputBufferNotEmpty);
KeReleaseSpinLock(&DeviceExtension->InputBufferLock, Irql);
-
+
if (WorkItemData->DontWait
&& !(WorkItemData->ReadAtLeastOneByte && Information == 0))
{
DPRINT("Serial: buffer empty. Don't wait more bytes\n");
break;
}
-
+
Status = KeWaitForMultipleObjects(
ObjectCount,
ObjectsArray,
FALSE,
(WorkItemData->UseIntervalTimeout && Information > 0) ? &WorkItemData->IntervalTimeout : NULL,
NULL);
-
+
if (Status == STATUS_TIMEOUT /* interval timeout */
|| Status == STATUS_WAIT_1) /* total timeout */
{
break;
}
}
-
+
/* stop total timeout timer */
if (WorkItemData->UseTotalTimeout)
KeCancelTimer(&TotalTimeoutTimer);
-
+
Irp->IoStatus.Information = Information;
if (Information == 0)
Irp->IoStatus.Status = STATUS_TIMEOUT;
{
PWORKITEM_DATA WorkItemData;
PIRP Irp;
-
+
DPRINT("Serial: SerialReadWorkItem() called\n");
-
+
WorkItemData = (PWORKITEM_DATA)pWorkItemData;
Irp = WorkItemData->Irp;
-
+
ReadBytes(DeviceObject, Irp, WorkItemData);
-
+
IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
+
IoFreeWorkItem(WorkItemData->IoWorkItem);
ExFreePoolWithTag(pWorkItemData, SERIAL_TAG);
}
PWORKITEM_DATA WorkItemData;
PIO_WORKITEM WorkItem;
NTSTATUS Status;
-
+
DPRINT("Serial: IRP_MJ_READ\n");
-
+
Stack = IoGetCurrentIrpStackLocation(Irp);
Length = Stack->Parameters.Read.Length;
Buffer = SerialGetUserBuffer(Irp);
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
+
if (Stack->Parameters.Read.ByteOffset.QuadPart != 0 || Buffer == NULL)
{
Status = STATUS_INVALID_PARAMETER;
goto ByeBye;
}
-
+
if (Length == 0)
{
Status = STATUS_SUCCESS;
goto ByeBye;
}
-
+
/* Allocate memory for parameters */
WorkItemData = ExAllocatePoolWithTag(PagedPool, sizeof(WORKITEM_DATA), SERIAL_TAG);
if (!WorkItemData)
}
RtlZeroMemory(WorkItemData, sizeof(WORKITEM_DATA));
WorkItemData->Irp = Irp;
-
+
/* Calculate time outs */
if (DeviceExtension->SerialTimeOuts.ReadIntervalTimeout == INFINITE &&
DeviceExtension->SerialTimeOuts.ReadTotalTimeoutMultiplier == INFINITE &&
{
ULONG TotalTimeout;
LARGE_INTEGER SystemTime;
-
+
WorkItemData->UseTotalTimeout = TRUE;
TotalTimeout = DeviceExtension->SerialTimeOuts.ReadTotalTimeoutConstant +
DeviceExtension->SerialTimeOuts.ReadTotalTimeoutMultiplier * Length;
TotalTimeout * 10000;
}
}
-
+
/* Pend IRP */
WorkItem = IoAllocateWorkItem(DeviceObject);
if (WorkItem)
IoMarkIrpPending(Irp);
return STATUS_PENDING;
}
-
+
/* insufficient resources, we can't pend the Irp */
CHECKPOINT;
Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, (PVOID)DeviceExtension->ComPort);
}
ReadBytes(DeviceObject, Irp, WorkItemData);
Status = Irp->IoStatus.Status;
-
+
IoReleaseRemoveLock(&DeviceExtension->RemoveLock, (PVOID)DeviceExtension->ComPort);
ByeBye:
PUCHAR ComPortBase;
KIRQL Irql;
NTSTATUS Status = STATUS_SUCCESS;
-
+
DPRINT("Serial: IRP_MJ_WRITE\n");
-
+
/* FIXME: pend operation if possible */
/* FIXME: use write timeouts */
-
+
Stack = IoGetCurrentIrpStackLocation(Irp);
Length = Stack->Parameters.Write.Length;
Buffer = SerialGetUserBuffer(Irp);
DeviceExtension = (PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
ComPortBase = (PUCHAR)DeviceExtension->BaseAddress;
-
+
if (Stack->Parameters.Write.ByteOffset.QuadPart != 0 || Buffer == NULL)
{
Status = STATUS_INVALID_PARAMETER;
goto ByeBye;
}
-
+
Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, (PVOID)DeviceExtension->ComPort);
if (!NT_SUCCESS(Status))
goto ByeBye;
-
+
/* push bytes into output buffer */
KeAcquireSpinLock(&DeviceExtension->OutputBufferLock, &Irql);
while (Information < Length)
}
KeReleaseSpinLock(&DeviceExtension->OutputBufferLock, Irql);
IoReleaseRemoveLock(&DeviceExtension->RemoveLock, (PVOID)DeviceExtension->ComPort);
-
+
/* send bytes */
SerialSendByte(NULL, DeviceExtension, NULL, NULL);
/* $Id:
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: drivers/dd/serial/serial.c
* PURPOSE: Serial driver loading/unloading
- *
+ *
* PROGRAMMERS: Hervé Poussineau (poussine@freesurf.fr)
*/
IN PUNICODE_STRING RegPath)
{
ULONG i;
-
+
DriverObject->DriverUnload = DriverUnload;
DriverObject->DriverExtension->AddDevice = SerialAddDevice;
-
+
for (i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++)
DriverObject->MajorFunction[i] = ForwardIrpAndForget;
DriverObject->MajorFunction[IRP_MJ_CREATE] = SerialCreate;
DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = SerialQueryInformation