Hello!
I've been trying to play around with my parallel port which has no driver or something. According to my research in the internet, "pciconf -l -b" shows necessary information (i.e. the physical address) to mmap it.
The output is this:
The code I'm using for creating some output is this:
Write-operations seem to work, which means that the register's values will be 0 until reboot, but the port doesn't put out any signals. What's wrong?
I've been trying to play around with my parallel port which has no driver or something. According to my research in the internet, "pciconf -l -b" shows necessary information (i.e. the physical address) to mmap it.
The output is this:
...
none1@pci0:5:7:0: class=0x070101 card=0x21701c00 chip=0x21701c00 rev=0x0f hdr=0x00
bar [10] = type I/O Port, range 32, base 0xb010, size 8, enabled
bar [14] = type I/O Port, range 32, base 0xb000, size 8, enabled
...
The code I'm using for creating some output is this:
C:
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdint.h>
int main()
{
int fd;
unsigned char *p1;
unsigned char *p2;
int i;
fd = open("/dev/mem", O_RDWR);
if(fd == -1)
{
printf("error1\n");
return 1;
}
p1 = mmap(NULL, sysconf(_SC_PAGE_SIZE), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0xb000);
p2 = p1 + 10;
getchar();
for(i = 0; i < 4; i++)
{
printf("%X\n", *(p1 + i));
*(p1 + i) = 0;
printf("%X\n", *(p1 + i));
getchar();
}
return 0;
}
Write-operations seem to work, which means that the register's values will be 0 until reboot, but the port doesn't put out any signals. What's wrong?