Ejemplo n.º 1
0
static void sig_quit(int signo)
{
	unmap_memory(adc_mem_addr, S2MM_BUF_SIZE);
	unmap_memory(dac_mem_addr, MM2S_BUF_SIZE);
	unmap_memory(dma_reg_addr_wr, REG_SIZE);
	unmap_memory(dma_reg_addr_rd, REG_SIZE);
	free(p);
	close(spi_fd);
	exit(1);
}
Ejemplo n.º 2
0
	void lin_webcam_impl::release_safe(){

		unmap_memory();
		try
		{
			do_close();
		}
		catch(const webcam_exception & exc)
		{
		}
	}
Ejemplo n.º 3
0
int main(int argc, char** argv)
{
	int i;
	uint64_t base = 0;
	unsigned char *mmio, *stash;

	if (iopl(3) < 0) {
		fprintf(stderr, "Failed to gain ioperm: %s\n",
			strerror(errno));
		exit(1);
	}

	for (i=0; i<4; i++) {
		outb(0x24 + i, 0xcd6);
		base |= (unsigned) inb(0xcd7) << (8*i);
	}

	if ((base & 0x03) != 0x01) {
		printf("ACPI MMIO disabled\n");
		exit(1);
	} else {
		base &= ~0xfff;
		printf("ACPI MMIO enabled at %08lx\n", base);
	}

	fd = open("/dev/mem", O_RDONLY, 0);
	if (fd < 0) {
		fprintf(stderr, "Failed to gain memory access: %s\n",
			strerror(errno));
		exit(1);
	}

	mmio = map_memory(base);
	stash = calloc(1, MMIO_REGION_SZ);

	if (mmio == NULL || stash == NULL)
		exit(1);

	for (i=0; i<MMIO_REGION_SZ; i++) {
		stash[i] = mmio[i];
	}
	unmap_memory();
	close(fd);

	FILE * dd = fopen("mmio_dump.dd", "w");
	fwrite(stash, MMIO_REGION_SZ, 1, dd);
	fclose(dd);

	exit(0);
}
Ejemplo n.º 4
0
	void lin_webcam_impl::close()
	{
		unmap_memory();
		do_close();
	}