예제 #1
0
static void idepmac_wake_device(ide_drive_t *drive, int used_dma)
 {
	/* We force the IDE subdriver to check for a media change
	 * This must be done first or we may lost the condition
	 *
	 * Problem: This can schedule. I moved the block device
	 * wakeup almost late by priority because of that.
	 */
	if (DRIVER(drive) && DRIVER(drive)->media_change)
		DRIVER(drive)->media_change(drive);

	/* We kick the VFS too (see fix in ide.c revalidate) */
	check_disk_change(MKDEV(HWIF(drive)->major, (drive->select.b.unit) << PARTN_BITS));
	
#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
	/* We re-enable DMA on the drive if it was active. */
	/* This doesn't work with the CD-ROM in the media-bay, probably
	 * because of a pending unit attention. The problem if that if I
	 * clear the error, the filesystem dies.
	 */
	if (used_dma && !ide_spin_wait_hwgroup(drive)) {
		/* Lock HW group */
		HWGROUP(drive)->busy = 1;
		pmac_ide_check_dma(drive);
		HWGROUP(drive)->busy = 0;
		spin_unlock_irq(&io_request_lock);
	}
#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
}
예제 #2
0
파일: fs.c 프로젝트: 565407548/micro_os
static void init_fs(){
    /* u8 fsbuf[SECTOR_SIZE]; */
    MESSAGE message;
    message.type=INFO_FS_DEVICE;
    message.device=ROOT_DEVICE;
    assert(dd_map[DRIVER(ROOT_DEVICE)].driver_pid!=PID_INVALID,"");
    send_receive(BOTH,dd_map[DRIVER(ROOT_DEVICE)].driver_pid,&message);

    //如果系统已经是要求的系统,就不需要在格式化系统了
    get_super_block(ROOT_DEVICE,&super_block);
    /* if(super_block.magic!=MAGIC_V1) */{
        mkfs();
        get_super_block(ROOT_DEVICE,&super_block);
    }
    
    init_inode_table();
    init_file_descriptor_table();
#ifdef DEBUG_FS
    //write test
    /* memset(fsbuf,0x23,SECTOR_SIZE); */
    /* WRITE_SECTOR(ROOT_DEVICE,fsbuf,1); */
    //read test
    u8 fsbuf[SECTOR_SIZE];
    READ_SECTOR(ROOT_DEVICE,fsbuf,1);
    printl("read test:\nfsbuf[0]=%x fsbuf[1]=%x fsbuf[2]=%x fsbuf[3]=%x\n",fsbuf[0],fsbuf[1],fsbuf[2],fsbuf[3]);
#endif
}
예제 #3
0
파일: fs.c 프로젝트: 565407548/micro_os
static void mkfs(){
    MESSAGE message;
    
    HD_PART_INFO part_info;
    message.type=INFO_FS_IOCTL;
    message.subtype=DIOCTL_GET_PART_INFO;
    message.device=ROOT_DEVICE;//-------------需要指定到具体分区--------------------
    message.arg_pointer=(void*)&part_info;
    message.source_pid=TASK_FS;
    assert(dd_map[DRIVER(message.device)].driver_pid!=PID_INVALID,"driver not exist!");
    send_receive(BOTH,dd_map[DRIVER(message.device)].driver_pid,&message);
    
#ifdef DEBUG_FS
    printl("device=%d base=%d size=%d (in sector)\n",DEVICE(message.device),part_info.base,part_info.size);
#endif

    SUPER_BLOCK sb;
    //super block
    int super_block_first_index=get_super_block_first_index();
    init_super_block(&sb,super_block_first_index,part_info.size);
#ifdef DEBUG_FS
    printl("init_super_block ok(start_sector=%d)\n",super_block_first_index);
#endif
    //imap
    /* int imap_first_index=super_block_first_index+SUPER_SECTORS_LENGTH; */
    int imap_first_index=get_imap_first_index(sb);
    int imap_sectors_length=get_imap_length(sb)/* sb.imap_sectors_length */;
    init_imap(imap_first_index,imap_sectors_length);
#ifdef DEBUG_FS
    printl("init_imap ok(start_sector=%d)\n",imap_first_index);
#endif
    //smap
    /* int smap_first_index=imap_first_index+imap_sectors_length; */
    int smap_first_index=get_smap_first_index(sb);
    int smap_sectors_length=get_smap_length(sb)/* sb.smap_sectors_length */;
    init_smap(smap_first_index,smap_sectors_length);
#ifdef DEBUG_FS
    printl("init_smap ok(start_sector=%d)\n",smap_first_index);
#endif
    //inode
    /* int inode_first_index=smap_first_index+smap_sectors_length; */
    int inode_first_index=get_inode_first_index(sb);
    /* int inode_sectors_length=get_inode_length(sb)/\* sb.inodes_sectors_length *\/; */
    int root_dir_start_index=get_data_block_first_index(sb)/* sb.data_first_sector_index */;
    init_inode(inode_first_index,root_dir_start_index);    
#ifdef DEBUG_FS
    printl("init_inode ok(start_sector=%d)\n",inode_first_index);
#endif
    //data
    /* int data_block_first_index=inode_first_index+inode_sectors_length; */
    int data_block_first_index=get_data_block_first_index(sb);
    init_data_block(data_block_first_index);
#ifdef DEBUG_FS
    printl("init_data_block ok(start_sector=%d)\n",data_block_first_index);
#endif
}
예제 #4
0
파일: fs.c 프로젝트: 565407548/micro_os
/*
注意:读取的起始位置是扇区的整数倍
*/
int rw_sector(int type,int device,u64 position,int length,int pid,void *buffer){
    MESSAGE message;
    message.type=type;
    message.device=device;
    message.position=position;
    message.length=length;
    message.arg_pointer=buffer;
    message.source_pid=pid;
    assert(dd_map[DRIVER(device)].driver_pid!=PID_INVALID,"");

    send_receive(BOTH,dd_map[DRIVER(device)].driver_pid,&message);
    return 0;
}
예제 #5
0
/*
 * This routine busy-waits for the drive status to be not "busy".
 * It then checks the status for all of the "good" bits and none
 * of the "bad" bits, and if all is okay it returns 0.  All other
 * cases return 1 after invoking ide_error() -- caller should just return.
 *
 * This routine should get fixed to not hog the cpu during extra long waits..
 * That could be done by busy-waiting for the first jiffy or two, and then
 * setting a timer to wake up at half second intervals thereafter,
 * until timeout is achieved, before timing out.
 */
