Ejemplo n.º 1
0
/*
 * The attach routine only checks and prints drive type.
 * Bringing the disk online is done when the disk is accessed
 * the first time.
 */
void
raattach(device_t parent, device_t self, void *aux)
{
	struct	rx_softc *rx = device_private(self);
	struct	drive_attach_args *da = aux;
	struct	mscp *mp = da->da_mp;
	struct	mscp_softc *mi = device_private(parent);
	struct	disklabel *dl;

	rx->ra_dev = self;
	rx->ra_mediaid = mp->mscp_guse.guse_mediaid;
	rx->ra_state = DK_CLOSED;
	rx->ra_hwunit = mp->mscp_unit;
	mi->mi_dp[mp->mscp_unit] = self;

#if NRX
	if (MSCP_MID_ECH(1, mp->mscp_guse.guse_mediaid) == 'X' - '@')
		disk_init((struct disk *)&rx->ra_disk, device_xname(rx->ra_dev), 
		    &rxdkdriver);
#endif
#if NRACD
	if (MSCP_MID_ECH(1, mp->mscp_guse.guse_mediaid) == 'R' - '@')
		disk_init((struct disk *)&rx->ra_disk, device_xname(rx->ra_dev), 
		    &racddkdriver);
#endif
#if NRA
	if (MSCP_MID_ECH(1, mp->mscp_guse.guse_mediaid) != 'X' - '@' &&
	    MSCP_MID_ECH(1, mp->mscp_guse.guse_mediaid) != 'R' - '@')
		disk_init((struct disk *)&rx->ra_disk, device_xname(rx->ra_dev), 
		    &radkdriver);
#endif
	disk_attach(&rx->ra_disk);

	/* Fill in what we know. The actual size is gotten later */
	dl = rx->ra_disk.dk_label;

	dl->d_secsize = DEV_BSIZE;
	dl->d_nsectors = mp->mscp_guse.guse_nspt;
	dl->d_ntracks = mp->mscp_guse.guse_ngpc * mp->mscp_guse.guse_group;
	dl->d_secpercyl = dl->d_nsectors * dl->d_ntracks;
	disk_printtype(mp->mscp_unit, mp->mscp_guse.guse_mediaid);
#ifdef DEBUG
	printf("%s: nspt %d group %d ngpc %d rct %d nrpt %d nrct %d\n",
	    device_xname(self), mp->mscp_guse.guse_nspt, mp->mscp_guse.guse_group,
	    mp->mscp_guse.guse_ngpc, mp->mscp_guse.guse_rctsize,
	    mp->mscp_guse.guse_nrpt, mp->mscp_guse.guse_nrct);
#endif
	if (MSCP_MID_ECH(1, mp->mscp_guse.guse_mediaid) != 'X' - '@') {
		/*
		 * XXX We should try to discover wedges here, but
		 * XXX that would mean being able to do I/O.  Should
		 * XXX use config_defer() here.
		 */
	}
}
Ejemplo n.º 2
0
static void
md_attach(device_t parent, device_t self,
          void *aux)
{
    struct md_softc *sc = device_private(self);

    bufq_alloc(&sc->sc_buflist, "fcfs", 0);

    /* XXX - Could accept aux info here to set the config. */
#ifdef	MEMORY_DISK_HOOKS
    /*
     * This external function might setup a pre-loaded disk.
     * All it would need to do is setup the md_conf struct.
     * See sys/dev/md_root.c for an example.
     */
    md_attach_hook(device_unit(self), &sc->sc_md);
#endif

    /*
     * Initialize and attach the disk structure.
     */
    disk_init(&sc->sc_dkdev, device_xname(self), &mddkdriver);
    disk_attach(&sc->sc_dkdev);

    if (!pmf_device_register(self, NULL, NULL))
        aprint_error_dev(self, "couldn't establish power handler\n");
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
    int rc,i;
    struct partinfo* pinfo;

    srand(clock());

    if(ata_init()) {
        DEBUGF("*** Warning! The disk is uninitialized\n");
        return -1;
    }
    pinfo = disk_init();
    if (!pinfo) {
        DEBUGF("*** Failed reading partitions\n");
        return -1;
    }

    for ( i=0; i<4; i++ ) {
        if ( pinfo[i].type == PARTITION_TYPE_FAT32 
#ifdef HAVE_FAT16SUPPORT
          || pinfo[i].type == PARTITION_TYPE_FAT16
#endif
        ) {
            DEBUGF("*** Mounting at block %ld\n",pinfo[i].start);
            rc = fat_mount(IF_MV(0,) IF_MD(0,) pinfo[i].start);
            if(rc) {
                DEBUGF("mount: %d",rc);
                return -1;
            }
            break;
        }
    }
Ejemplo n.º 4
0
static int mkrk27_init(const char *filename) {
    int i;
    int rc;
    srand(clock());

    img_filename = filename;

    if(ata_init()) {
        mkrk27_set_error("Warning! The disk is uninitialized\n");
        return -1;
    }

    struct partinfo *pinfo = disk_init();

    if (!pinfo) {
        mkrk27_set_error("Failed reading partitions\n");
        return -1;
    }

    for ( i=0; i<4; i++ ) {
        if ( pinfo[i].type == PARTITION_TYPE_FAT32
#ifdef HAVE_FAT16SUPPORT
             || pinfo[i].type == PARTITION_TYPE_FAT16
#endif
            ) {
            rc = fat_mount(IF_MV(0,) IF_MD(0,) pinfo[i].start);
            if(rc) {
                mkrk27_set_error("mount: %d",rc);
                return -1;
            }
            break;
        }
    }
Ejemplo n.º 5
0
FRESULT PFFS::begin (
	unsigned char cs_pin,	/* Pin to connect to CS */
	uint8_t clkdivider		// parameter for spi clock divider
)
{
	_clkdivider = clkdivider;
	FRESULT res;
	
	CS = cs_pin;
	pinMode(CS, OUTPUT);
#if _SoftSPI
	pinMode(_SCLK, OUTPUT);
	pinMode(_MOSI, OUTPUT);
	pinMode(_MISO, INPUT);
#else
	SPI.begin();
#endif
	attach_cs_pin(CS_LOW, CS_HIGH, CS_READ);
	attach_dly100u(DLY100U);
	attach_SPIdriver(SPI_RECEIVE, SPI_SEND);

	disk_init();
	res = mount(&fatfs_obj);

	SPI_SET_DIVIDER(_clkdivider);
	
#if _USE_DIR
	res = pf_opendir(&dir_obj, (const CHAR *)"/");
#endif

	return res;
}
Ejemplo n.º 6
0
static void
ofdisk_attach(device_t parent, device_t self, void *aux)
{
	struct ofdisk_softc *of = device_private(self);
	struct ofbus_attach_args *oba = aux;
	char child[64];
	int l;

	of->sc_dev = self;
	if ((l = OF_getprop(oba->oba_phandle, "name", child,
	    sizeof child - 1)) < 0)
		panic("device without name?");
	if (l >= sizeof child)
		l = sizeof child - 1;
	child[l] = 0;

	of->sc_flags = 0;
	of->sc_phandle = oba->oba_phandle;
	of->sc_unit = oba->oba_unit;
	of->sc_ihandle = 0;
	disk_init(&of->sc_dk, device_xname(of->sc_dev), &ofdisk_dkdriver);
	disk_attach(&of->sc_dk);
	printf("\n");

	if (strcmp(child, "floppy") == 0)
		of->sc_flags |= OFDF_ISFLOPPY;
	else {
		/* Discover wedges on this disk. */
		dkwedge_discover(&of->sc_dk);
	}
}
Ejemplo n.º 7
0
int main(void)
{
    MCUSR &= ~(1 << WDRF);
    wdt_disable();

     // led
    SETUPRED();
    SETUPGREEN();
    GREENON();
    REDON();

    uint8_t bootloader_version[5] = "b002";
    eeprom_update_block((void *)&bootloader_version, BOOTLOADER_VERSION_ADDR, 4);

    sd_disk sd;
    _delay_ms(250);

     uint16_t flash = 0;
     if (!sd_init(&sd) && disk_init(&sd)) {
         if (!find_and_load_bootfile(&sd)) {
             flash = 4*3;
         }
     }
     GREENOFF();
     REDOFF();

     for (int i=0; i<flash; i++) {
         REDTOGGLE();
        _delay_ms(250);
      }
    REDOFF();
     __asm__("jmp 0000");
     sd_write_block(0,0);
}
Ejemplo n.º 8
0
void init() {
	int i;
	// Initialize kseg0 & useg3 page table (same for all processes)
	init_kernel_pt();
	init_useg3_pt();

	// Initilize all VM-I/O support level semaphores
	swap_semaphore = 1;
	memset(uproc_semaphore, 0, sizeof(int) * UPROCMAX); //Private semaphore for delay facility

	initADL();
	init_del_deamon();
	initAVSL();
	disk_init();
	initSwapPool();
	initDMA();

	// Init all the u-procs from tape and get the number of u-procs created
	uprocess_c = init_proc();
	// wait for all uprocs to terminate
	SYSCALL(SEMOP,&master_sem,-1,0);
	//Terminate Deamon
	SYSCALL(TERMINATEPROCESS,3,0,0);

	//Terminate the init process (and all his children)
	//This should HALT the system
	SYSCALL(TERMINATEPROCESS,0,0,0);
	fatal("System failed to terminate");
}
Ejemplo n.º 9
0
int main(void)
{
	random_init();
	cache_init();
	disk_init();
	processes_run(task);
	return 0;
}
Ejemplo n.º 10
0
void brd_driver_init(){
#ifdef CFG_DRV_CONSOLE
	console_init();
#endif
#ifdef CFG_DRV_EMU_DISK
	disk_init();
#endif
}
Ejemplo n.º 11
0
Archivo: init.c Proyecto: aunali1/exopc
void init(void) {
        kernel_init();
        xn_init();
        tmplt_init();
	sec_init();
        xr_reset();
#ifndef EXOPC
	disk_init();
#endif
}
Ejemplo n.º 12
0
static void
ed_mca_attach(device_t parent, device_t self, void *aux)
{
    struct ed_softc *ed = device_private(self);
    struct edc_mca_softc *sc = device_private(parent);
    struct ed_attach_args *eda = aux;
    char pbuf[8];
    int drv_flags;

    ed->sc_dev = self;
    ed->edc_softc = sc;
    ed->sc_devno  = eda->edc_drive;
    edc_add_disk(sc, ed);

    bufq_alloc(&ed->sc_q, "disksort", BUFQ_SORT_RAWBLOCK);
    mutex_init(&ed->sc_q_lock, MUTEX_DEFAULT, IPL_VM);

    if (ed_get_params(ed, &drv_flags)) {
        printf(": IDENTIFY failed, no disk found\n");
        return;
    }

    format_bytes(pbuf, sizeof(pbuf),
                 (u_int64_t) ed->sc_capacity * DEV_BSIZE);
    printf(": %s, %u cyl, %u head, %u sec, 512 bytes/sect x %u sectors\n",
           pbuf,
           ed->cyl, ed->heads, ed->sectors,
           ed->sc_capacity);

    printf("%s: %u spares/cyl, %s, %s, %s, %s, %s\n",
           device_xname(ed->sc_dev), ed->spares,
           (drv_flags & (1 << 0)) ? "NoRetries" : "Retries",
           (drv_flags & (1 << 1)) ? "Removable" : "Fixed",
           (drv_flags & (1 << 2)) ? "SkewedFormat" : "NoSkew",
           (drv_flags & (1 << 3)) ? "ZeroDefect" : "Defects",
           (drv_flags & (1 << 4)) ? "InvalidSecondary" : "SecondaryOK"
          );

    /*
     * Initialize and attach the disk structure.
     */
    disk_init(&ed->sc_dk, device_xname(ed->sc_dev), &eddkdriver);
    disk_attach(&ed->sc_dk);
    rnd_attach_source(&ed->rnd_source, device_xname(ed->sc_dev),
                      RND_TYPE_DISK, RND_FLAG_DEFAULT);

    ed->sc_flags |= EDF_INIT;

    /*
     * XXX We should try to discovery wedges here, but
     * XXX that would mean being able to do I/O.  Should
     * XXX use config_defer() here.
     */
}
Ejemplo n.º 13
0
Archivo: init.c Proyecto: zswek/bitch
void dev_init(void) {
    
    //console_init();
    
    keyboard_init();
    
    set_input_mode(2);
    
    disk_init();
    
}
Ejemplo n.º 14
0
static void
cgd_attach(device_t parent, device_t self, void *aux)
{
	struct cgd_softc *sc = device_private(self);

	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_BIO);
	dk_init(&sc->sc_dksc, self, DKTYPE_CGD);
	disk_init(&sc->sc_dksc.sc_dkdev, sc->sc_dksc.sc_xname, &cgddkdriver);

	if (!pmf_device_register(self, NULL, NULL))
		aprint_error_dev(self, "unable to register power management hooks\n");
}
Ejemplo n.º 15
0
Archivo: bmd.c Proyecto: ryo/netbsd-src
static void
bmd_attach(device_t parent, device_t self, void *aux)
{
	struct bmd_softc *sc = device_private(self);
	struct intio_attach_args *ia = aux;
	bus_space_tag_t iot = ia->ia_bst;
	bus_space_handle_t ioh;
	u_int8_t r;

	aprint_normal(": Nereid Bank Memory Disk\n");

	/* Map I/O space */
	ia->ia_size = 2;
	if (bus_space_map(iot, ia->ia_addr, ia->ia_size, 0, &ioh)) {
		aprint_error_dev(self, "can't map I/O space\n");
		return;
	}

	sc->sc_iot = iot;
	sc->sc_ioh = ioh;

	/* read control register */
	r = bus_space_read_1(sc->sc_iot, sc->sc_ioh, BMD_CTRL);

	/* check enable-bit */
	if ((r & BMD_CTRL_ENABLE) == 0) {
		aprint_error_dev(self, "disabled by DIP-SW 8\n");
		return;
	}

	if ((r & BMD_CTRL_MEMORY))
		sc->sc_maxpage = 256;
	else
		sc->sc_maxpage = 64;

	if ((r & BMD_CTRL_WINDOW))
		sc->sc_window = 0xef0000;
	else
		sc->sc_window = 0xee0000;

	/* Map bank area */
	if (bus_space_map(iot, sc->sc_window, BMD_PAGESIZE, 0, &sc->sc_bank)) {
		aprint_error_dev(self, "can't map bank area: 0x%x\n",
			sc->sc_window);
		return;
	}

	aprint_normal_dev(self, "%d MB, 0x%x(64KB) x %d pages\n",
		(sc->sc_maxpage / 16), sc->sc_window, sc->sc_maxpage);

	disk_init(&sc->sc_dkdev, device_xname(self), &bmddkdriver);
	disk_attach(&sc->sc_dkdev);
}
Ejemplo n.º 16
0
void
mcdattach(struct device *parent, struct device *self, void *aux)
{
	struct mcd_softc *sc = (void *)self;
	struct isa_attach_args *ia = aux;
	bus_space_tag_t iot = ia->ia_iot;
	bus_space_handle_t ioh;
	struct mcd_mbox mbx;

	/* Map i/o space */
	if (bus_space_map(iot, ia->ia_io[0].ir_addr, MCD_NPORT, 0, &ioh)) {
		printf(": can't map i/o space\n");
		return;
	}

	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);

	sc->sc_iot = iot;
	sc->sc_ioh = ioh;

	sc->probe = 0;
	sc->debug = 0;

	if (!mcd_find(iot, ioh, sc)) {
		printf(": mcd_find failed\n");
		return;
	}

	bufq_alloc(&sc->buf_queue, "disksort", BUFQ_SORT_RAWBLOCK);
	callout_init(&sc->sc_pintr_ch, 0);

	/*
	 * Initialize and attach the disk structure.
	 */
	disk_init(&sc->sc_dk, device_xname(&sc->sc_dev), &mcddkdriver);
	disk_attach(&sc->sc_dk);

	printf(": model %s\n", sc->type != 0 ? sc->type : "unknown");

	(void) mcd_setlock(sc, MCD_LK_UNLOCK);

	mbx.cmd.opcode = MCD_CMDCONFIGDRIVE;
	mbx.cmd.length = sizeof(mbx.cmd.data.config) - 1;
	mbx.cmd.data.config.subcommand = MCD_CF_IRQENABLE;
	mbx.cmd.data.config.data1 = 0x01;
	mbx.res.length = 0;
	(void) mcd_send(sc, &mbx, 0);

	mcd_soft_reset(sc);

	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
	    IST_EDGE, IPL_BIO, mcdintr, sc);
}
Ejemplo n.º 17
0
void mainMenu_doF3(void * data) // switch to usb
{
    int h,w;
    int evt;
    char * msg1 = "In USB mode (F3 to exit)";

    if(usbMode)
    {
        // in usb mode => disable usb
        printk( "Warning should not be here\n");
#warning need some processing to see what to do here
    }
    else
    {
        // not in usb mode => enable usb if cable present
        if(usb_isConnected() || FW_isConnected())
        {
            if(disk_umount(HD_DRIVE,1)!=MED_OK)
            {
                printk("File still open, can't umount\n");
                return;
            }
            gfx_clearScreen(COLOR_WHITE);
            gfx_fontSet(STD8X13);
            gfx_getStringSize(msg1,&w,&h);
            gfx_putS(COLOR_RED,COLOR_WHITE,(SCREEN_WIDTH-w)/2,(SCREEN_HEIGHT-h)/2,msg1);
            enableUsbFw();
            usbMode=1;
            mdelay(10);
            evt_purgeHandler(evt_hand);
            while(1)
            {
                if((evt=evt_getStatus(evt_hand))<0)
                    printk("Bad evt (error:%d)\n",-evt);
                if(evt==BTN_F3)
                    break;
            }
            disableUsbFw();
            usbMode=0;
            //mdelay(5);
            disk_init();
#warning we should also reload menu.cfg or other menu related files
            evt_purgeHandler(evt_hand);
            mainMenu_start();
        }
        else
        {
            printk( "Warning can't go usb as usb cable is absent\n");
        }
    }
}
Ejemplo n.º 18
0
static void
vnd_attach(device_t parent, device_t self, void *aux)
{
	struct vnd_softc *sc = device_private(self);

	sc->sc_dev = self;
	sc->sc_comp_offsets = NULL;
	sc->sc_comp_buff = NULL;
	sc->sc_comp_decombuf = NULL;
	bufq_alloc(&sc->sc_tab, "disksort", BUFQ_SORT_RAWBLOCK);
	disk_init(&sc->sc_dkdev, device_xname(self), &vnddkdriver);
	if (!pmf_device_register(self, NULL, NULL))
		aprint_error_dev(self, "couldn't establish power handler\n");
}
Ejemplo n.º 19
0
/*
 * Controller is working, and drive responded.  Attach it.
 */
