pci epc mem use virtual mem
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
This commit is contained in:
parent
aa3568f353
commit
9d425eb521
|
@ -45,7 +45,7 @@
|
|||
*
|
||||
* Input Parameters:
|
||||
* epc - The EPC device
|
||||
* phys_addr - Physical address alloced to be matched
|
||||
* phys_addr - Virtual address alloced to be matched
|
||||
*
|
||||
* Returned Value:
|
||||
* Memory window alloced if success, NULL if failed
|
||||
|
@ -119,6 +119,7 @@ int pci_epc_mem_multi_init(FAR struct pci_epc_ctrl_s *epc,
|
|||
goto err;
|
||||
}
|
||||
|
||||
epc->mem[i].virt_base = windows[i].virt_base;
|
||||
epc->mem[i].phys_base = windows[i].phys_base;
|
||||
epc->mem[i].size = windows[i].size;
|
||||
epc->mem[i].page_size = windows[i].page_size;
|
||||
|
@ -152,7 +153,8 @@ err:
|
|||
*
|
||||
* Input Parameters:
|
||||
* epc - PCI EPC device
|
||||
* base - The physical base address of the PCI address window
|
||||
* virt - The virtual base address of the PCI address window
|
||||
* phys - The phys base address of the PCI address window
|
||||
* size - The PCI window size
|
||||
* page_size - Size of each window page
|
||||
*
|
||||
|
@ -160,12 +162,13 @@ err:
|
|||
* 0 if success, negative if failed
|
||||
****************************************************************************/
|
||||
|
||||
int pci_epc_mem_init(FAR struct pci_epc_ctrl_s *epc, uintptr_t base,
|
||||
size_t size, size_t page_size)
|
||||
int pci_epc_mem_init(FAR struct pci_epc_ctrl_s *epc, FAR void *virt,
|
||||
uintptr_t phys, size_t size, size_t page_size)
|
||||
{
|
||||
struct pci_epc_mem_window_s window;
|
||||
|
||||
window.phys_base = base;
|
||||
window.virt_base = virt;
|
||||
window.phys_base = phys;
|
||||
window.size = size;
|
||||
window.page_size = page_size;
|
||||
|
||||
|
@ -218,14 +221,16 @@ void pci_epc_mem_exit(FAR struct pci_epc_ctrl_s *epc)
|
|||
* is usually done to map the remote RC address into the local system.
|
||||
*
|
||||
* Input Parameters:
|
||||
* epc - The EPC device on which memory has to be allocated
|
||||
* size - The size of the address space that has to be allocated
|
||||
* epc - The EPC device on which memory has to be allocated
|
||||
* phys - The virtual addr
|
||||
* size - The size of the address space that has to be allocated
|
||||
*
|
||||
* Returned Value:
|
||||
* The memory address alloced if success, 0 if failed
|
||||
* The memory address alloced if success, NULL if failed
|
||||
****************************************************************************/
|
||||
|
||||
uintptr_t pci_epc_mem_alloc_addr(FAR struct pci_epc_ctrl_s *epc, size_t size)
|
||||
FAR void *pci_epc_mem_alloc_addr(FAR struct pci_epc_ctrl_s *epc,
|
||||
FAR uintptr_t *phys, size_t size)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
|
@ -241,11 +246,12 @@ uintptr_t pci_epc_mem_alloc_addr(FAR struct pci_epc_ctrl_s *epc, size_t size)
|
|||
|
||||
if (pageno != mem->pages)
|
||||
{
|
||||
return mem->phys_base + pageno * mem->page_size;
|
||||
*phys = mem->phys_base + pageno * mem->page_size;
|
||||
return mem->virt_base + pageno * mem->page_size;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -258,7 +264,7 @@ uintptr_t pci_epc_mem_alloc_addr(FAR struct pci_epc_ctrl_s *epc, size_t size)
|
|||
*
|
||||
* Input Parameters:
|
||||
* epc - The EPC device on which memory was allocated
|
||||
* phys_addr - The allocated physical address
|
||||
* phys_addr - The allocated virtual address
|
||||
* size - The size of the allocated address space
|
||||
*
|
||||
* Returned Value:
|
||||
|
|
|
@ -131,6 +131,7 @@ struct pci_epc_ops_s
|
|||
|
||||
/* struct pci_epc_mem_window_s - Address window of the endpoint controller
|
||||
*
|
||||
* virt_base: Virtual base address of the PCI address window
|
||||
* phys_base: Physical base address of the PCI address window
|
||||
* size: The size of the PCI address window
|
||||
* page_size: Size of each page
|
||||
|
@ -138,6 +139,7 @@ struct pci_epc_ops_s
|
|||
|
||||
struct pci_epc_mem_window_s
|
||||
{
|
||||
FAR void *virt_base;
|
||||
uintptr_t phys_base;
|
||||
size_t size;
|
||||
size_t page_size;
|
||||
|
@ -145,6 +147,7 @@ struct pci_epc_mem_window_s
|
|||
|
||||
/* struct pci_epc_mem_s - Address space of the endpoint controller
|
||||
*
|
||||
* virt_base: Virtual base address of the PCI address window
|
||||
* phys_base: Physical base address of the PCI address window
|
||||
* size: The size of the PCI address window
|
||||
* page_size: Size of each page
|
||||
|
@ -155,6 +158,7 @@ struct pci_epc_mem_window_s
|
|||
|
||||
struct pci_epc_mem_s
|
||||
{
|
||||
FAR void *virt_base;
|
||||
uintptr_t phys_base;
|
||||
size_t size;
|
||||
size_t page_size;
|
||||
|
@ -745,7 +749,8 @@ int pci_epc_mem_multi_init(FAR struct pci_epc_ctrl_s *epc,
|
|||
*
|
||||
* Input Parameters:
|
||||
* epc - PCI EPC device
|
||||
* base - The physical base address of the PCI address window
|
||||
* virt - The virtual addr
|
||||
* phys - The physical base address of the PCI address window
|
||||
* size - The PCI window size
|
||||
* page_size - Size of each window page
|
||||
*
|
||||
|
@ -753,8 +758,8 @@ int pci_epc_mem_multi_init(FAR struct pci_epc_ctrl_s *epc,
|
|||
* 0 if success, negative if failed
|
||||
****************************************************************************/
|
||||
|
||||
int pci_epc_mem_init(FAR struct pci_epc_ctrl_s *epc, uintptr_t base,
|
||||
size_t size, size_t page_size);
|
||||
int pci_epc_mem_init(FAR struct pci_epc_ctrl_s *epc, FAR void *virt,
|
||||
uintptr_t phys, size_t size, size_t page_size);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pci_epc_mem_exit
|
||||
|
@ -784,15 +789,16 @@ void pci_epc_mem_exit(FAR struct pci_epc_ctrl_s *epc);
|
|||
* is usually done to map the remote RC address into the local system.
|
||||
*
|
||||
* Input Parameters:
|
||||
* epc - The EPC device on which memory has to be allocated
|
||||
* size - The size of the address space that has to be allocated
|
||||
* epc - The EPC device on which memory has to be allocated
|
||||
* phys - The Physical addr
|
||||
* size - The size of the address space that has to be allocated
|
||||
*
|
||||
* Returned Value:
|
||||
* The memory address alloced if success, 0 if failed
|
||||
* The memory address alloced if success, NULL if failed
|
||||
****************************************************************************/
|
||||
|
||||
uintptr_t pci_epc_mem_alloc_addr(FAR struct pci_epc_ctrl_s *epc,
|
||||
size_t size);
|
||||
FAR void *pci_epc_mem_alloc_addr(FAR struct pci_epc_ctrl_s *epc,
|
||||
FAR uintptr_t *phys, size_t size);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pci_epc_mem_free_addr
|
||||
|
|
Loading…
Reference in New Issue