int ide_wait_stat (ide_startstop_t *startstop, ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout)
{
	ide_hwif_t *hwif = HWIF(drive);
	u8 stat;
	int i;
	unsigned long flags;
 
	/* bail early if we've exceeded max_failures */
	if (drive->max_failures && (drive->failures > drive->max_failures)) {
		*startstop = ide_stopped;
		return 1;
	}

	udelay(1);	/* spec allows drive 400ns to assert "BUSY" */
	if ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) {
		local_irq_set(flags);
		timeout += jiffies;
		while ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) {
			if (time_after(jiffies, timeout)) {
				/*
				 * One last read after the timeout in case
				 * heavy interrupt load made us not make any
				 * progress during the timeout..
				 */
				stat = hwif->INB(IDE_STATUS_REG);
				if (!(stat & BUSY_STAT))
					break;

				local_irq_restore(flags);
				*startstop = DRIVER(drive)->error(drive, "status timeout", stat);
				return 1;
			}
		}
		local_irq_restore(flags);
	}
	/*
	 * Allow status to settle, then read it again.
	 * A few rare drives vastly violate the 400ns spec here,
	 * so we'll wait up to 10usec for a "good" status
	 * rather than expensively fail things immediately.
	 * This fix courtesy of Matthew Faupel & Niccolo Rigacci.
	 */
	for (i = 0; i < 10; i++) {
		udelay(1);
		if (OK_STAT((stat = hwif->INB(IDE_STATUS_REG)), good, bad))
			return 0;
	}
	*startstop = DRIVER(drive)->error(drive, "status error", stat);
	return 1;
}
예제 #6
0
void initial_p(void)
{
	//------Init CLK
	CLKPR = 1 << CLKPCE; // CLK Change Enable
	CLKPR = (1 << CLKPS0) | (1 << CLKPS1); // CLK/8
	
	//------Init GPIO
	DRIVER(LED, OUT);
}
예제 #7
0
int idedefault_attach (ide_drive_t *drive)
{
	int ret = 0;
	MOD_INC_USE_COUNT;
	if (ide_register_subdriver(drive,
			&idedefault_driver, IDE_SUBDRIVER_VERSION)) {
		printk(KERN_ERR "ide-default: %s: Failed to register the "
			"driver with ide.c\n", drive->name);
		ret = 1;
		goto bye_game_over;
	}
	DRIVER(drive)->busy++;
	idedefault_setup(drive);
	DRIVER(drive)->busy--;

bye_game_over:
	MOD_DEC_USE_COUNT;
	return ret;
}
예제 #8
0
static adv_error none_mode_import(adv_mode* mode, const none_video_mode* none_mode)
{
	sncpy(mode->name, MODE_NAME_MAX, none_mode->crtc.name);

	*DRIVER(mode) = *none_mode;

	mode->driver = &video_none_driver;
	mode->flags = (mode->flags & MODE_FLAGS_USER_MASK)
		| none_mode->index;
	mode->size_x = DRIVER(mode)->crtc.hde;
	mode->size_y = DRIVER(mode)->crtc.vde;
	mode->vclock = crtc_vclock_get(&DRIVER(mode)->crtc);
	mode->hclock = crtc_hclock_get(&DRIVER(mode)->crtc);

	if (crtc_is_doublescan(&none_mode->crtc))
		mode->scan = 1;
	else if (crtc_is_interlace(&none_mode->crtc))
		mode->scan = -1;
	else
		mode->scan = 0;

	return 0;
}
예제 #9
0
void pre_reset (ide_drive_t *drive)
{
	DRIVER(drive)->pre_reset(drive);

	if (!drive->keep_settings) {
		if (drive->using_dma) {
			check_dma_crc(drive);
		} else {
			drive->unmask = 0;
			drive->io_32bit = 0;
		}
		return;
	}
	if (drive->using_dma)
		check_dma_crc(drive);

	if (HWIF(drive)->pre_reset != NULL)
		HWIF(drive)->pre_reset(drive);

}
예제 #10
0
void uclinux_ide_init(void)
{
	hw_regs_t hw;
	ide_ioreg_t base;
	int index, i;
	ide_hwif_t* hwif;

	for (i = 0; ide_defaults[i].base != (ide_ioreg_t) -1; i++) {
		base = ide_defaults[i].base;
		memset(&hw, 0, sizeof(hw));
#ifdef CONFIG_COLDFIRE
		mcf_autovector(hw.irq);
#endif
		hw.irq = ide_defaults[i].irq;
		ide_setup_ports(&hw, base, ide_offsets, 0, 0, ack_intr,
				/* ide_iops, */
				ide_defaults[i].irq);
		index = ide_register_hw(&hw, &hwif);
		if (index != -1) {
			hwif->mmio  = 1; /* not io(0) or mmio(1) */
#ifdef CONFIG_COLDFIRE
			hwif->OUTB  = OUTB;
			hwif->OUTBSYNC = OUTBSYNC;
			hwif->OUTW  = OUTW;
			hwif->OUTL  = OUTL;
			hwif->OUTSW = OUTSW;
			hwif->OUTSL = OUTSL;
			hwif->INB   = INB;
			hwif->INW   = INW;
			hwif->INL   = INL;
			hwif->INSW  = INSW;
			hwif->INSL  = INSL;

			DRIVER(&hwif->drives[0])->cleanup = uclinux_irq_remove;

#endif
		}
		disable_irq(ide_defaults[i].irq);
	}
}
예제 #11
0
파일: vfb.c 프로젝트: bojoer/advancemame
adv_error fb_mode_import(adv_mode* mode, const fb_video_mode* fb_mode)
{
	sncpy(mode->name, MODE_NAME_MAX, fb_mode->crtc.name);

	*DRIVER(mode) = *fb_mode;

	mode->driver = &video_fb_driver;
	mode->flags = MODE_FLAGS_RETRACE_WAIT_SYNC | MODE_FLAGS_RETRACE_SET_ASYNC
		| (mode->flags & MODE_FLAGS_USER_MASK)
		| fb_mode->index;
	mode->size_x = DRIVER(mode)->crtc.hde;
	mode->size_y = DRIVER(mode)->crtc.vde;
	mode->vclock = crtc_vclock_get(&DRIVER(mode)->crtc);
	mode->hclock = crtc_hclock_get(&DRIVER(mode)->crtc);
	mode->scan = crtc_scan_get(&DRIVER(mode)->crtc);

	return 0;
}
예제 #12
0
adv_error vgaline_mode_import(adv_mode* mode, const vgaline_video_mode* vgaline_mode)
{
	sncpy(mode->name, MODE_NAME_MAX, vgaline_mode->crtc.name);
	*DRIVER(mode) = *vgaline_mode;

	/* adjust the pixel clock to an acceptable value */
	DRIVER(mode)->crtc.pixelclock = vga_pixelclock_nearest_get(DRIVER(mode)->crtc.pixelclock, DRIVER(mode)->is_text);

	mode->driver = &video_vgaline_driver;
	mode->flags = MODE_FLAGS_RETRACE_WAIT_SYNC | MODE_FLAGS_RETRACE_SET_ASYNC
		| (mode->flags & MODE_FLAGS_USER_MASK);

	if (DRIVER(mode)->is_text) {
		mode->flags |= MODE_FLAGS_INDEX_TEXT;
	} else {
		mode->flags |= MODE_FLAGS_INDEX_PALETTE8;
		if (DRIVER(mode)->crtc.vde * DRIVER(mode)->crtc.hde > 0x10000)
			return -1;
	}

	mode->size_x = DRIVER(mode)->crtc.hde;
	mode->size_y = DRIVER(mode)->crtc.vde;
	mode->vclock = crtc_vclock_get(&DRIVER(mode)->crtc);
	mode->hclock = crtc_hclock_get(&DRIVER(mode)->crtc);
	mode->scan = crtc_scan_get(&DRIVER(mode)->crtc);

	return 0;
}
예제 #13
0
파일: shift.c 프로젝트: 4glk/low_temp
void Shift_Init(){
    DRIVER (SHIFT_data, OUT);  // pin_macros format
    DRIVER (SHIFT_clk,OUT);
    DRIVER (SHIFT_latch,OUT);
}
예제 #14
0
파일: tlc5916.c 프로젝트: smeyel/M2
	BIT(6),
	BIT(7)
};


