Exemple #1
0
int main(void)
{
    u8 *vid = (u8 *) 0x00000000;
    run(MM_PID,MIF_DMAMAP,0xE0000000,0xE0000000,0x4096);
    outw(0x00,0x1ce);
    u16 i = inw(0x1cf);
    if(i < 0xb0c0 || i > 0xb0c6)
        printf("FLASE\n");
    outw(0xb0c4,0x1cf);
    i = inw(0x1cf);
    outw(0x04,0x1ce);
    outw(0x00,0x1cf);

    outw(0x01,0x1ce);
    outw(1024,0x1cf);

    outw(0x02,0x1ce);
    outw(768,0x1cf);

    outw(0x03,0x1ce);
    outw(32,0x1cf);

    outw(0x07,0x1ce);
    outw(4096,0x1cf);

    outw(0x04,0x1ce);
    outw(0x41,0x1cf);

    memset((void*)0xe0000000,0xff,1 << 24);
    pci_scan(bochas_scan_pci,-1,&vid);
    printf("MEMORY : %p\n",vid);
    while(1);
    return 0;
}
Exemple #2
0
static int init(void) {
	pci_scan(&find_rtl, -1, &rtl_device_pci);
	if (!rtl_device_pci) {
		debug_print(ERROR, "No RTL 8139 found?");
		return 1;
	}
	init_rtl();
	return 0;
}
Exemple #3
0
void pci_dump(
  FILE *fp
)
{
  if ( !fp )
    fp = stdout;
  fprintf(
    fp,
    "BUS:SLOT:FUN VENDOR:DEV_ID   CMD  STAT   BASE_ADDR0 BASE_ADDR1 INTn IRQ_LINE\n"
  );
  pci_scan(0, dump_dev_helper, fp);
}
Exemple #4
0
int bochs_init(void) {

	outw(VBE_DISPI_IOPORT_INDEX, 0);
	
	int n = inw(VBE_DISPI_IOPORT_DATA);
	if(!(CHECK_BGA(n)))
		return E_ERR;


	__lfbptr = 0;

	void pci_func(uint32_t device, uint16_t vendor_id, uint16_t device_id, void* arg) {
		
		if(likely(!(
			(vendor_id == 0x1234) &&
			(device_id == 0x1111)
		))) return;
		
		__lfbptr = (uintptr_t) pci_read_field(device, PCI_BAR0, 4);
	}

	int i;
	for(i = 0; i < 65536 && !__lfbptr; i++)
		pci_scan(&pci_func, i, NULL);

	if(!__lfbptr)
		return E_ERR;


	#define ALIGN(x)										\
		(((x) + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1))
	
	if(__lfbptr) {
		uintptr_t frame = ALIGN(__lfbptr) - PAGE_SIZE;
		uintptr_t end = ALIGN(frame + BGA_VIDEORAM_SIZE);

		for(; frame < end; frame += PAGE_SIZE)
			map_page(frame, frame, 1);
	} else
		return E_ERR;
	


	fbdev->name = "Bochs VBE Extensions";
	fbdev->setvideomode = bga_setvideomode;
	return E_OK;
#else
int bga_init(void) {
	return E_ERR;
#endif
}
Exemple #5
0
int32_t kernel_main(multiboot_t *mboot_ptr)
{
    textmode_init();

    printf("                   _____ _                 _       ____   _____ \n                  / ____(_)               | |     / __ \\ / ____|\n                 | (___  _ _ __ ___  _ __ | | ___| |  | | (___  \n                  \\___ \\| | '_ ` _ \\| '_ \\| |/ _ \\ |  | |\\___ \\ \n                  ____) | | | | | | | |_) | |  __/ |__| |____) |\n                 |_____/|_|_| |_| |_| .__/|_|\\___|\\____/|_____/ \n                                    | |                         \n                                    |_|                         \n");
    textmode_set_colors(COLOR_RED, COLOR_BLACK);
    textmode_move_cursor(19, 6);
    printf("Version %i.%i.%i", VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD);
    textmode_move_cursor(19, 7);
    printf("Built %s", VERSION_DATE);
    textmode_set_colors(COLOR_GREEN, COLOR_BLACK);
    textmode_move_cursor(41, 6);
    printf("Written by Joe Biellik");
    textmode_set_colors(COLOR_LTGRAY, COLOR_BLACK);
    textmode_move_cursor(0, 9);

    fpu_init();
    gdt_init();
    idt_init();

    __asm __volatile__("sti"); // Start interrupts

    pit_init();
    serial_init();

    // Test serial
    int8_t buffer[50];
    sprintf(buffer, "SimpleOS %i.%i.%i (%s)\n", VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD, VERSION_DATE);
    serial_write(SERIAL_PORT_A, buffer);

    // Test RTC
    datetime_t *dt = 0;
    rtc_get(dt);
    printf("Started at %02i-%02i-%02i %02i:%02i:%02i\n\n", dt->year, dt->month, dt->day, dt->hour, dt->min, dt->sec);

    // Test CPU
    cpu_detect();

    printf("\n");

    // Test PCI
    pci_scan();

    for (;;);

    return 0x12345678;
}
Exemple #6
0
int VIDIX_NAME(vixProbe)(int verbose,int force)
{
#if 0
    int err = 0;
#ifdef DEMO_DRIVER
    err = ENOSYS;
#endif
    
    printf(GENFB_MSG"probe\n");

    fd = open("/dev/fb0", O_RDWR);
    if (fd < 0)
    {
	printf(GENFB_MSG"Error occured durint open: %s\n", strerror(errno));
	err = errno;
    }
    
    probed = 1;

    return(err);
#else
  pciinfo_t lst[MAX_PCI_DEVICES];
  unsigned i,num_pci;
  int err;
  err = pci_scan(lst,&num_pci);
  if(err)
  {
    printf(GENFB_MSG"Error occured during pci scan: %s\n",strerror(err));
    return err;
  }
  else
  {
    err = ENXIO;
    for(i=0;i<num_pci;i++)
    {
	if(verbose)
	    printf(GENFB_MSG" Found chip [%04X:%04X] '%s' '%s'\n"
	    ,lst[i].vendor
	    ,lst[i].device
	    ,pci_vendor_name(lst[i].vendor)
	    ,pci_device_name(lst[i].vendor,lst[i].device));
    }
  }
  return ENOSYS;
#endif
}
Exemple #7
0
static int pci_getinfo(lua_State *L)
{
  struct pci_domain *pci_domain;
  struct pci_device *pci_device;
  int pci_dev = 1;

  pci_domain = pci_scan();

  lua_newtable(L);	/* list of busses */

  for_each_pci_func(pci_device, pci_domain) {
    lua_pushnumber(L, pci_dev++);

    lua_newtable(L); /* device infos */

    lua_pushstring(L, "bus");
    lua_pushnumber(L, __pci_bus);
    lua_settable(L,-3);

    lua_pushstring(L, "slot");
    lua_pushnumber(L, __pci_slot);
    lua_settable(L,-3);

    lua_pushstring(L, "func");
    lua_pushnumber(L, __pci_func);
    lua_settable(L,-3);

    lua_pushstring(L, "vendor");
    lua_pushnumber(L, pci_device->vendor);
    lua_settable(L,-3);

    lua_pushstring(L, "product");
    lua_pushnumber(L, pci_device->product);
    lua_settable(L,-3);

    lua_pushstring(L, "sub_vendor");
    lua_pushnumber(L, pci_device->sub_vendor);
    lua_settable(L,-3);

    lua_pushstring(L, "sub_product");
    lua_pushnumber(L, pci_device->sub_product);
    lua_settable(L,-3);

    lua_settable(L,-3); /* end device infos */
  }
Exemple #8
0
static int cyberblade_probe(int verbose, int force)
{
	pciinfo_t lst[MAX_PCI_DEVICES];
	unsigned i,num_pci;
	int err;
	err = pci_scan(lst,&num_pci);
	if(err)
	{
		printf("[cyberblade] Error occurred during pci scan: %s\n",strerror(err));
		return err;
	}
	else
	{
		err = ENXIO;
		for(i=0; i < num_pci; i++)
		{
			if(lst[i].vendor == VENDOR_TRIDENT)
			{
				int idx;
				const char *dname;
				idx = find_chip(lst[i].device);
				if(idx == -1)
					continue;
				dname = pci_device_name(VENDOR_TRIDENT, lst[i].device);
				dname = dname ? dname : "Unknown chip";
				printf("[cyberblade] Found chip: %s\n", dname);
#if 0
                                if ((lst[i].command & PCI_COMMAND_IO) == 0)
				{
					printf("[cyberblade] Device is disabled, ignoring\n");
					continue;
				}
#endif
				cyberblade_cap.device_id = lst[i].device;
				err = 0;
				memcpy(&pci_info, &lst[i], sizeof(pciinfo_t));
				break;
			}
		}
	}

	if(err && verbose) printf("[cyberblade] Can't find chip\n");
		return err;
}
Exemple #9
0
int main(int argc, char *argv[])
{
    struct match *list, *match;
    struct pci_domain *pci_domain;

    openconsole(&dev_null_r, &dev_stdcon_w);
    pci_domain = pci_scan();

    if (pci_domain) {
	list = parse_config(argc < 2 ? NULL : argv[1]);

	match = find_pci_device(pci_domain, list);

	if (match)
	    syslinux_run_command(match->filename);
    }

    /* On error, return to the command line */
    fputs("Error: no recognized network card found!\n", stderr);
    return 1;
}
Exemple #10
0
int main( void )
{
  pciinfo_t lst[MAX_PCI_DEVICES];
  unsigned i,num_pci;
  int err;
  err = pci_scan(lst,&num_pci);
  if(err)
  {
    printf("Error occurred during pci scan: %s\n",strerror(err));
    return EXIT_FAILURE;
  }
  else
  {
    printf(" Bus:card:func vend:dev  command base0   :base1   :base2   :baserom\n");
    for(i=0;i<num_pci;i++)
      printf("%04X:%04X:%04X %04X:%04X %04X    %08X:%08X:%08X:%08X\n"
    	    ,lst[i].bus,lst[i].card,lst[i].func
	    ,lst[i].vendor,lst[i].device,lst[i].command
	    ,lst[i].base0,lst[i].base1,lst[i].base2,lst[i].baserom);
  }
  return EXIT_SUCCESS;
}
Exemple #11
0
static int nv_probe(int verbose, int force){
    pciinfo_t lst[MAX_PCI_DEVICES];
    unsigned i,num_pci;
    int err;

    if (force)
	    printf("[nvidia_vid]: warning: forcing not supported yet!\n");
    err = pci_scan(lst,&num_pci);
    if(err){
	printf("[nvidia_vid] Error occurred during pci scan: %s\n",strerror(err));
	return err;
    }
    else {
	err = ENXIO;
	for(i=0; i < num_pci; i++){
	    if(lst[i].vendor == VENDOR_NVIDIA2 || lst[i].vendor == VENDOR_NVIDIA){
		int idx;
		const char *dname;
		idx = find_chip(lst[i].device);
		if(idx == -1)
		    continue;
		dname = pci_device_name(lst[i].vendor, lst[i].device);
		dname = dname ? dname : "Unknown chip";
		printf("[nvidia_vid] Found chip: %s\n", dname);
		if ((lst[i].command & PCI_COMMAND_IO) == 0){
			printf("[nvidia_vid] Device is disabled, ignoring\n");
			continue;
		}
		nvidia_cap.device_id = lst[i].device;
		err = 0;
		memcpy(&pci_info, &lst[i], sizeof(pciinfo_t));
		break;
	    }
	}
    }
    if(err && verbose) printf("[nvidia_vid] Can't find chip\n");
    return err;
}
Exemple #12
0
int pci_find_device(
  uint16_t vendorid,
  uint16_t deviceid,
  int      instance,
  int     *bus,
  int     *device,
  int     *function
)
{
  pci_scan_arg_t  scan;

  scan.instance   = instance;
  scan.vendor_id  = vendorid;
  scan.device_id  = deviceid;

  if ( pci_scan(0, find_dev_helper, (void*)&scan) != 0 ) {
    *bus      = scan.bus;
    *device   = scan.device;
    *function = scan.function;
    return 0;
  }
  return -1;
}
Exemple #13
0
int init(void) {
    
    void find_pci(uint32_t device, uint16_t venid, uint16_t devid, void* data) {
        if((venid == 0x1022) && (devid == 0x2000))
            *((uint32_t*) data) = device;
    }

    int pci = 0;
    pci_scan(&find_pci, -1, &pci);
    if(!pci) {
        kprintf(ERROR "pcnet: pci device not found!\n");
        return -1;
    }

    struct pcnet* dev = (struct pcnet*) kmalloc(sizeof(struct pcnet), GFP_KERNEL);
    struct ethif* eth = (struct ethif*) kmalloc(sizeof(struct ethif), GFP_KERNEL);

    memset(dev, 0, sizeof(struct pcnet));
    memset(eth, 0, sizeof(struct ethif));


    eth->internals = (void*) dev;
    dev->pci = pci;



    spinlock_init(&dev->lock);

    dev->buf = (uintptr_t) kvalloc(0x10000, GFP_KERNEL);
    dev->bufp = (uintptr_t) V2P((void*) dev->buf);

    uint16_t cmd = pci_read_field(dev->pci, PCI_COMMAND, 4);
    if(!(cmd & (1 << 2))) 
        pci_write_field(dev->pci, PCI_COMMAND, 4, cmd | (1 << 2));


    dev->irq = pci_read_field(dev->pci, PCI_INTERRUPT_LINE, 1);
    dev->io = pci_read_field(dev->pci, PCI_BAR0, 4) & 0xFFFFFFF0;
    dev->mem = pci_read_field(dev->pci, PCI_BAR1, 4) & 0xFFFFFFF0;

    
    kprintf(LOG "pcnet: irq: %d, io: %p, mem: %p\n", dev->irq, dev->io, dev->mem);

    int i;
    for(i = 0; i < 6; i++)
        eth->address[i] = inb(dev->io + i);

    

    pcnet_irqno = dev->irq;   /* FIXME: fix current_irq */

    irq_enable(dev->irq, pcnet_irq);
    irq_set_data(dev->irq, dev);


    eth->low_level_init = pcnet_init;
    eth->low_level_startoutput = pcnet_startoutput;
    eth->low_level_output = pcnet_output;
    eth->low_level_endoutput = pcnet_endoutput;
    eth->low_level_startinput = pcnet_startinput;
    eth->low_level_input = pcnet_input;
    eth->low_level_endinput = pcnet_endinput;
    eth->low_level_input_nomem = pcnet_input_nomem;


    IP4_ADDR(&eth->ip, 10, 0, 2, 15);
    IP4_ADDR(&eth->nm, 255, 255, 255, 0);
    IP4_ADDR(&eth->gw, 10, 0, 2, 2);

    struct netif* netif = (struct netif*) kmalloc(sizeof(struct netif), GFP_KERNEL);
    dev->netif = netif;

    if(!netif_add(netif, &eth->ip, &eth->nm, &eth->gw, eth, ethif_init, ethernet_input)) {
        kprintf(ERROR "pcnet: netif_add() failed\n");

        kfree(dev);
        kfree(eth);
        kfree(netif);
        return -1;
    }

    netif_set_default(netif);
    netif_set_up(netif);

    return 0;
}
Exemple #14
0
void nic_scan_all()
{
     pci_scan(scan_all_pci, PCI_SCAN_ALL, 0);
}