void
fdattach(device_t parent, device_t self, void *aux)
{
	struct fdc_softc *fdc = device_private(parent);
	struct fd_softc *fd = device_private(self);
	struct fdc_attach_args *fa = aux;
	const struct fd_type *type = fa->fa_deftype;
	int drive = fa->fa_drive;

	fd->sc_dev = self;

	callout_init(&fd->sc_motoron_ch, 0);
	callout_init(&fd->sc_motoroff_ch, 0);

	/* XXX Allow `flags' to override device type? */

	if (type)
		aprint_normal(": %s, %d cyl, %d head, %d sec\n", type->name,
		    type->cyls, type->heads, type->sectrac);
	else
		aprint_normal(": density unknown\n");

	bufq_alloc(&fd->sc_q, "disksort", BUFQ_SORT_CYLINDER);
	fd->sc_cylin = -1;
	fd->sc_drive = drive;
	fd->sc_deftype = type;
	fdc->sc_fd[drive] = fd;

	/*
	 * Initialize and attach the disk structure.
	 */
	disk_init(&fd->sc_dk, device_xname(fd->sc_dev), &fddkdriver);
	disk_attach(&fd->sc_dk);

	/*
	 * Establish a mountroot hook.
	 */
	fd->sc_roothook =
	    mountroothook_establish(fd_mountroot_hook, fd->sc_dev);

#if NRND > 0
	rnd_attach_source(&fd->rnd_source, device_xname(fd->sc_dev),
			  RND_TYPE_DISK, 0);
#endif

	fd_set_properties(fd);

	if (!pmf_device_register(self, NULL, NULL))
		aprint_error_dev(self, "cannot set power mgmt handler\n");
}
Ejemplo n.º 20
0
init_fat(){
	/* enable everdrive card */
	clearFATBuffers();
	ed_begin();
	put_string("Initialise", 0, 1);
	everdrive_error = disk_init();
	put_number(everdrive_error, 3, 0, 2);
	everdrive_error = getMBR(0);
	put_number(everdrive_error, 3, 4, 2);
	everdrive_error = getFATVol();
	put_number(everdrive_error, 3, 8, 2);
	everdrive_error = getFATFS();
	put_number(everdrive_error, 3, 12, 2);
	/* NOTE: You should normally check that each call to the above 4 functions
	has returned correctly before proceeding! */
}
Ejemplo n.º 21
0
static void
rdattach(device_t parent, device_t self, void *aux)
{
	struct rd_softc *sc = device_private(self);
	struct hpibbus_attach_args *ha = aux;

	sc->sc_dev = self;
	bufq_alloc(&sc->sc_tab, "disksort", BUFQ_SORT_RAWBLOCK);

	if (rdident(parent, sc, ha) == 0) {
		aprint_error(": didn't respond to describe command!\n");
		return;
	}

	/*
	 * Initialize and attach the disk structure.
	 */
	memset(&sc->sc_dkdev, 0, sizeof(sc->sc_dkdev));
	disk_init(&sc->sc_dkdev, device_xname(sc->sc_dev), NULL);
	disk_attach(&sc->sc_dkdev);

	sc->sc_slave = ha->ha_slave;
	sc->sc_punit = ha->ha_punit;

	callout_init(&sc->sc_restart_ch, 0);

	/* Initialize the hpib job queue entry */
	sc->sc_hq.hq_softc = sc;
	sc->sc_hq.hq_slave = sc->sc_slave;
	sc->sc_hq.hq_start = rdstart;
	sc->sc_hq.hq_go = rdgo;
	sc->sc_hq.hq_intr = rdintr;

	sc->sc_flags = RDF_ALIVE;
#ifdef DEBUG
	/* always report errors */
	if (rddebug & RDB_ERROR)
		rderrthresh = 0;
#endif
	/*
	 * attach the device into the random source list
	 */
	rnd_attach_source(&sc->rnd_source, device_xname(sc->sc_dev),
	    RND_TYPE_DISK, RND_FLAG_DEFAULT);
}
Ejemplo n.º 22
0
/** Main function of the PC loader. */
void platform_init(void) {
	/* Set up console output. */
	console_init();

	/* Initialize the architecture. */
	arch_init();

	/* Initialize hardware. */
	memory_init();
	disk_init();
	vbe_init();

	/* Parse information from Multiboot. */
	multiboot_init();

	/* Call the main function. */
	loader_main();
}
Ejemplo n.º 23
0
struct io_batch *iobatch_new(int capacity, size_t bytes_cap) {
    struct io_batch *batch = kmalloc(sizeof(*batch), GFP_ATOMIC);
	IORequest *reqs = kmalloc(sizeof(*reqs)*capacity, GFP_ATOMIC);
	if (!batch || !reqs) {
		kfree(batch);
		kfree(reqs);
		return NULL;
	}
	memset(batch, 0, sizeof(*batch));
	memset(reqs, 0, sizeof(*reqs));
	disk_init(&batch->disk);
	batch->reqs = reqs;
	batch->reqs_size = 0;
	batch->reqs_capacity = capacity;
	batch->cost = -1;
	batch->bytes = 0;
	batch->bytes_cap = bytes_cap;
	return batch;
}
Ejemplo n.º 24
0
Archivo: disk.c Proyecto: balr0g/cw
/****************************************************************************
 * config_disk
 ****************************************************************************/
