/* Create SB-1 system control devices */
int dev_sb1_init(vm_instance_t *vm)
{   
   struct sb1_data *d;

   /* allocate private data structure */
   if (!(d = malloc(sizeof(*d)))) {
      fprintf(stderr,"SB1: out of memory\n");
      return(-1);
   }

   memset(d,0,sizeof(*d));

   vm_object_init(&d->vm_obj);
   d->vm_obj.name = "sb1_sysctrl";
   d->vm_obj.data = d;
   d->vm_obj.shutdown = (vm_shutdown_t)dev_sb1_shutdown;

   dev_init(&d->dev);
   d->dev.name      = "sb1_sysctrl";
   d->dev.priv_data = d;
   d->dev.phys_addr = 0x10000000ULL;
   d->dev.phys_len  = 0x60000;
   d->dev.handler   = dev_sb1_access;

   /* Map this device to the VM */
   vm_bind_device(vm,&d->dev);  
   vm_object_add(vm,&d->vm_obj);
   return(0);
}
/* remote control device */
int dev_remote_control_init(vm_instance_t *vm,m_uint64_t paddr,m_uint32_t len)
{
   struct remote_data *d;

   if (!(d = malloc(sizeof(*d)))) {
      fprintf(stderr,"Remote Control: unable to create device.\n");
      return(-1);
   }

   memset(d,0,sizeof(*d));

   vm_object_init(&d->vm_obj);
   d->vm_obj.name = "remote_ctrl";
   d->vm_obj.data = d;
   d->vm_obj.shutdown = (vm_shutdown_t)dev_remote_control_shutdown;

   dev_init(&d->dev);
   d->dev.name      = "remote_ctrl";
   d->dev.phys_addr = paddr;
   d->dev.phys_len  = len;
   d->dev.handler   = dev_remote_control_access;
   d->dev.priv_data = d;

   /* Map this device to the VM */
   vm_bind_device(vm,&d->dev);
   vm_object_add(vm,&d->vm_obj);
   return(0);
}
Exemple #3
0
/* Create a NS16552 device */
int dev_ns16552_init(vm_instance_t *vm,m_uint64_t paddr,m_uint32_t len,
                     u_int reg_div,u_int irq,vtty_t *vtty_A,vtty_t *vtty_B)
{  
   struct ns16552_data *d;

   /* Allocate private data structure */
   if (!(d = malloc(sizeof(*d)))) {
      fprintf(stderr,"NS16552: out of memory\n");
      return(-1);
   }

   memset(d,0,sizeof(*d));
   d->vm  = vm;
   d->irq = irq;
   d->reg_div = reg_div;
   d->channel[0].vtty = vtty_A;
   d->channel[1].vtty = vtty_B;
   d->line_control_reg = 0;
   d->div_latch = 0;
   d->baud_divisor=0;
   
   vm_object_init(&d->vm_obj);
   d->vm_obj.name = "ns16552";
   d->vm_obj.data = d;
   d->vm_obj.shutdown = (vm_shutdown_t)dev_ns16552_shutdown;

   /* Set device properties */
   dev_init(&d->dev);
   d->dev.name      = "ns16552";
   d->dev.phys_addr = paddr;
   d->dev.phys_len  = len;
   d->dev.handler   = dev_ns16552_access;
   d->dev.priv_data = d;

   vtty_A->priv_data = d;
   vtty_B->priv_data = d;
   vtty_A->read_notifier = tty_con_input;
   vtty_B->read_notifier = tty_aux_input;

   /* Trigger periodically a dummy IRQ to flush buffers */
   d->tid = ptask_add((ptask_callback)tty_trigger_dummy_irq,d,NULL);

   /* Map this device to the VM */
   vm_bind_device(vm,&d->dev);   
   vm_object_add(vm,&d->vm_obj);
   return(0);
}
/* Initialize a RAM zone */
int dev_ram_init(vm_instance_t *vm,char *name,int use_mmap,int delete_file,
                 char *alternate_name,int sparse,
                 m_uint64_t paddr,m_uint32_t len)
{
   struct ram_data *d;

   /* allocate the private data structure */
   if (!(d = malloc(sizeof(*d)))) {
      fprintf(stderr,"RAM: unable to create device.\n");
      return(-1);
   }

   memset(d,0,sizeof(*d));
   d->delete_file = delete_file;

   vm_object_init(&d->vm_obj);
   d->vm_obj.name = name;
   d->vm_obj.data = d;
   d->vm_obj.shutdown = (vm_shutdown_t)dev_ram_shutdown;

   if (use_mmap) {
      if (!alternate_name)
         d->filename = vm_build_filename(vm,name);
      else
         d->filename = strdup(alternate_name);

      if (!d->filename) {
         fprintf(stderr,"RAM: unable to create filename.\n");
         goto err_filename;
      }
   }

   if (!(d->dev = dev_create_ram(vm,name,sparse,d->filename,paddr,len))) {
      fprintf(stderr,"RAM: unable to create device.\n");
      goto err_dev_create;
   }

   vm_object_add(vm,&d->vm_obj);
   return(0);

 err_dev_create:
   free(d->filename);
 err_filename:
   free(d);
   return(-1);
}
/*
 * dev_c3600_iofpga_init()
 */
int dev_c3600_iofpga_init(c3600_t *router,m_uint64_t paddr,m_uint32_t len)
{
   vm_instance_t *vm = router->vm;
   struct c3600_iofpga_data *d;

   /* Allocate private data structure */
   if (!(d = malloc(sizeof(*d)))) {
      fprintf(stderr,"IO_FPGA: out of memory\n");
      return(-1);
   }

   memset(d,0,sizeof(*d));
   d->router = router;

   vm_object_init(&d->vm_obj);
   d->vm_obj.name = "io_fpga";
   d->vm_obj.data = d;
   d->vm_obj.shutdown = (vm_shutdown_t)dev_c3600_iofpga_shutdown;

   /* Set device properties */
   dev_init(&d->dev);
   d->dev.name      = "io_fpga";
   d->dev.phys_addr = paddr;
   d->dev.phys_len  = len;
   d->dev.priv_data = d;

   switch(router->chassis_driver->chassis_id) {
      case 3620:
      case 3640:
         d->dev.handler = dev_c3620_c3640_iofpga_access;
         break;
      case 3660:
         d->dev.handler = dev_c3660_iofpga_access;
         break;
      default:
         fprintf(stderr,"C3600 '%s': invalid chassis ID %d\n",
                 router->vm->name,router->chassis_driver->chassis_id);
         free(d);
         return(-1);
   }

   /* Map this device to the VM */
   vm_bind_device(router->vm,&d->dev);
   vm_object_add(vm,&d->vm_obj);
   return(0);
}
Exemple #6
0
/* ARGSUSED*/
static void
vm_mem_init(void *dummy)
{
	/*
	 * Initializes resident memory structures. From here on, all physical
	 * memory is accounted for, and we use only virtual addresses.
	 */
	vm_set_page_size();
	vm_page_startup();

	/*
	 * Initialize other VM packages
	 */
	vm_object_init();
	vm_map_startup();
	kmem_init();
	pmap_init();
}
/* Initialize a ghosted RAM zone */
int dev_ram_ghost_init(vm_instance_t *vm,char *name,int sparse,char *filename,
                       m_uint64_t paddr,m_uint32_t len)
{
   struct ram_data *d;

   /* allocate the private data structure */
   if (!filename || !(d = malloc(sizeof(*d)))) {
      fprintf(stderr,"RAM_ghost: unable to create device.\n");
      return(-1);
   }

   memset(d,0,sizeof(*d));
   d->delete_file = FALSE;

   if (!(d->filename = strdup(filename)))
      goto err_filename;

   vm_object_init(&d->vm_obj);
   d->vm_obj.name = name;
   d->vm_obj.data = d;
   d->vm_obj.shutdown = (vm_shutdown_t)dev_ram_shutdown;

   if (!(d->dev = dev_create_ghost_ram(vm,name,sparse,d->filename,
                                       paddr,len))) 
   {
      fprintf(stderr,"RAM_ghost: unable to create device.\n");
      goto err_dev_create;
   }

   vm_object_add(vm,&d->vm_obj);
   return(0);

 err_dev_create:
   free(d->filename);
 err_filename:
   free(d);
   return(-1);
}
Exemple #8
0
/*
 * dev_c2600_iofpga_init()
 */
int dev_c2600_iofpga_init(c2600_t *router,m_uint64_t paddr,m_uint32_t len)
{
   vm_instance_t *vm = router->vm;
   struct c2600_iofpga_data *d;

   /* Allocate private data structure */
   if (!(d = malloc(sizeof(*d)))) {
      fprintf(stderr,"IO_FPGA: out of memory\n");
      return(-1);
   }

   memset(d,0,sizeof(*d));
   d->router = router;

   vm_object_init(&d->vm_obj);
   d->vm_obj.name = "io_fpga";
   d->vm_obj.data = d;
   d->vm_obj.shutdown = (vm_shutdown_t)dev_c2600_iofpga_shutdown;

   /* Set device properties */
   dev_init(&d->dev);
   d->dev.name      = "io_fpga";
   d->dev.phys_addr = paddr;
   d->dev.phys_len  = len;
   d->dev.priv_data = d;
   d->dev.handler   = dev_c2600_iofpga_access;

   /* Initialize the MPC860 SPI TX callback to read mainboard WIC EEPROMs */
   mpc860_spi_set_tx_callback(router->mpc_data,
                              dev_c2600_mpc860_spi_tx_callback,d);
                              
   /* Map this device to the VM */
   vm_bind_device(router->vm,&d->dev);
   vm_object_add(vm,&d->vm_obj);
   return(0);
}
Exemple #9
0
/* Initialize an SRAM device */
int dev_c7200_sram_init(vm_instance_t *vm,char *name,
                        m_uint64_t paddr,m_uint32_t len,
                        struct pci_bus *pci_bus,int pci_device)
{
   m_uint64_t alias_paddr;
   struct sram_data *d;

