Ejemplo n.º 1
0
Archivo: main.c Proyecto: orlv/fos
int connect_pci() {
  resmgr_attach("/dev/uip");
  char *buffer = malloc(RECV_BUF_SIZE);
  struct message msg;
  while (1) {
    msg.tid = 0;
    msg.recv_size = RECV_BUF_SIZE;
    msg.recv_buf = buffer;
    msg.flags = 0;
    receive(&msg);
    switch (msg.arg[0]) {
    case FS_CMD_ACCESS:
      msg.arg[0] = 1;
      msg.arg[1] = RECV_BUF_SIZE;
      msg.arg[2] = NO_ERR;
      break;

    case PCI_NOTIFY_NEW: {
      if(msg.arg[1] == 0x10EC && msg.arg[2] == 0x8139) {
        printf("Realtek 8139 starting up\n");
        pci_addr_t *addr = malloc(sizeof(pci_addr_t));
        memcpy(addr, buffer, sizeof(pci_addr_t));
        if(rtl8139_init(addr) < 0) {
          printf("Failure!\n");
          free(addr);
          return -1;
       } else {
          printf("Card started up successfully\n");
	  return 0;
       }
      }
      break;
    }
    default:
      msg.arg[0] = 0;
      msg.arg[2] = ERR_UNKNOWN_METHOD;
    }

    msg.send_size = 0;
    reply(&msg);
  }

}
Ejemplo n.º 2
0
int dev_bootstrap(void)
{
	rtl8139 *rtl;

	dprintf("rtl8139_dev_init: entry\n");

	// detect and setup the device
	if(rtl8139_detect(&rtl) < 0) {
		// no rtl8139 here
		dprintf("rtl8139_dev_init: no device found\n");
		return ERR_GENERAL;
	}

	rtl8139_init(rtl);

	// create device node
	devfs_publish_indexed_device("net/rtl8139", rtl, &rtl8139_hooks);

	return 0;
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
	rtl8139 *rtl;
	int fd;
	

	// detect and setup the device
	if(rtl8139_detect(&rtl) < 0) {
		// no rtl8139 here
		printf("%s","rtl8139_dev_init: no device found\n");
		return 0;
	}
	
	rtl8139_init(rtl);

//	fd = sys_open("/dev/net/rtl8139/0", "", STREAM_TYPE_DEVICE);
//	if(fd < 0) {
//		panic("rtl8139_dev_init: could not open %s\n", "/dev/net/rtl8139/0");
//	}
//	sys_ioctl(fd, 87912, (void *)rtl, 4);
//	sys_close(fd);
	return 0;
}