📄 ddk_bus.c
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/* -*-C-*-
*
*
* Module Name: ceddk.c
*
* Abstract:
*
* WINCE device driver support routines. This file supports
* a very minimal subset of the routines from ntddk.h
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
* PARTICULAR PURPOSE.
*
* Release Status:OS005-SW-70002-r0p0-00REL0
* $Copyright:
* ----------------------------------------------------------------
* This confidential and proprietary software may be used only as
* authorised by a licensing agreement from ARM Limited
* (C) COPYRIGHT 2004 ARM Limited
* ALL RIGHTS RESERVED
* The entire notice above must be reproduced on all authorised
* copies and copies may only be made to the extent permitted
* by a licensing agreement from ARM Limited.
* ----------------------------------------------------------------
* File: ddk_bus.c,v
* Revision: 1.1
* ----------------------------------------------------------------
* $
*
*/
#include <windows.h>
#include <types.h>
#include <ceddk.h>
#include <arm_ddk.h>
#include <board.h>
#include <platform.h>
//
// I/O driver configuration functions.
//
ULONG HalGetBusDataByOffset(BUS_DATA_TYPE BusDataType, ULONG BusNumber,
ULONG SlotNumber, PVOID Buffer,
ULONG Offset, ULONG Length)
{
BUSDATA_PARMS parms;
DWORD dwBytesReturned;
BOOL RetCode;
parms.Function = IOCTL_HAL_GETBUSDATA;
parms.ReturnCode = 0;
parms.BusDataType = BusDataType;
parms.BusNumber = BusNumber;
parms.SlotNumber = SlotNumber;
parms.Buffer = Buffer;
parms.Offset = Offset;
parms.Length = Length;
RetCode = KernelIoControl(IOCTL_HAL_DDK_CALL, &parms, sizeof(parms),
NULL, 0, &dwBytesReturned);
if (RetCode) {
return parms.ReturnCode;
} else {
return 0;
}
}
ULONG HalSetBusDataByOffset(BUS_DATA_TYPE BusDataType, ULONG BusNumber,
ULONG SlotNumber, PVOID Buffer,
ULONG Offset, ULONG Length)
{
BUSDATA_PARMS parms;
DWORD dwBytesReturned;
BOOL RetCode;
parms.Function = IOCTL_HAL_SETBUSDATA;
parms.ReturnCode = 0;
parms.BusDataType = BusDataType;
parms.BusNumber = BusNumber;
parms.SlotNumber = SlotNumber;
parms.Buffer = Buffer;
parms.Offset = Offset;
parms.Length = Length;
RetCode = KernelIoControl(IOCTL_HAL_DDK_CALL, &parms, sizeof(parms),
NULL, 0, &dwBytesReturned);
if (RetCode) {
return parms.ReturnCode;
} else {
return 0;
}
}
BOOLEAN HalTranslateBusAddress(INTERFACE_TYPE InterfaceType,
ULONG BusNumber, PHYSICAL_ADDRESS BusAddress,
PULONG AddressSpace,
PPHYSICAL_ADDRESS TranslatedAddress)
{
// Not currently supported
return FALSE;
// Example PCI implementation:
/*
*TranslatedAddress = BusAddress;
if (*AddressSpace)
{
// This is a PCI IO address. Unlike PCI memory addresses, the range
// of PCI IO addresses we assign to a device's BAR aren't equal to
// their corresponding addresses on the system bus. We'll add the PA
// offset to rebase the address into the correct range.
//
// Since we can't hand back the VA and allow the caller to access the
// IO buffer directly, we'll override the AddressSpace flag and
// require that the caller calls MmMapIoSpace to get a virtual mapping
// of their devices IO space.
//
TranslatedAddress->LowPart += PHYS_PCI_IO_BASE;
*AddressSpace = 0;
}
return TRUE;
*/
}
/*++
Function: HalTranslateSystemAddress
Description: Translates a system physical address to a logical
(bus-relative) address, which can be handed off to a bus
controller (for DMA, for example).
Arguments:
InterfaceType - Bus interface type (controller address space).
BusNumber - Bus number.
SystemAddress - System physical address to be translated.
TranslatedAddress - Translated (logical) address.
Returns:
TRUE - Success.
FALSE - Failure.
Comments:
Not currently supported
--*/
NTHALAPI
BOOLEAN
HalTranslateSystemAddress(
IN INTERFACE_TYPE InterfaceType,
IN ULONG BusNumber,
IN PHYSICAL_ADDRESS SystemAddress,
OUT PPHYSICAL_ADDRESS TranslatedAddress
)
{
return FALSE;
// Example PCI implementation:
/*
if (!TranslatedAddress)
return(FALSE);
// Only support PCI at the moment...
if (InterfaceType != PCIBus) {
RETAILMSG(1, (TEXT("HalTranslateSystemAddress: only PCI devices are supported.\r\n")));
return(FALSE);
}
// Default case.
TranslatedAddress->QuadPart = SystemAddress.QuadPart;
return(TRUE);
*/
}
/* EOF ddk_bus.c */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -