On 1/19/10, Jeff Epler <[email protected]> wrote:
> What does linux parport_pc say about ports?
>
> Presumably the "base" and "base_hi" ports all have to be from the set of
> I/O ports named in lspci, so the "base_hi" ports must be the 1000 and
> 1010 addresses if the xxx8 addresses are the "base"s.


# insmod /lib/modules/2.6.30.5-rtai/kernel/drivers/parport/parport_pc.ko

# cat /proc/sys/dev/parport/parport1/base-addr
4120    4112

(these are 0x1018 and 0x1010)

# cat /proc/sys/dev/parport/parport2/base-addr
4104    4096

(these are 0x1008 and 0x1000)

I tried to write 0x80 to 0x1010 and 0x1000 but nothing changed.
I used the attached code to write. The program output:

# ./epp 0x1010
00
write 80
00

# ./epp 0x1000
00
write 80
00
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/io.h>

#define ECR_OFFSET	0x400
#define SPP_MODE	0x00
#define ECP_MODE	0x60
#define EPP_MODE	0x80

int main(int argc, char *argv[]) {
	unsigned int base;
	unsigned int ecr;
	unsigned char reg;

	if (argc != 2) {
		printf("No base address\n");
		exit(1);
	}
	// get the base address from the commandline
	base = strtol(argv[1], NULL, 16);

	// Extended Control Register address
	//ecr = base + ECR_OFFSET;
	ecr = base;

	// request to access to the address space
	if (iopl(3)) {
		perror("iopl");
		exit(2);
	}

	// request to write access to ECR 
	if (ioperm(ecr, 1, 1)) {
		perror("ioperm");
		exit(3);
	}

	// read from ECR
	reg = inb_p(ecr);
	printf("%02x\n", reg);

	// change mode
	reg = reg & 0x1F;
	reg = reg | EPP_MODE;
	printf("write %02x\n", reg);

	// write to ECR
	outb(reg, ecr);
	usleep(100000);

	// read from ECR
	reg = inb_p(ecr);
	printf("%02x\n", reg);

	// release to write privilege
	if (ioperm(ecr, 1, 0)) {
		perror("ioperm1");
		exit(4);
	}

	exit(0);
}
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to