   /* Allocate the private data structure for SRAM */
   if (!(d = malloc(sizeof(*d)))) {
      fprintf(stderr,"dev_c7200_sram_init (%s): out of memory\n",name);
      return(-1);
   }

   memset(d,0,sizeof(*d));

   vm_object_init(&d->vm_obj);
   d->vm_obj.name = name;
   d->vm_obj.data = d;
   d->vm_obj.shutdown = (vm_shutdown_t)dev_c7200_sram_shutdown;

   if (!(d->filename = vm_build_filename(vm,name)))
      return(-1);

   /* add as a pci device */
   d->pci_dev = pci_dev_add_basic(pci_bus,name,
                                  PCI_VENDOR_SRAM,PCI_PRODUCT_SRAM,
                                  pci_device,0);

   alias_paddr = 0x100000000ULL + paddr;
   
   /* create the standard RAM zone */
   if (!(d->dev = dev_create_ram(vm,name,FALSE,d->filename,paddr,len))) {
      fprintf(stderr,"dev_c7200_sram_init: unable to create '%s' file.\n",
              d->filename);
      return(-1);
   }

   /* create the RAM alias */
   if (!(d->alias_dev_name = dyn_sprintf("%s_alias",name))) {
      fprintf(stderr,"dev_c7200_sram_init: unable to create alias name.\n");
      return(-1);
   }

   d->alias_dev = dev_create_ram_alias(vm,d->alias_dev_name,name,
                                       alias_paddr,len);

   if (!d->alias_dev) {
      fprintf(stderr,"dev_c7200_sram_init: unable to create alias device.\n");
      return(-1);
   }

   /* create the byte-swapped zone (used with Galileo DMA) */
   if (!(d->bs_dev_name = dyn_sprintf("%s_bswap",name))) {
      fprintf(stderr,"dev_c7200_sram_init: unable to create BS name.\n");
      return(-1);
   }

   if (dev_bswap_init(vm,d->bs_dev_name,paddr+0x800000,len,paddr) == -1) {
      fprintf(stderr,"dev_c7200_sram_init: unable to create BS device.\n");
      return(-1);
   }
   
   d->bs_obj = vm_object_find(vm,d->bs_dev_name);
   return(0);
}    
Exemple #10
0
void vm_mem_init(void)
{
	vm_object_init();
	memory_object_proxy_init();
	vm_page_info_all();
}
/* Create a new MV64460 controller */
int dev_mv64460_init(vm_instance_t *vm,char *name,
                     m_uint64_t paddr,m_uint32_t len)
{
   struct mv64460_data *d;
   int i;

   if (!(d = malloc(sizeof(*d)))) {
      fprintf(stderr,"mv64460: unable to create device data.\n");
      return(-1);
   }

   memset(d,0,sizeof(*d));
   pthread_mutex_init(&d->lock,NULL);
   d->name = name;
   d->vm = vm;
   d->bus[0] = vm->pci_bus[0];
   d->bus[1] = vm->pci_bus[1];

   for(i=0;i<MV64460_SDMA_CHANNELS;i++)
      d->sdma[i].id = i;

   vm_object_init(&d->vm_obj);
   d->vm_obj.name = name;
   d->vm_obj.data = d;
   d->vm_obj.shutdown = (vm_shutdown_t)dev_mv64460_shutdown;

   dev_init(&d->dev);
   d->dev.name      = name;
   d->dev.priv_data = d;
   d->dev.phys_addr = paddr;
   d->dev.phys_len  = len;
   d->dev.handler   = dev_mv64460_access;

   /* Create the SRAM device */
   dev_init(&d->sram_dev);
   d->sram_dev.name = "mv64460_sram";
   d->sram_dev.phys_len = MV64460_SRAM_SIZE;
   d->sram_dev.flags = VDEVICE_FLAG_CACHING;
   d->sram_dev.host_addr = (m_iptr_t)m_memalign(4096,d->sram_dev.phys_len);

   if (!d->sram_dev.host_addr) {
      fprintf(stderr,"mv64460: unable to create SRAM data.\n");
      return(-1);
   }

   /* Add the controller as a PCI device */
   if (!pci_dev_lookup(d->bus[0],0,0,0)) {
      d->pci_dev = pci_dev_add(d->bus[0],name,
                               PCI_VENDOR_MARVELL,PCI_PRODUCT_MARVELL_MV64460,
                               0,0,-1,d,NULL,pci_mv64460_read,NULL);
      if (!d->pci_dev) {
         fprintf(stderr,"mv64460: unable to create PCI device.\n");
         return(-1);
      }
   }

   /* TEST */
   pci_dev_add(d->bus[1],name,
               PCI_VENDOR_MARVELL,PCI_PRODUCT_MARVELL_MV64460,
               0,0,-1,d,NULL,pci_mv64460_read,NULL);

   /* Map this device to the VM */
   vm_bind_device(vm,&d->dev);
   vm_object_add(vm,&d->vm_obj);
   return(0);
}
Exemple #12
0
void
vm_mem_init(void)
{
	vm_object_init();
}