|
@@ -5,7 +5,8 @@
|
|
|
#include "common.h"
|
|
|
#include "kernels.h"
|
|
|
#include "gdrapi.h"
|
|
|
-#include "pcilib.h"
|
|
|
+#include <pcilib.h>
|
|
|
+#include <pcilib/kmem.h>
|
|
|
|
|
|
int main()
|
|
|
{
|
|
@@ -70,17 +71,39 @@ int main()
|
|
|
printf("Cannot open a context for pci\n");
|
|
|
exit( EXIT_FAILURE );
|
|
|
}
|
|
|
-
|
|
|
pciVa = pcilib_resolve_bar_address(pciCtx,PCILIB_BAR_DETECT, 0);
|
|
|
if( pciVa == NULL )
|
|
|
{
|
|
|
printf("Cannot resolve PCI physical adress to virtual\n");
|
|
|
exit( EXIT_FAILURE );
|
|
|
}
|
|
|
+
|
|
|
+ pcilib_kmem_handle_t* pciHandle;
|
|
|
+ pciHandle = pcilib_alloc_kernel_memory(pciCtx,PCILIB_KMEM_TYPE_CONSISTENT,1,64,4096,PCILIB_KMEM_USE_STANDARD,PCILIB_KMEM_FLAG_REUSE);
|
|
|
+ if( pciHandle == NULL )
|
|
|
+ {
|
|
|
+ printf("Cannot allocate PCI kernel memory\n");
|
|
|
+ exit( EXIT_FAILURE );
|
|
|
|
|
|
- pcilib_close(pciCtx);
|
|
|
-
|
|
|
+ }
|
|
|
+ volatile void* pciMemPtr;
|
|
|
+ uintptr_t pciBus;
|
|
|
+ pciMemPtr = pcilib_kmem_get_ua(pciCtx,pciHandle);
|
|
|
+ if( pciMemPtr == NULL )
|
|
|
+ {
|
|
|
+ printf("Cannot get PCI pointer to kernel memory\n");
|
|
|
+ exit( EXIT_FAILURE );
|
|
|
+ }
|
|
|
+ pciBus = pcilib_kmem_get_ba(pciCtx,pciHandle);
|
|
|
+ if( pciBus == 0 )
|
|
|
+ {
|
|
|
+ printf("Cannot get PCI Bus address on kernel memory\n");
|
|
|
+ exit( EXIT_FAILURE );
|
|
|
+ }
|
|
|
+
|
|
|
+ printf("pciMemPtr = %p\npciBus = %p or %lu\n",pciMemPtr,pciBus,pciBus);
|
|
|
|
|
|
+ pcilib_close(pciCtx);
|
|
|
|
|
|
/* Close everything */
|
|
|
assert_gdr( gdr_unmap(g,GPUMemHandle,va,(size_t) GPUProp.sharedMemPerBlock) );
|