How to get hardware address

Hi,
Can somebody tell me how to get hardware address under QNX4?

Thanks
Jackie

If your talking about the ethernet hardware address then run “netinfo
-l” - Physical Node ID is the h/w address of the adapter card.

If your talking about something else please elaborate.

  • KenR

Jackie wrote:

Hi,
Can somebody tell me how to get hardware address under QNX4?

Thanks
Jackie

Jackie;
Below is a working example of how I am communicating with a PCI memory
card. Basically what you do is use the functions in /usr/include/pci.h such
as _CA_PCI_Find_Device to find your pci card and store the info in a
structure of type _pci_config_regs (also declared in pci.h) using
_CA_PCI_Config_Read. Once you do that you must open a shared memory object
which absolutely must be named “Physical”. Then just mmap in your registers
from your PCI device and remember you must be logged in as root to access
the harware and you must compile using the -T1 flag for sufficient privity.
If you have any other questions you can feel free to E-mail me. I hope this
helps you out.

Chris

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/pci.h>
#include <sys/mman.h>
#include <sys/types.h>
#include “card.h”

//
/
Global Variables /
/
/

unsigned busnum, device, lastbus, version, hardware, index=0;
int fd, i, j, flags=MAP_SHARED;
int prots=PROT_READ | PROT_WRITE | PROT_NOCACHE;
volatile uint32_t *scr_mem_ptr1, *scr_mem_ptr;
volatile uint16_t *scr_reg_ptr;
uint32_t csr_base;
struct _pci_config_regs scr_reg;
unsigned DEVICE_ID=0x4750;
unsigned VENDOR_ID=0x11B0;

start_pci(void)
{
if(_CA_PCI_BIOS_Present (&lastbus, &version, &hardware) !=PCI_SUCCESS)
{
printf(“Error no PCI Bios found!!!\n”);
exit (0);
}

if (_CA_PCI_Find_Device(DEVICE_ID,VENDOR_ID,index,&busnum,
&device)!=PCI_SUCCESS){
printf (“PCI card not found!!\n”);
exit (0);
}

if (_CA_PCI_Read_Config_DWord(busnum,device,0,64,(char*)&scr_reg)
!=PCI_SUCCESS){
printf(“Could not read from PCI configuration space\n”);
exit(0);
}
fd=shm_open(“Physical”, O_RDWR, 0777);
if (fd==-1){
printf (“Physical file descriptor invalid\n”);
exit(-101);
}
/else{
printf (“File Descriptor open successful\n”);
}
/
scr_reg.Base_Address_Regs[1]=scr_reg.Base_Address_Regs[1]&0xFFFFFF00;
scr_reg.Base_Address_Regs[2]=scr_reg.Base_Address_Regs[2]&0xFFFFFF00;

scr_mem_ptr1=mmap(0,0x400000,prots,flags,fd,scr_reg.Base_Address_Regs[1]);
scr_mem_ptr=mmap(0,0x400000,prots,flags,fd,scr_reg.Base_Address_Regs[2]);
csr_base=(scr_reg.Base_Address_Regs[1]+0x800000);
scr_reg_ptr=mmap(0,0x1000,prots,flags,fd,csr_base);
if ((scr_mem_ptr||scr_reg_ptr)==-1){
printf (“Could not map apertures for PCI\n”);
fprintf (stderr, “Mmap failed: %s \n”, strerror(errno));
shm_unlink(“Physical”);
exit(-201);
}
else{
printf (“PCI scr_mem_pointer is at 0x%x and scr_reg_ptr 0x%x\n”,
scr_mem_ptr,scr_reg_ptr);
}
return(SUCCESS);
}

stop_pci(void)
{
shm_unlink(“Physical”);
munmap((void*)scr_mem_ptr1,0x400000);
munmap((void*)scr_mem_ptr,0x400000);
munmap((void*)scr_reg_ptr,0x1000);
return (SUCCESS);
}


Jackie <jackie@neontech.com> wrote in message news:98811j$j7q$1@inn.qnx.com

Hi,
Can somebody tell me how to get hardware address under QNX4?

Thanks
Jackie