帮我看看这个程序,怎么有时侯有输出,有时侯没有输出,谢谢!

#include <sys/stat.h>
#include <signal.h>
#include <sys/procmgr.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/uio.h>
#include <dirent.h> //manipulate DIR

#include <time.h> //time structure
#include <sys/netmgr.h> //net manager routines
#include <sys/iofunc.h> //name_attach()
#include <sys/dispatch.h> //name_attach()
#include <sys/neutrino.h> //MsgReceive()…
#include <unistd.h> //delay(),
#include <inttypes.h> //clockcycles()…
#include <sys/syspage.h> //system info
#include <process.h> //fork()
#include <sys/mman.h> //memory manager
#include <fcntl.h> //flags definition
#include <sys/siginfo.h> //signal information
#include <sched.h> //scheduling operation
#include <hw/pci.h> //PCI functions
#include <hw/inout.h> //I/O operation
#include <pthread.h> //about threads
#include <stddef.h>
#include <ioctl.h> //for set udp unblock
#include <math.h>

#include <sys/socket.h> //socket communication
#include <arpa/inet.h> //htons(),etc.
#include <sys/socket.h> //socket communication
#include <sys/ioctl.h> //ioctl()…
#include <arpa/inet.h> //htons(),etc.
#include <netdb.h>
#include <netinet/udp.h>
#include <netinet/ip.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/types.h>

#include <limits.h>
#include <errno.h>
#include <mqueue.h>

typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned long dword;

typedef struct {
unsigned vendor_id;
unsigned device_id;
unsigned index;
unsigned offset;
}pciinfo;

void init_7434r( int base )
dword iobase;
void pf_perror(char *strerr, char *filename, int line);
dword find_pci_dev(pciinfo pcidev );
int main(void)
{
int voltage=4; // set voltage value
int i;
pciinfo DO_7434;
DO_7434.vendor_id = 0x144a;
DO_7434.device_id = 0x7434 ;
DO_7434.index = 0 ;
DO_7434.offset = 0x18 ;

ThreadCtl(_NTO_TCTL_IO, 0);

iobase = find_pci_dev( DO_7434); // for control do
if( iobase == -1 )
{
pf_perror(“find_pci_dev”, FILE, LINE);
return;
}
printf("\n7434 iobase is:%x\t \n",iobase);
init_7434r (0xdc00 );
delay(5000);
out8(iobase + 0x00, 0x00); printf(“ok0\n”);
out8(iobase + 0x01, 0x00); printf(“ok1\n”);
out8(iobase + 0x02, 0x00); printf(“ok2\n”);
out8(iobase + 0x03, 0x00); printf(“ok3\n”);
out8(iobase + 0x04, 0x00); printf(“ok4\n”);
out8(iobase + 0x05, 0x00); printf(“ok5\n”);
out8(iobase + 0x06, 0x00); printf(“ok6\n”);
out8(iobase + 0x07, 0x00); printf(“ok7\n”);


}





/*****************************************************
*

  • Function Name: find_pci_dev
  • Description: To find the iobase of a specifical card.
  • Input : pciinfo pcidev
  • Return : dword iobase
  •          -1-->Failure
    
  • Global Var :
  • ***************************************************/
    dword find_pci_dev(pciinfo pcidev )
    {
    struct pci_dev_info info;
    void *hdl;
    unsigned int buf;
    dword io_baseaddress = 0;

memset(&info, 0, sizeof(info));

//Connect to the PCI server
if (pci_attach(0) < 0)
{
perror(“pci_attach in lib file”);
return -1;
}

//attache a driver to a PCI device
info.VendorId = pcidev.vendor_id;
info.DeviceId = pcidev.device_id;
hdl = pci_attach_device (0, PCI_SHARE|PCI_INIT_ALL, pcidev.index, &info);
if (hdl == 0)
{
perror(“pci_attach_device in lib file”);
printf("%x\n",pcidev.device_id);
return -1;
}

if(pci_read_config(hdl,pcidev.offset,1,sizeof(buf),&buf) == PCI_SUCCESS)
io_baseaddress = PCI_IO_ADDR(buf);
else
{
perror(“read iobase register”);
printf("%x\n",pcidev.device_id);
return -1;
}

return(io_baseaddress);
}

void pf_perror(char *strerr, char *filename, int line)
{
printf("\n\n%s <%s,%d>:\n",strerr, filename, line-2);
perror("");//print system err info
return;
}

void init_7434r( int base )
{
out8(base + 0x00, 0xFF);
out8(base + 0x01, 0xFF);
out8(base + 0x02, 0xFF);
out8(base + 0x03, 0xFF);
out8(base + 0x04, 0xFF);
out8(base + 0x05, 0xFF);
out8(base + 0x06, 0xFF);
out8(base + 0x07, 0xFF);
}

先用mmap_device_io( size_t len, uint64_t io );映射一下,再out8试试
如:

port_handle=mmap_device_io(1, YOUR_IO);
out8(port_handle, 0xff);