Ejemplo n.º 1
0
int
disk_open(void)
{
	int di;

	di = get_diskinfo(BDEV(dev,unit));

#ifdef	DEBUG
	if(debug) {
		printf("disk_open()\n");
		printf("diskinfo %x\n", di);
		printf("HS %d %d\n", HEADS(di) ,SPT(di));
	}
#endif
	spc = (spt = SPT(di)) * HEADS(di);
	use_badsect = FALSE;
	if (dev == DEV_FLOPPY) {
		boff = 0;
		part = (spt == 15 ? 3 : 1);
		return 0;
	}
	else {
	  	/*
		 * Usually H=32 S=64 for SCSI
		 * But sometimes we also have H=33 & S=62.
		 * For IDE Apparently H<64 
		 */
		if (spt >= 64 || HEADS(di) > 32) /* scsi */
			dev = DEV_SD;
		if (read_partitions())
			return(1);
#if	DEBUG
	if(debug)
		printf("%d partitions, active is %d\n", 
		       npartitions, active_partition);
#endif
		if (part > npartitions)
			return(1);
		boff = partitions[part].p_start;
	}
	return 0;
}
Ejemplo n.º 2
0
Archivo: disk.c Proyecto: metacore/spin
int
devopen(void)
{
	struct dos_partition *dptr;
	struct disklabel *dl;
	char *p;
	int i, sector = 0, di, dosdev_copy;

	dosdev_copy = dosdev;
	di = get_diskinfo(dosdev_copy);
	spt = SPT(di);

	/* Hack for 2.88MB floppy drives. */
	if (!(dosdev_copy & 0x80) && spt == 36)
		spt = 18;

	spc = spt * HEADS(di);

#ifndef RAWBOOT
	{
#ifdef	EMBEDDED_DISKLABEL
		dl = &disklabel;
#else	EMBEDDED_DISKLABEL
		p = Bread(dosdev_copy, 0);
		dptr = (struct dos_partition *)(p+DOSPARTOFF);
		slice = WHOLE_DISK_SLICE;
		for (i = 0; i < NDOSPART; i++, dptr++)
			if (dptr->dp_typ == DOSPTYP_386BSD) {
				slice = BASE_SLICE + i;
				sector = dptr->dp_start;
				break;
			}
		p = Bread(dosdev_copy, sector + LABELSECTOR);
		dl=((struct disklabel *)p);
		disklabel = *dl;	/* structure copy (maybe useful later)*/
#endif	EMBEDDED_DISKLABEL
		if (dl->d_magic != DISKMAGIC) {
			printf("bad disklabel");
			return 1;
		}
		if( (maj == 4) || (maj == 0) || (maj == 1))
		{
			if (dl->d_type == DTYPE_SCSI)
			{
				maj = 4; /* use scsi as boot dev */
			}
			else
			{
				maj = 0; /* must be ESDI/IDE */
			}
		}
		/* This little trick is for OnTrack DiskManager disks */
		boff = dl->d_partitions[part].p_offset -
			dl->d_partitions[2].p_offset + sector;

		/* This is a good idea for all disks */
		bsize = dl->d_partitions[part].p_size;
#ifdef DO_BAD144
		do_bad144 = 0;
		if (dl->d_flags & D_BADSECT) {
		    /* this disk uses bad144 */
		    int i;
		    int dkbbnum;
		    struct dkbad *dkbptr;

		    /* find the first readable bad sector table */
		    /* some of this code is copied from ufs/ufs_disksubr.c */
		    /* including the bugs :-( */
		    /* read a bad sector table */

#define BAD144_PART	2	/* XXX scattered magic numbers */
#define BSD_PART	0	/* XXX should be 2 but bad144.c uses 0 */
		    if (dl->d_partitions[BSD_PART].p_offset != 0)
			    dkbbnum = dl->d_partitions[BAD144_PART].p_offset
				      + dl->d_partitions[BAD144_PART].p_size;
		    else
			    dkbbnum = dl->d_secperunit;
		    dkbbnum -= dl->d_nsectors;

		    if (dl->d_secsize > DEV_BSIZE)
		      dkbbnum *= dl->d_secsize / DEV_BSIZE;
		    else
		      dkbbnum /= DEV_BSIZE / dl->d_secsize;
		    i = 0;
		    do_bad144 = 0;
		    do {
			/* XXX: what if the "DOS sector" < 512 bytes ??? */
			p = Bread(dosdev_copy, dkbbnum + i);
			dkbptr = (struct dkbad *) p;
/* XXX why is this not in <sys/dkbad.h> ??? */
#define DKBAD_MAGIC 0x4321
			if (dkbptr->bt_mbz == 0 &&
			        dkbptr->bt_flag == DKBAD_MAGIC) {
			    dkb = *dkbptr;	/* structure copy */
			    do_bad144 = 1;
			    break;
			}
			i += 2;
		    } while (i < 10 && (unsigned)i < dl->d_nsectors);
		    if (!do_bad144)
		      printf("Bad bad sector table\n");
		    else
		      printf("Using bad sector table at %d\n", dkbbnum+i);
		}
#endif /* DO_BAD144 */
	}
#endif /* RAWBOOT */
	return 0;
}
Ejemplo n.º 3
0
int
read_partitions(void)
{
	char 		*altptr;
	struct ipart 	*iptr, *active, *extended;
	int 		i, sector;
	int 		base =0;
	int		ext_base = 0;
	struct evtoc 	*evp;
	int 		di;

	di  = get_diskinfo(BDEV(dev,unit));
	spc = (spt = SPT(di)) * HEADS(di);
	use_badsect = FALSE;

	npartitions = 0;
	active_partition = 0;
	active = (struct ipart *)0;
	extended = (struct ipart *)0;

	disk_read(0, BPS, (vm_offset_t)0);
	iptr = (struct ipart *)((struct mboot *)0)->parts;
	for (i = 0; i < FD_NUMPART; i++, iptr++) {
#if	DEBUG
	  	if (debug)
			show_part(iptr, i, 0);
#endif
		if (iptr->bootid == ACTIVE) {
			active = iptr;
			active_partition = i;
		}
		if (iptr->systid == EXT_PART)
			extended = iptr;
		partitions[i].p_start = iptr->relsect;
		partitions[i].p_size = iptr->numsect;
	}
	if (active && active->systid == UNIXOS) {
	  	sector = active->relsect + HDPDLOC;
		evp = (struct evtoc *)0;
		if (disk_read(sector++, BPS, (vm_offset_t)0) == 0 &&
		    evp->sanity == VTOC_SANE) {	/* compatibility */
			bcopy((char *)evp->part,
			      (char *)partitions, sizeof(partitions));
			npartitions = evp->nparts;
			altptr = (char *)(&alt_info);
			for (i = 0; i++ < 4; altptr += BPS, sector++) {
			    if (disk_read(sector, BPS, (vm_offset_t)altptr))
				return 1;
			}
			if (alt_info.alt_sanity != ALT_SANITY) {
				printf("Bad alt_sanity\n");
				return 1;
			}
			active_partition = 0;
			use_badsect = TRUE;
			return 0;
		} 
	}
	if (extended) {
		/* look for extended partitions */
		base = extended->relsect;
		ext_base = base;
		while (1) {
			if (disk_read(base, BPS, (vm_offset_t)0))
		        	return 1;	
			iptr = (struct ipart *)((struct mboot *)0)->parts;
#if	DEBUG
			if (debug)
				show_part(iptr, i, base);
#endif
			partitions[i].p_start = base + iptr->relsect;
			partitions[i].p_size = iptr->numsect;
			i++;
			iptr++;
#if 	DEBUG
			if (debug)
				show_part(iptr, i, base);
#endif
			if (iptr->systid == EXT_PART) {
		        	extended = iptr;
				base = extended->relsect + ext_base;
			} else
				break;
		}
	}
	npartitions = i;
	return 0;
}
Ejemplo n.º 4
0
int devopen(void)
{
	struct dos_partition *dptr;
	struct disklabel *dl;
	int dosdev = (int) inode.i_dev;
	int i;
	long di, sector;
	
	di = get_diskinfo(dosdev);
	spc = (spt = (int)SPT(di)) * (int)HEADS(di);
	if (dosdev == 2)
	{
		boff = 0;
		part = (spt == 15 ? 3 : 1);
	}
	else
	{
#ifdef	EMBEDDED_DISKLABEL
		dl = &disklabel;
#else	EMBEDDED_DISKLABEL
		Bread(dosdev, 0);
		dptr = (struct dos_partition *)(((char *)I_ADDR)+DOSPARTOFF);
		sector = LABELSECTOR;
		slice = WHOLE_DISK_SLICE;
		for (i = 0; i < NDOSPART; i++, dptr++)
			if (dptr->dp_typ == DOSPTYP_386BSD) {
				slice = BASE_SLICE + i;
				sector = dptr->dp_start + LABELSECTOR;
				break;
			}
		Bread(dosdev, sector++);
		dl=((struct disklabel *)I_ADDR);
		disklabel = *dl;	/* structure copy (maybe useful later)*/
#endif	EMBEDDED_DISKLABEL
		if (dl->d_magic != DISKMAGIC) {
			printf("bad disklabel");
			return 1;
		}

		if( (maj == 4) || (maj == 0) || (maj == 1)) {
			if (dl->d_type == DTYPE_SCSI)
				maj = 4; /* use scsi as boot dev */
			else
				maj = 0; /* must be ESDI/IDE */
		}

		boff = dl->d_partitions[part].p_offset;
#ifdef DO_BAD144
		bsize = dl->d_partitions[part].p_size;
		do_bad144 = 0;
		if (dl->d_flags & D_BADSECT) {
		    /* this disk uses bad144 */
		    int i;
		    long dkbbnum;
		    struct dkbad *dkbptr;

		    /* find the first readable bad sector table */
		    /* some of this code is copied from ufs/ufs_disksubr.c */
		    /* including the bugs :-( */
		    /* read a bad sector table */

#define BAD144_PART	2	/* XXX scattered magic numbers */
#define BSD_PART	0	/* XXX should be 2 but bad144.c uses 0 */
		    if (dl->d_partitions[BSD_PART].p_offset != 0)
			    dkbbnum = dl->d_partitions[BAD144_PART].p_offset
				      + dl->d_partitions[BAD144_PART].p_size;
		    else
			    dkbbnum = dl->d_secperunit;
		    dkbbnum -= dl->d_nsectors;

		    if (dl->d_secsize > DEV_BSIZE)
		      dkbbnum *= dl->d_secsize / DEV_BSIZE;
		    else
		      dkbbnum /= DEV_BSIZE / dl->d_secsize;
		    i = 0;
		    do_bad144 = 0;
		    do {
			/* XXX: what if the "DOS sector" < 512 bytes ??? */
			Bread(dosdev, dkbbnum + i);
			dkbptr = (struct dkbad *) I_ADDR;
/* XXX why is this not in <sys/dkbad.h> ??? */
#define DKBAD_MAGIC 0x4321
			if (dkbptr->bt_mbz == 0 &&
			        dkbptr->bt_flag == DKBAD_MAGIC) {
			    dkb = *dkbptr;	/* structure copy */
			    do_bad144 = 1;
			    break;
			}
			i += 2;
		    } while (i < 10 && (u_long) i < dl->d_nsectors);
		    if (!do_bad144)
		      printf("Bad badsect table\n");
		    else
		      printf("Using bad144 bad sector at %ld\n", dkbbnum+i);
		}
#endif
	}
	return 0;
}
Ejemplo n.º 5
0
int
devopen(void)
{
	struct dos_partition *dptr;
	struct disklabel *dl;
	char *p;
	int i, sector = 0, di, dosdev_copy;

	dosdev_copy = dosdev;
	di = get_diskinfo(dosdev_copy);
	spt = SPT(di);

	/* Hack for 2.88MB floppy drives. */
	if (!(dosdev_copy & 0x80) && spt == 36)
		spt = 18;

	spc = spt * HEADS(di);

#ifndef RAWBOOT
	{
#ifdef	EMBEDDED_DISKLABEL
		dl = &disklabel;
#else	EMBEDDED_DISKLABEL
		p = Bread(dosdev_copy, 0);
		dptr = (struct dos_partition *)(p+DOSPARTOFF);
		slice = WHOLE_DISK_SLICE;
		for (i = 0; i < NDOSPART; i++, dptr++)
			if (dptr->dp_typ == DOSPTYP_386BSD) {
				slice = BASE_SLICE + i;
				sector = dptr->dp_start;
				break;
			}
		p = Bread(dosdev_copy, sector + LABELSECTOR);
		dl=((struct disklabel *)p);
		disklabel = *dl;	/* structure copy (maybe useful later)*/
#endif	EMBEDDED_DISKLABEL
		if (dl->d_magic != DISKMAGIC) {
			printf("bad disklabel\n");
			return 1;
		}
		if( (maj == 4) || (maj == 0) || (maj == 1))
		{
			if (dl->d_type == DTYPE_SCSI)
			{
				maj = 4; /* use scsi as boot dev */
			}
			else
			{
				maj = 0; /* must be ESDI/IDE */
			}
		}
		/* This little trick is for OnTrack DiskManager disks */
		boff = dl->d_partitions[part].p_offset -
			dl->d_partitions[2].p_offset + sector;

		bsize = dl->d_partitions[part].p_size;
		if (bsize == 0) {
			printf("empty partition\n");
			return 1;
		}

	}
#endif /* RAWBOOT */
	return 0;
}
Ejemplo n.º 6
0
dlgStdPad::dlgStdPad(_cfg_port *cfg_port, QWidget *parent = 0) : QDialog(parent) {
	QFont f9, f8;

	f9.setPointSize(9);
	f9.setWeight(QFont::Light);
	f8.setPointSize(8);
	f8.setWeight(QFont::Light);

	memset(&data, 0x00, sizeof(data));
	memcpy(&data.cfg, cfg_port, sizeof(_cfg_port));

	setupUi(this);

	setFont(parent->font());

	groupBox_controller->setTitle(tr("Controller %1 : Standard Pad").arg(cfg_port->id));
	tabWidget->setCurrentIndex(JOYSTICK);
	combo_id_init();

	for (int a = KEYBOARD; a <= JOYSTICK; a++) {
		QPlainTextEdit *txt;
		QPushButton *bt;

		txt = findChild<QPlainTextEdit *>("plainTextEdit_" + SPT(a) + "_info");

		if (txt->font().pointSize() > 9) {
			txt->setFont(f9);
		}

		bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_Sequence");
		bt->setProperty("myType", QVariant(a));
		connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_in_sequence_clicked(bool)));

		bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_Unset_all");
		bt->setProperty("myType", QVariant(a));
		connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_unset_all_clicked(bool)));

		bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_Defaults");
		bt->setProperty("myType", QVariant(a));
		connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_defaults_clicked(bool)));

		for (int b = BUT_A; b < MAX_STD_PAD_BUTTONS; b++) {
			int vbutton = b + (a * MAX_STD_PAD_BUTTONS);
			QPushButton *unset;

			bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_" + SPB(b));
			unset = findChild<QPushButton *>("pushButton_" + SPT(a) + "_unset_" + SPB(b));

			if (bt->font().pointSize() > 9) {
				bt->setFont(f9);
			}
			if (unset->font().pointSize() > 8) {
				unset->setFont(f8);
			}

			if (a == KEYBOARD) {
				bt->setText(inpObject::kbd_keyval_to_name(data.cfg.port.input[a][b]));
			} else {
				bt->setText(uQString(jsv_to_name(data.cfg.port.input[a][b])));
			}

			bt->installEventFilter(this);
			bt->setProperty("myVbutton", QVariant(vbutton));
			unset->setProperty("myVbutton", QVariant(vbutton));

			connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_input_clicked(bool)));
			connect(unset, SIGNAL(clicked(bool)), this, SLOT(s_unset_clicked(bool)));
		}
	}

	{
		comboBox_Controller_type->addItem(tr("Auto"));
		comboBox_Controller_type->addItem(tr("Original"));
		comboBox_Controller_type->addItem(tr("3rd-party"));
		comboBox_Controller_type->setCurrentIndex(data.cfg.port.type_pad);
		connect(comboBox_Controller_type, SIGNAL(activated(int)), this,
				SLOT(s_combobox_controller_type_activated(int)));
	}

	for (int i = TURBOA; i <= TURBOB; i++) {
		QSlider *tb = findChild<QSlider *>("horizontalSlider_" + SPB(i + TRB_A));
		QLabel *label = findChild<QLabel *>("label_value_slider_" + SPB(i + TRB_A));

		tb->setRange(1, TURBO_BUTTON_DELAY_MAX);
		tb->setProperty("myTurbo", QVariant(i));
		tb->setValue(data.cfg.port.turbo[i].frequency);
		connect(tb, SIGNAL(valueChanged(int)), this, SLOT(s_slider_td_value_changed(int)));

		label->setFixedWidth(label->sizeHint().width());
		td_update_label(i, data.cfg.port.turbo[i].frequency);
	}

	pushButton_Apply->setProperty("myPointer", QVariant::fromValue(((void *)cfg_port)));
	connect(pushButton_Apply, SIGNAL(clicked(bool)), this, SLOT(s_apply_clicked(bool)));
	connect(pushButton_Discard, SIGNAL(clicked(bool)), this, SLOT(s_discard_clicked(bool)));

	setAttribute(Qt::WA_DeleteOnClose);
	setFixedSize(width(), height());

	setFocusPolicy(Qt::StrongFocus);
	groupBox_controller->setFocus(Qt::ActiveWindowFocusReason);

	data.joy.timer = new QTimer(this);
	connect(data.joy.timer, SIGNAL(timeout()), this, SLOT(s_pad_joy_read_timer()));

	data.seq.timer = new QTimer(this);
	connect(data.seq.timer, SIGNAL(timeout()), this, SLOT(s_pad_in_sequence_timer()));

	installEventFilter(this);
}