//swap típus, mert a LED-ek összevissza lesznek bekötve
typedef struct{
	uint8_t driver;	//driver indexe
	uint8_t bit;	//bit maszk
}swap_t;

//melyik LED melyik driver hányas bit-jénél van
#define DRIVER(d)			(d)
#define BIT_FROM_PIN(p)			BIT((p)-5)
static const swap_t swap[] = {
	/* LED0  */	{DRIVER(7), BIT_FROM_PIN(11)},
	/* LED1  */	{DRIVER(7), BIT_FROM_PIN(10)},
	/* LED2  */	{DRIVER(7), BIT_FROM_PIN(7)},
	/* LED3  */	{DRIVER(7), BIT_FROM_PIN(6)},
	/* LED4  */	{DRIVER(6), BIT_FROM_PIN(11)},
	/* LED5  */	{DRIVER(6), BIT_FROM_PIN(10)},
	/* LED6  */	{DRIVER(6), BIT_FROM_PIN(7)},
	/* LED7  */	{DRIVER(6), BIT_FROM_PIN(6)},
	/* LED8  */	{DRIVER(5), BIT_FROM_PIN(11)},
	/* LED9  */	{DRIVER(5), BIT_FROM_PIN(10)},
	/* LED10 */	{DRIVER(5), BIT_FROM_PIN(7)},
	/* LED11 */	{DRIVER(5), BIT_FROM_PIN(6)},
	/* LED12 */	{DRIVER(4), BIT_FROM_PIN(11)},
	/* LED13 */	{DRIVER(4), BIT_FROM_PIN(10)},
	/* LED14 */	{DRIVER(4), BIT_FROM_PIN(7)},
	/* LED15 */	{DRIVER(4), BIT_FROM_PIN(6)},
예제 #15
0
/**
 * Import information for one video mode.
 * \param mode Mode to write.
 * \param vbe_mode Mode to import.
 * \return 0 if successful
 */
adv_error vbe_mode_import(adv_mode* mode, const vbe_video_mode* vbe_mode)
{
	vbe_ModeInfoBlock info;

	snprintf(mode->name, MODE_NAME_MAX, "vbe_bios_%x", vbe_mode->mode);
	*DRIVER(mode) = *vbe_mode;

	if (vbe_mode_info_get(&info, DRIVER(mode)->mode) != 0) {
		error_set("VBE report that mode %d is unsupported", DRIVER(mode)->mode);
		return -1;
	}
	if ((info.ModeAttributes & vbeMdAvailable) == 0) {
		error_set("VBE report that mode %d is not avaliable", DRIVER(mode)->mode);
		return -1;
	}

	if ((info.ModeAttributes & vbeMdGraphMode) == 0) {
		error_nolog_set("Text modes are unsupported");
		return -1;
	} else {
		if ((DRIVER(mode)->mode & vbeLinearBuffer) != 0) {
			if (vbe_state.info.VESAVersion < 0x200) {
				error_nolog_set("Linear frame buffer not available on VBE version prior 2.0");
				return -1;
			}
			if ((info.ModeAttributes & vbeMdLinear) == 0) {
				error_nolog_set("Linear frame buffer not available in this mode");
				return -1;
			}
		} else {
			if ((info.ModeAttributes & vbeMdNonBanked) != 0) {
				error_nolog_set("Banked frame buffer not available in this mode");
				return -1;
			} else {
				error_nolog_set("Banked frame buffer isn't supported");
				return -1;
			}
		}
		/* Packed or RGB memory model */
		if (info.MemoryModel != vbeMemPK && info.MemoryModel != vbeMemRGB) {
			error_nolog_set("Unsupported memory model");
			return -1;
		}
		/* Non planar mode */
		if (info.NumberOfPlanes != 1) {
			error_nolog_set("Unsupported number of planes");
			return -1;
		}
	}

	mode->driver = &video_vbe_driver;
	mode->flags = MODE_FLAGS_RETRACE_WAIT_SYNC | MODE_FLAGS_RETRACE_SCROLL_SYNC
		| (mode->flags & MODE_FLAGS_USER_MASK);
	if ((info.ModeAttributes & vbeMdTripleBuffer) != 0)
		mode->flags |= MODE_FLAGS_RETRACE_SCROLL_ASYNC;
	switch (info.MemoryModel) {
	case vbeMemTXT:
		mode->flags |= MODE_FLAGS_INDEX_TEXT;
		break;
	case vbeMemPK:
		mode->flags |= MODE_FLAGS_INDEX_PALETTE8;
		break;
	case vbeMemRGB:
		switch (info.BitsPerPixel) {
		case 15: mode->flags |= MODE_FLAGS_INDEX_BGR15; break;
		case 16: mode->flags |= MODE_FLAGS_INDEX_BGR16; break;
		case 24: mode->flags |= MODE_FLAGS_INDEX_BGR24; break;
		case 32: mode->flags |= MODE_FLAGS_INDEX_BGR32; break;
		default:
			return -1;
		}
		break;
	default:
		return -1;
	}

	mode->size_x = info.XResolution;
	mode->size_y = info.YResolution;
	if (info.MemoryModel == vbeMemTXT) {
		mode->size_x *= info.XCharSize;
		mode->size_y *= info.YCharSize;
	}
	mode->vclock = 0;
	mode->hclock = 0;
	if (info.YResolution <= 300)
		mode->scan = 1; /* assume doublescan */
	else
		mode->scan = 0; /* assume singlescan */

	return 0;
}