当前位置: 技术问答>linux和unix
这个区就没有高手了吗?怎么我的2.6的内核缺这2个API,驱动无法编译了~~
来源: 互联网 发布时间:2016-01-29
本文导语: 谁知道2.6内核里没有remap_page_range和tq_struct这2个函数怎么编译通过啊~ 例如:内存映射不能用了啊,我改用remap_vmalloc_range,但是不知道怎么改搞还是映射不了~~ /****************************************************************************** ...
谁知道2.6内核里没有remap_page_range和tq_struct这2个函数怎么编译通过啊~
例如:内存映射不能用了啊,我改用remap_vmalloc_range,但是不知道怎么改搞还是映射不了~~
/******************************************************************************
*
* Function : PlxPciPhysicalMemoryMap
*
* Description: Maps physical memory to User virtual address space
*
******************************************************************************/
RETURN_CODE
PlxPciPhysicalMemoryMap(
DEVICE_EXTENSION *pdx,
PCI_MEMORY *pPciMem,
BOOLEAN bDeviceMem,
VOID *pOwner
)
{
int rc;
struct list_head *pList;
MAP_PARAMS_OBJECT *pMapObject;
// Verify physical address
if (pPciMem->PhysicalAddr == (U32)NULL)
{
DebugPrintf((
"ERROR - Invalid physical address (0x%08x), cannot map to user spacen",
pPciMem->PhysicalAddr
));
return ApiInvalidAddress;
}
spin_lock(
&(pdx->Lock_MapParamsList)
);
// Find the mapping parameters from the call to mmap
pList = pdx->List_MapParams.next;
// Find the object and remove it
while (pList != &(pdx->List_MapParams))
{
// Get the object
pMapObject =
list_entry(
pList,
MAP_PARAMS_OBJECT,
list
);
if ((pMapObject->pOwner == pOwner) &&
(pMapObject->vma.vm_start == pPciMem->UserAddr))
{
// Remove the object from the list
list_del(
pList
);
spin_unlock(
&(pdx->Lock_MapParamsList)
);
DebugPrintf((
"Found and removed map object (0x%08x) from listn",
(U32)pMapObject
));
// Set flags for I/O resource mapping
if (bDeviceMem)
pMapObject->vma.vm_flags |= VM_IO;
// Set the region as page-locked
pMapObject->vma.vm_flags |= VM_RESERVED;
/***********************************************************
* Attempt to map the region
*
* Note:
*
* The remap_page_range() function prototype was modified
* to add a parameter in kernel version 2.5.3. The new
* parameter is a pointer to the VMA structure. The kernel
* source in RedHat 9.0 (v2.4.20-8), however, also uses the
* new parameter. As a result, another #define is added if
* RedHat 9.0 kernel source is used.
**********************************************************/
#if ( (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,3)) ||
((LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20)) && defined(RED_HAT_LINUX_KERNEL)) )
rc =
remap_page_range(
&pMapObject->vma,
pMapObject->vma.vm_start,
pPciMem->PhysicalAddr,
pMapObject->vma.vm_end - pMapObject->vma.vm_start,
pMapObject->vma.vm_page_prot
);
#else
rc =
remap_page_range(
pMapObject->vma.vm_start,
pPciMem->PhysicalAddr,
pMapObject->vma.vm_end - pMapObject->vma.vm_start,
pMapObject->vma.vm_page_prot
);
#endif
if (rc != 0)
{
DebugPrintf((
"ERROR - Unable to map Physical address (0x%08x) ==> User spacen",
pPciMem->PhysicalAddr
));
rc = (int)ApiInsufficientResources;
}
else
{
DebugPrintf((
"Mapped Physical address (0x%08x) ==> User space (0x%08x)n",
pPciMem->PhysicalAddr, (U32)pMapObject->vma.vm_start
));
rc = (int)ApiSuccess;
}
// Release the object
kfree(
pMapObject
);
return (RETURN_CODE)rc;
}
// Jump to next item in the list
pList = pList->next;
}
spin_unlock(
&(pdx->Lock_MapParamsList)
);
DebugPrintf((
"ERROR - Map parameters object not found in listn"
));
return ApiInvalidData;
}
例如:内存映射不能用了啊,我改用remap_vmalloc_range,但是不知道怎么改搞还是映射不了~~
/******************************************************************************
*
* Function : PlxPciPhysicalMemoryMap
*
* Description: Maps physical memory to User virtual address space
*
******************************************************************************/
RETURN_CODE
PlxPciPhysicalMemoryMap(
DEVICE_EXTENSION *pdx,
PCI_MEMORY *pPciMem,
BOOLEAN bDeviceMem,
VOID *pOwner
)
{
int rc;
struct list_head *pList;
MAP_PARAMS_OBJECT *pMapObject;
// Verify physical address
if (pPciMem->PhysicalAddr == (U32)NULL)
{
DebugPrintf((
"ERROR - Invalid physical address (0x%08x), cannot map to user spacen",
pPciMem->PhysicalAddr
));
return ApiInvalidAddress;
}
spin_lock(
&(pdx->Lock_MapParamsList)
);
// Find the mapping parameters from the call to mmap
pList = pdx->List_MapParams.next;
// Find the object and remove it
while (pList != &(pdx->List_MapParams))
{
// Get the object
pMapObject =
list_entry(
pList,
MAP_PARAMS_OBJECT,
list
);
if ((pMapObject->pOwner == pOwner) &&
(pMapObject->vma.vm_start == pPciMem->UserAddr))
{
// Remove the object from the list
list_del(
pList
);
spin_unlock(
&(pdx->Lock_MapParamsList)
);
DebugPrintf((
"Found and removed map object (0x%08x) from listn",
(U32)pMapObject
));
// Set flags for I/O resource mapping
if (bDeviceMem)
pMapObject->vma.vm_flags |= VM_IO;
// Set the region as page-locked
pMapObject->vma.vm_flags |= VM_RESERVED;
/***********************************************************
* Attempt to map the region
*
* Note:
*
* The remap_page_range() function prototype was modified
* to add a parameter in kernel version 2.5.3. The new
* parameter is a pointer to the VMA structure. The kernel
* source in RedHat 9.0 (v2.4.20-8), however, also uses the
* new parameter. As a result, another #define is added if
* RedHat 9.0 kernel source is used.
**********************************************************/
#if ( (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,3)) ||
((LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20)) && defined(RED_HAT_LINUX_KERNEL)) )
rc =
remap_page_range(
&pMapObject->vma,
pMapObject->vma.vm_start,
pPciMem->PhysicalAddr,
pMapObject->vma.vm_end - pMapObject->vma.vm_start,
pMapObject->vma.vm_page_prot
);
#else
rc =
remap_page_range(
pMapObject->vma.vm_start,
pPciMem->PhysicalAddr,
pMapObject->vma.vm_end - pMapObject->vma.vm_start,
pMapObject->vma.vm_page_prot
);
#endif
if (rc != 0)
{
DebugPrintf((
"ERROR - Unable to map Physical address (0x%08x) ==> User spacen",
pPciMem->PhysicalAddr
));
rc = (int)ApiInsufficientResources;
}
else
{
DebugPrintf((
"Mapped Physical address (0x%08x) ==> User space (0x%08x)n",
pPciMem->PhysicalAddr, (U32)pMapObject->vma.vm_start
));
rc = (int)ApiSuccess;
}
// Release the object
kfree(
pMapObject
);
return (RETURN_CODE)rc;
}
// Jump to next item in the list
pList = pList->next;
}
spin_unlock(
&(pdx->Lock_MapParamsList)
);
DebugPrintf((
"ERROR - Map parameters object not found in listn"
));
return ApiInvalidData;
}
|
1.用remap_pfn_range替代
2.下半部的处理方式发生了大的变化,早期的某些机制被去除了,你用2.6中的任务队列机制来做,这就不仅仅是换一个函数名这么简单了,具体详见第三版
2.下半部的处理方式发生了大的变化,早期的某些机制被去除了,你用2.6中的任务队列机制来做,这就不仅仅是换一个函数名这么简单了,具体详见第三版