cw_bool_t
config_disk(
	struct config			*cfg,
	cw_count_t			revision)

	{
	cw_char_t			token[GLOBAL_MAX_NAME_SIZE];
	struct disk			dsk;

	disk_init(&dsk, revision);
	config_name(cfg, "disk name expected", token, sizeof (token));
	if (! disk_set_name(&dsk, token)) config_error(cfg, "already defined disk '%s' within this scope", token);
	config_disk_directive(cfg, &dsk, disk_init_track_default(&dsk), NULL, SCOPE_ENTER | SCOPE_TRACK | SCOPE_RW);
	if (! disk_tracks_used(&dsk)) config_error(cfg, "no tracks used in disk '%s'", token);
	if (! disk_image_ok(&dsk)) config_error(cfg, "specified format and image do not have the same level in disk '%s'", token);
	if (! disk_trackmap_ok(&dsk)) config_error(cfg, "trackmap incomplete or illegal use of side_offset or flip_side in disk '%s'", token);
	if (! disk_trackmap_numbering_ok(&dsk)) config_error(cfg, "image_track numbering in trackmap not compatible with selected image format in disk '%s'", token);
	disk_insert(&dsk);
	return (CW_BOOL_OK);
	}
Ejemplo n.º 25
0
static void
fss_attach(device_t parent, device_t self, void *aux)
{
	struct fss_softc *sc = device_private(self);

	sc->sc_dev = self;
	sc->sc_bdev = NODEV;
	mutex_init(&sc->sc_slock, MUTEX_DEFAULT, IPL_NONE);
	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
	cv_init(&sc->sc_work_cv, "fssbs");
	cv_init(&sc->sc_cache_cv, "cowwait");
	bufq_alloc(&sc->sc_bufq, "fcfs", 0);
	sc->sc_dkdev = malloc(sizeof(*sc->sc_dkdev), M_DEVBUF, M_WAITOK);
	sc->sc_dkdev->dk_info = NULL;
	disk_init(sc->sc_dkdev, device_xname(self), NULL);
	if (!pmf_device_register(self, NULL, NULL))
		aprint_error_dev(self, "couldn't establish power handler\n");

	if (fss_num_attached++ == 0)
		vfs_hooks_attach(&fss_vfs_hooks);
}
Ejemplo n.º 26
0
void
rlattach(device_t parent, device_t self, void *aux)
{
	struct rl_softc *rc = device_private(self);
	struct rlc_attach_args *ra = aux;
	struct disklabel *dl;

	rc->rc_dev = self;
	rc->rc_rlc = device_private(parent);
	rc->rc_hwid = ra->hwid;
	disk_init(&rc->rc_disk, device_xname(rc->rc_dev), &rldkdriver);
	disk_attach(&rc->rc_disk);
	dl = rc->rc_disk.dk_label;
	dl->d_npartitions = 3;
	strcpy(dl->d_typename, "RL01");
	if (ra->type & RLMP_DT)
		dl->d_typename[3] = '2';
	dl->d_secsize = DEV_BSIZE; /* XXX - wrong, but OK for now */
	dl->d_nsectors = RL_SPT/2;
	dl->d_ntracks = RL_SPD;
	dl->d_ncylinders = ra->type & RLMP_DT ? RL_TPS02 : RL_TPS01;
	dl->d_secpercyl = dl->d_nsectors * dl->d_ntracks;
	dl->d_secperunit = dl->d_ncylinders * dl->d_secpercyl;
	dl->d_partitions[0].p_size = dl->d_partitions[2].p_size =
	    dl->d_secperunit;
	dl->d_partitions[0].p_offset = dl->d_partitions[2].p_offset = 0;
	dl->d_interleave = dl->d_headswitch = 1;
	dl->d_bbsize = BBSIZE;
	dl->d_sbsize = SBLOCKSIZE;
	dl->d_rpm = 2400;
	dl->d_type = DTYPE_DEC;
	printf(": %s, %s\n", dl->d_typename, rlstate(rc->rc_rlc, ra->hwid));

	/*
	 * XXX We should try to discovery wedges here, but
	 * XXX that would mean loading up the pack and being
	 * XXX able to do I/O.  Should use config_defer() here.
	 */
}
Ejemplo n.º 27
0
void
rdattach(device_t parent, device_t self, void *aux)
{
	struct hdcsoftc * const sc = device_private(parent);
	struct rdsoftc * const rd = device_private(self);
	struct hdc_attach_args * const ha = aux;
	struct disklabel *dl;
	const char *msg;

	rd->sc_dev = self;
	rd->sc_drive = ha->ha_drive;
	rd->sc_hdc = sc;
	/*
	 * Initialize and attach the disk structure.
	 */
	disk_init(&rd->sc_disk, device_xname(rd->sc_dev), NULL);
	disk_attach(&rd->sc_disk);

	/*
	 * if it's not a floppy then evaluate the on-disk geometry.
	 * if necessary correct the label...
	 */
	rd_readgeom(sc, rd);
	disk_printtype(rd->sc_drive, rd->sc_xbn.media_id);
	dl = rd->sc_disk.dk_label;
	rdmakelabel(dl, &rd->sc_xbn);
	msg = readdisklabel(MAKEDISKDEV(cdevsw_lookup_major(&rd_cdevsw),
					device_unit(rd->sc_dev), RAW_PART),
			    rdstrategy, dl, NULL);
	if (msg)
		aprint_normal_dev(self, "%s: size %u sectors",
		    msg, dl->d_secperunit);
	else
		aprint_normal_dev(self, "size %u sectors\n", dl->d_secperunit);
#ifdef RDDEBUG
	hdc_printgeom(&rd->sc_xbn);
#endif
}
Ejemplo n.º 28
0
void product_cache_load_cache()
{
	struct book *b1;
	struct disk *d1;

	printf("product_cache::load_cache()\n");
	
	b1 = malloc(sizeof(*b1));
	book_init(b1);
	product_set_description(&b1->product, "Oliver Twist");
	product_set_sku(&b1->product, "B1");
	book_set_pages_num(b1, 100);

	product_cache_ops.product_list[product_cache_ops.product_list_sz++] = &b1->product;

	d1 = malloc(sizeof(*d1));
	disk_init(d1);
	product_set_description(&d1->product, "Superman");
	product_set_sku(&d1->product, "D1");
	disk_set_duration(d1, 180);

	product_cache_ops.product_list[product_cache_ops.product_list_sz++] = &d1->product;
}
Ejemplo n.º 29
0
void file_reinit(void) {
  disk_init();
  file_init();
}
Ejemplo n.º 30
0
int main(int argc, char **argv){
	char *trace = argc == 1 ? "trace.txt" : argv[1];
	int cache_size = argc > 2 ? atoi(argv[2]) : 16;
	int ramdisk = 1;

	printf("blocksize:  %u\n", BLOCK_SIZE);
	printf("refs/block: %u\n", (unsigned int) (BLOCK_SIZE / sizeof(block_no)));

	/* First create the lowest level "store".
	 */
	block_if disk;
	if (ramdisk) {
		disk = ramdisk_init(blocks, DISK_SIZE);
	}
	else {
		disk = disk_init("disk.dev", DISK_SIZE);
	}

	/* Start a timer to try to detect infinite loops or just insanely slow code.
	 */
	signal(SIGALRM, sigalrm);
	alarm(5);

	/* Virtualize the store, creating a collection of 64 virtual stores.
	 */
	if (treedisk_create(disk, MAX_INODES) < 0) {
		panic("trace: can't create treedisk file system");
	}

	/* Add a disk to keep track of statistics.
	 */
	block_if sdisk = statdisk_init(disk);

	/* Add a layer of caching.
	 */
	block_t *cache = malloc(cache_size * BLOCK_SIZE);
	block_if cdisk = cachedisk_init(sdisk, cache, cache_size);

	/* Add a layer of checking to make sure the cache layer works.
	 */
	block_if xdisk = checkdisk_init(cdisk, "cache");

	/* Run a trace.
	 */
	block_if tdisk = tracedisk_init(xdisk, trace, MAX_INODES);

	/* Clean up.
	 */
	(*tdisk->destroy)(tdisk);
	(*xdisk->destroy)(xdisk);
	(*cdisk->destroy)(cdisk);

	/* No longer running treedisk or cachedisk code.
	 */
	alarm(0);

	/* Print stats.
	 */
	statdisk_dump_stats(sdisk);

	(*sdisk->destroy)(sdisk);

	/* Check that disk just one more time for good measure.
	 */
	treedisk_check(disk);

	(*disk->destroy)(disk);

	free(cache);

	return 0;
}