Beispiel #1
0
unsigned long
ide_device_size(unsigned short ideno) {
    if (ide_device_valid(ideno)) {
        return ide_devices[ideno]->lba;
    }
    return 0;
}
Beispiel #2
0
void
swapfs_init(void) {
    static_assert((PGSIZE % SECTSIZE) == 0);
    if (!ide_device_valid(SWAP_DEV_NO)) {
        panic("swap fs isn't available.\n");
    }
    max_swap_offset = ide_device_size(SWAP_DEV_NO) / (PGSIZE / SECTSIZE);
}
Beispiel #3
0
static void
disk0_device_init(struct device *dev) {
    static_assert(DISK0_BLKSIZE % SECTSIZE == 0);
    if (!ide_device_valid(DISK0_DEV_NO)) {
        panic("disk0 device isn't available.\n");
    }
    dev->d_blocks = ide_device_size(DISK0_DEV_NO) / DISK0_BLK_NSECT;
    dev->d_blocksize = DISK0_BLKSIZE;
    dev->d_open = disk0_open;
    dev->d_close = disk0_close;
    dev->d_io = disk0_io;
    dev->d_ioctl = disk0_ioctl;
    sem_init(&(disk0_sem), 1);

    static_assert(DISK0_BUFSIZE % DISK0_BLKSIZE == 0);
    if ((disk0_buffer = kmalloc(DISK0_BUFSIZE)) == NULL) {
        panic("disk0 alloc buffer failed.\n");
    }
}
Beispiel #4
0
static void mmc0_device_init(struct device *dev)
{
	memset(dev, 0, sizeof(*dev));
	static_assert(MMC0_BLKSIZE % SECTSIZE == 0);
	if (!ide_device_valid(MMC0_DEV_NO)) {
		panic("mmc0 device isn't available.\n");
	}
	dev->d_blocks = ide_device_size(MMC0_DEV_NO) / MMC0_BLK_NSECT;
	dev->d_blocksize = MMC0_BLKSIZE;
	dev->d_open = mmc0_open;
	dev->d_close = mmc0_close;
	dev->d_io = mmc0_io;
	dev->d_ioctl = mmc0_ioctl;
	sem_init(&(mmc0_sem), 1);

	static_assert(MMC0_BUFSIZE % MMC0_BLKSIZE == 0);
	if ((mmc0_buffer = kmalloc(MMC0_BUFSIZE)) == NULL) {
		panic("mmc0 alloc buffer failed.\n");
	}
}