Commit fc01f7e7 authored by bellard's avatar bellard

IDE emulation


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@291 c046a42c-6fe2-441c-8c8c-71466251a162
parent 3b0dca51
/*
* QEMU System Emulator block driver
*
* Copyright (c) 2003 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <getopt.h>
#include <inttypes.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <sys/time.h>
#include <malloc.h>
#include <termios.h>
#include <sys/poll.h>
#include <errno.h>
#include <sys/wait.h>
#include "vl.h"
struct BlockDriverState {
int fd;
int64_t total_sectors;
};
BlockDriverState *bdrv_open(const char *filename)
{
BlockDriverState *bs;
int fd;
int64_t size;
bs = malloc(sizeof(BlockDriverState));
if(!bs)
return NULL;
fd = open(filename, O_RDWR);
if (fd < 0) {
close(fd);
free(bs);
return NULL;
}
size = lseek64(fd, 0, SEEK_END);
bs->total_sectors = size / 512;
bs->fd = fd;
return bs;
}
void bdrv_close(BlockDriverState *bs)
{
close(bs->fd);
free(bs);
}
/* return -1 if error */
int bdrv_read(BlockDriverState *bs, int64_t sector_num,
uint8_t *buf, int nb_sectors)
{
int ret;
lseek64(bs->fd, sector_num * 512, SEEK_SET);
ret = read(bs->fd, buf, nb_sectors * 512);
if (ret != nb_sectors * 512)
return -1;
else
return 0;
}
/* return -1 if error */
int bdrv_write(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors)
{
int ret;
lseek64(bs->fd, sector_num * 512, SEEK_SET);
ret = write(bs->fd, buf, nb_sectors * 512);
if (ret != nb_sectors * 512)
return -1;
else
return 0;
}
void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr)
{
*nb_sectors_ptr = bs->total_sectors;
}
......@@ -46,6 +46,9 @@
#include "cpu-i386.h"
#include "disas.h"
#include "thunk.h"
#include "vl.h"
#define DEBUG_LOGFILE "/tmp/vl.log"
#define DEFAULT_NETWORK_SCRIPT "/etc/vl-ifup"
......@@ -175,17 +178,15 @@ struct __attribute__ ((packed)) linux_params {
typedef void (IOPortWriteFunc)(CPUX86State *env, uint32_t address, uint32_t data);
typedef uint32_t (IOPortReadFunc)(CPUX86State *env, uint32_t address);
#define MAX_IOPORTS 1024
#define MAX_IOPORTS 4096
char phys_ram_file[1024];
CPUX86State *global_env;
CPUX86State *cpu_single_env;
FILE *logfile = NULL;
int loglevel;
IOPortReadFunc *ioport_readb_table[MAX_IOPORTS];
IOPortWriteFunc *ioport_writeb_table[MAX_IOPORTS];
IOPortReadFunc *ioport_readw_table[MAX_IOPORTS];
IOPortWriteFunc *ioport_writew_table[MAX_IOPORTS];
IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS];
IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS];
/***********************************************************/
/* x86 io ports */
......@@ -195,7 +196,7 @@ uint32_t default_ioport_readb(CPUX86State *env, uint32_t address)
#ifdef DEBUG_UNUSED_IOPORT
fprintf(stderr, "inb: port=0x%04x\n", address);
#endif
return 0;
return 0xff;
}
void default_ioport_writeb(CPUX86State *env, uint32_t address, uint32_t data)
......@@ -209,62 +210,79 @@ void default_ioport_writeb(CPUX86State *env, uint32_t address, uint32_t data)
uint32_t default_ioport_readw(CPUX86State *env, uint32_t address)
{
uint32_t data;
data = ioport_readb_table[address](env, address);
data |= ioport_readb_table[address + 1](env, address + 1) << 8;
data = ioport_read_table[0][address](env, address);
data |= ioport_read_table[0][address + 1](env, address + 1) << 8;
return data;
}
void default_ioport_writew(CPUX86State *env, uint32_t address, uint32_t data)
{
ioport_writeb_table[address](env, address, data & 0xff);
ioport_writeb_table[address + 1](env, address + 1, (data >> 8) & 0xff);
ioport_write_table[0][address](env, address, data & 0xff);
ioport_write_table[0][address + 1](env, address + 1, (data >> 8) & 0xff);
}
void init_ioports(void)
uint32_t default_ioport_readl(CPUX86State *env, uint32_t address)
{
int i;
for(i = 0; i < MAX_IOPORTS; i++) {
ioport_readb_table[i] = default_ioport_readb;
ioport_writeb_table[i] = default_ioport_writeb;
ioport_readw_table[i] = default_ioport_readw;
ioport_writew_table[i] = default_ioport_writew;
}
#ifdef DEBUG_UNUSED_IOPORT
fprintf(stderr, "inl: port=0x%04x\n", address);
#endif
return 0xffffffff;
}
int register_ioport_readb(int start, int length, IOPortReadFunc *func)
void default_ioport_writel(CPUX86State *env, uint32_t address, uint32_t data)
{
int i;
for(i = start; i < start + length; i++)
ioport_readb_table[i] = func;
return 0;
#ifdef DEBUG_UNUSED_IOPORT
fprintf(stderr, "outl: port=0x%04x data=0x%02x\n", address, data);
#endif
}
int register_ioport_writeb(int start, int length, IOPortWriteFunc *func)
void init_ioports(void)
{
int i;
for(i = start; i < start + length; i++)
ioport_writeb_table[i] = func;
return 0;
for(i = 0; i < MAX_IOPORTS; i++) {
ioport_read_table[0][i] = default_ioport_readb;
ioport_write_table[0][i] = default_ioport_writeb;
ioport_read_table[1][i] = default_ioport_readw;
ioport_write_table[1][i] = default_ioport_writew;
ioport_read_table[2][i] = default_ioport_readl;
ioport_write_table[2][i] = default_ioport_writel;
}
}
int register_ioport_readw(int start, int length, IOPortReadFunc *func)
/* size is the word size in byte */
int register_ioport_read(int start, int length, IOPortReadFunc *func, int size)
{
int i;
int i, bsize;
for(i = start; i < start + length; i += 2)
ioport_readw_table[i] = func;
if (size == 1)
bsize = 0;
else if (size == 2)
bsize = 1;
else if (size == 4)
bsize = 2;
else
return -1;
for(i = start; i < start + length; i += size)
ioport_read_table[bsize][i] = func;
return 0;
}
int register_ioport_writew(int start, int length, IOPortWriteFunc *func)
/* size is the word size in byte */
int register_ioport_write(int start, int length, IOPortWriteFunc *func, int size)
{
int i;
int i, bsize;
for(i = start; i < start + length; i += 2)
ioport_writew_table[i] = func;
if (size == 1)
bsize = 0;
else if (size == 2)
bsize = 1;
else if (size == 4)
bsize = 2;
else
return -1;
for(i = start; i < start + length; i += size)
ioport_write_table[bsize][i] = func;
return 0;
}
......@@ -339,33 +357,32 @@ int load_image(const char *filename, uint8_t *addr)
void cpu_x86_outb(CPUX86State *env, int addr, int val)
{
ioport_writeb_table[addr & (MAX_IOPORTS - 1)](env, addr, val);
ioport_write_table[0][addr & (MAX_IOPORTS - 1)](env, addr, val);
}
void cpu_x86_outw(CPUX86State *env, int addr, int val)
{
ioport_writew_table[addr & (MAX_IOPORTS - 1)](env, addr, val);
ioport_write_table[1][addr & (MAX_IOPORTS - 1)](env, addr, val);
}
void cpu_x86_outl(CPUX86State *env, int addr, int val)
{
fprintf(stderr, "outl: port=0x%04x, data=%08x\n", addr, val);
ioport_write_table[2][addr & (MAX_IOPORTS - 1)](env, addr, val);
}
int cpu_x86_inb(CPUX86State *env, int addr)
{
return ioport_readb_table[addr & (MAX_IOPORTS - 1)](env, addr);
return ioport_read_table[0][addr & (MAX_IOPORTS - 1)](env, addr);
}
int cpu_x86_inw(CPUX86State *env, int addr)
{
return ioport_readw_table[addr & (MAX_IOPORTS - 1)](env, addr);
return ioport_read_table[1][addr & (MAX_IOPORTS - 1)](env, addr);
}
int cpu_x86_inl(CPUX86State *env, int addr)
{
fprintf(stderr, "inl: port=0x%04x\n", addr);
return 0;
return ioport_read_table[2][addr & (MAX_IOPORTS - 1)](env, addr);
}
/***********************************************************/
......@@ -511,8 +528,8 @@ void cmos_init(void)
cmos_data[REG_EQUIPMENT_BYTE] = 0x02; /* FPU is there */
register_ioport_writeb(0x70, 2, cmos_ioport_write);
register_ioport_readb(0x70, 2, cmos_ioport_read);
register_ioport_write(0x70, 2, cmos_ioport_write, 1);
register_ioport_read(0x70, 2, cmos_ioport_read, 1);
}
/***********************************************************/
......@@ -726,10 +743,10 @@ uint32_t pic_ioport_read(CPUX86State *env, uint32_t addr)
void pic_init(void)
{
register_ioport_writeb(0x20, 2, pic_ioport_write);
register_ioport_readb(0x20, 2, pic_ioport_read);
register_ioport_writeb(0xa0, 2, pic_ioport_write);
register_ioport_readb(0xa0, 2, pic_ioport_read);
register_ioport_write(0x20, 2, pic_ioport_write, 1);
register_ioport_read(0x20, 2, pic_ioport_read, 1);
register_ioport_write(0xa0, 2, pic_ioport_write, 1);
register_ioport_read(0xa0, 2, pic_ioport_read, 1);
}
/***********************************************************/
......@@ -1031,11 +1048,11 @@ void pit_init(void)
pit_load_count(s, 0);
}
register_ioport_writeb(0x40, 4, pit_ioport_write);
register_ioport_readb(0x40, 3, pit_ioport_read);
register_ioport_write(0x40, 4, pit_ioport_write, 1);
register_ioport_read(0x40, 3, pit_ioport_read, 1);
register_ioport_readb(0x61, 1, speaker_ioport_read);
register_ioport_writeb(0x61, 1, speaker_ioport_write);
register_ioport_read(0x61, 1, speaker_ioport_read, 1);
register_ioport_write(0x61, 1, speaker_ioport_write, 1);
}
/***********************************************************/
......@@ -1277,8 +1294,8 @@ void serial_init(void)
s->lsr = UART_LSR_TEMT | UART_LSR_THRE;
register_ioport_writeb(0x3f8, 8, serial_ioport_write);
register_ioport_readb(0x3f8, 8, serial_ioport_read);
register_ioport_write(0x3f8, 8, serial_ioport_write, 1);
register_ioport_read(0x3f8, 8, serial_ioport_read, 1);
term_init();
}
......@@ -1444,7 +1461,7 @@ int net_init(void)
close(fd);
return -1;
}
printf("connected to host network interface: %s\n", ifr.ifr_name);
printf("Connected to host network interface: %s\n", ifr.ifr_name);
fcntl(fd, F_SETFL, O_NONBLOCK);
net_fd = fd;
......@@ -1739,19 +1756,624 @@ uint32_t ne2000_reset_ioport_read(CPUX86State *env, uint32_t addr)
void ne2000_init(void)
{
register_ioport_writeb(NE2000_IOPORT, 16, ne2000_ioport_write);
register_ioport_readb(NE2000_IOPORT, 16, ne2000_ioport_read);
register_ioport_write(NE2000_IOPORT, 16, ne2000_ioport_write, 1);
register_ioport_read(NE2000_IOPORT, 16, ne2000_ioport_read, 1);
register_ioport_writeb(NE2000_IOPORT + 0x10, 1, ne2000_asic_ioport_write);
register_ioport_readb(NE2000_IOPORT + 0x10, 1, ne2000_asic_ioport_read);
register_ioport_writew(NE2000_IOPORT + 0x10, 2, ne2000_asic_ioport_write);
register_ioport_readw(NE2000_IOPORT + 0x10, 2, ne2000_asic_ioport_read);
register_ioport_write(NE2000_IOPORT + 0x10, 1, ne2000_asic_ioport_write, 1);
register_ioport_read(NE2000_IOPORT + 0x10, 1, ne2000_asic_ioport_read, 1);
register_ioport_write(NE2000_IOPORT + 0x10, 2, ne2000_asic_ioport_write, 2);
register_ioport_read(NE2000_IOPORT + 0x10, 2, ne2000_asic_ioport_read, 2);
register_ioport_writeb(NE2000_IOPORT + 0x1f, 1, ne2000_reset_ioport_write);
register_ioport_readb(NE2000_IOPORT + 0x1f, 1, ne2000_reset_ioport_read);
register_ioport_write(NE2000_IOPORT + 0x1f, 1, ne2000_reset_ioport_write, 1);
register_ioport_read(NE2000_IOPORT + 0x1f, 1, ne2000_reset_ioport_read, 1);
ne2000_reset();
}
/***********************************************************/
/* ide emulation */
//#define DEBUG_IDE
/* Bits of HD_STATUS */
#define ERR_STAT 0x01
#define INDEX_STAT 0x02
#define ECC_STAT 0x04 /* Corrected error */
#define DRQ_STAT 0x08
#define SEEK_STAT 0x10
#define SRV_STAT 0x10
#define WRERR_STAT 0x20
#define READY_STAT 0x40
#define BUSY_STAT 0x80
/* Bits for HD_ERROR */
#define MARK_ERR 0x01 /* Bad address mark */
#define TRK0_ERR 0x02 /* couldn't find track 0 */
#define ABRT_ERR 0x04 /* Command aborted */
#define MCR_ERR 0x08 /* media change request */
#define ID_ERR 0x10 /* ID field not found */
#define MC_ERR 0x20 /* media changed */
#define ECC_ERR 0x40 /* Uncorrectable ECC error */
#define BBD_ERR 0x80 /* pre-EIDE meaning: block marked bad */
#define ICRC_ERR 0x80 /* new meaning: CRC error during transfer */
/* Bits of HD_NSECTOR */
#define CD 0x01
#define IO 0x02
#define REL 0x04
#define TAG_MASK 0xf8
#define IDE_CMD_RESET 0x04
#define IDE_CMD_DISABLE_IRQ 0x02
/* ATA/ATAPI Commands pre T13 Spec */
#define WIN_NOP 0x00
/*
* 0x01->0x02 Reserved
*/
#define CFA_REQ_EXT_ERROR_CODE 0x03 /* CFA Request Extended Error Code */
/*
* 0x04->0x07 Reserved
*/
#define WIN_SRST 0x08 /* ATAPI soft reset command */
#define WIN_DEVICE_RESET 0x08
/*
* 0x09->0x0F Reserved
*/
#define WIN_RECAL 0x10
#define WIN_RESTORE WIN_RECAL
/*
* 0x10->0x1F Reserved
*/
#define WIN_READ 0x20 /* 28-Bit */
#define WIN_READ_ONCE 0x21 /* 28-Bit without retries */
#define WIN_READ_LONG 0x22 /* 28-Bit */
#define WIN_READ_LONG_ONCE 0x23 /* 28-Bit without retries */
#define WIN_READ_EXT 0x24 /* 48-Bit */
#define WIN_READDMA_EXT 0x25 /* 48-Bit */
#define WIN_READDMA_QUEUED_EXT 0x26 /* 48-Bit */
#define WIN_READ_NATIVE_MAX_EXT 0x27 /* 48-Bit */
/*
* 0x28
*/
#define WIN_MULTREAD_EXT 0x29 /* 48-Bit */
/*
* 0x2A->0x2F Reserved
*/
#define WIN_WRITE 0x30 /* 28-Bit */
#define WIN_WRITE_ONCE 0x31 /* 28-Bit without retries */
#define WIN_WRITE_LONG 0x32 /* 28-Bit */
#define WIN_WRITE_LONG_ONCE 0x33 /* 28-Bit without retries */
#define WIN_WRITE_EXT 0x34 /* 48-Bit */
#define WIN_WRITEDMA_EXT 0x35 /* 48-Bit */
#define WIN_WRITEDMA_QUEUED_EXT 0x36 /* 48-Bit */
#define WIN_SET_MAX_EXT 0x37 /* 48-Bit */
#define CFA_WRITE_SECT_WO_ERASE 0x38 /* CFA Write Sectors without erase */
#define WIN_MULTWRITE_EXT 0x39 /* 48-Bit */
/*
* 0x3A->0x3B Reserved
*/
#define WIN_WRITE_VERIFY 0x3C /* 28-Bit */
/*
* 0x3D->0x3F Reserved
*/
#define WIN_VERIFY 0x40 /* 28-Bit - Read Verify Sectors */
#define WIN_VERIFY_ONCE 0x41 /* 28-Bit - without retries */
#define WIN_VERIFY_EXT 0x42 /* 48-Bit */
/*
* 0x43->0x4F Reserved
*/
#define WIN_FORMAT 0x50
/*
* 0x51->0x5F Reserved
*/
#define WIN_INIT 0x60
/*
* 0x61->0x5F Reserved
*/
#define WIN_SEEK 0x70 /* 0x70-0x7F Reserved */
#define CFA_TRANSLATE_SECTOR 0x87 /* CFA Translate Sector */
#define WIN_DIAGNOSE 0x90
#define WIN_SPECIFY 0x91 /* set drive geometry translation */
#define WIN_DOWNLOAD_MICROCODE 0x92
#define WIN_STANDBYNOW2 0x94
#define WIN_STANDBY2 0x96
#define WIN_SETIDLE2 0x97
#define WIN_CHECKPOWERMODE2 0x98
#define WIN_SLEEPNOW2 0x99
/*
* 0x9A VENDOR
*/
#define WIN_PACKETCMD 0xA0 /* Send a packet command. */
#define WIN_PIDENTIFY 0xA1 /* identify ATAPI device */
#define WIN_QUEUED_SERVICE 0xA2
#define WIN_SMART 0xB0 /* self-monitoring and reporting */
#define CFA_ERASE_SECTORS 0xC0
#define WIN_MULTREAD 0xC4 /* read sectors using multiple mode*/
#define WIN_MULTWRITE 0xC5 /* write sectors using multiple mode */
#define WIN_SETMULT 0xC6 /* enable/disable multiple mode */
#define WIN_READDMA_QUEUED 0xC7 /* read sectors using Queued DMA transfers */
#define WIN_READDMA 0xC8 /* read sectors using DMA transfers */
#define WIN_READDMA_ONCE 0xC9 /* 28-Bit - without retries */
#define WIN_WRITEDMA 0xCA /* write sectors using DMA transfers */
#define WIN_WRITEDMA_ONCE 0xCB /* 28-Bit - without retries */
#define WIN_WRITEDMA_QUEUED 0xCC /* write sectors using Queued DMA transfers */
#define CFA_WRITE_MULTI_WO_ERASE 0xCD /* CFA Write multiple without erase */
#define WIN_GETMEDIASTATUS 0xDA
#define WIN_ACKMEDIACHANGE 0xDB /* ATA-1, ATA-2 vendor */
#define WIN_POSTBOOT 0xDC
#define WIN_PREBOOT 0xDD
#define WIN_DOORLOCK 0xDE /* lock door on removable drives */
#define WIN_DOORUNLOCK 0xDF /* unlock door on removable drives */
#define WIN_STANDBYNOW1 0xE0
#define WIN_IDLEIMMEDIATE 0xE1 /* force drive to become "ready" */
#define WIN_STANDBY 0xE2 /* Set device in Standby Mode */
#define WIN_SETIDLE1 0xE3
#define WIN_READ_BUFFER 0xE4 /* force read only 1 sector */
#define WIN_CHECKPOWERMODE1 0xE5
#define WIN_SLEEPNOW1 0xE6
#define WIN_FLUSH_CACHE 0xE7
#define WIN_WRITE_BUFFER 0xE8 /* force write only 1 sector */
#define WIN_WRITE_SAME 0xE9 /* read ata-2 to use */
/* SET_FEATURES 0x22 or 0xDD */
#define WIN_FLUSH_CACHE_EXT 0xEA /* 48-Bit */
#define WIN_IDENTIFY 0xEC /* ask drive to identify itself */
#define WIN_MEDIAEJECT 0xED
#define WIN_IDENTIFY_DMA 0xEE /* same as WIN_IDENTIFY, but DMA */
#define WIN_SETFEATURES 0xEF /* set special drive features */
#define EXABYTE_ENABLE_NEST 0xF0
#define WIN_SECURITY_SET_PASS 0xF1
#define WIN_SECURITY_UNLOCK 0xF2
#define WIN_SECURITY_ERASE_PREPARE 0xF3
#define WIN_SECURITY_ERASE_UNIT 0xF4
#define WIN_SECURITY_FREEZE_LOCK 0xF5
#define WIN_SECURITY_DISABLE 0xF6
#define WIN_READ_NATIVE_MAX 0xF8 /* return the native maximum address */
#define WIN_SET_MAX 0xF9
#define DISABLE_SEAGATE 0xFB
#define MAX_MULT_SECTORS 16
#define MAX_DISKS 2
struct IDEState;
typedef void EndTransferFunc(struct IDEState *);
typedef struct IDEState {
/* ide config */
int cylinders, heads, sectors;
int64_t nb_sectors;
int mult_sectors;
int irq;
/* ide regs */
uint8_t feature;
uint8_t error;
uint8_t nsector;
uint8_t sector;
uint8_t lcyl;
uint8_t hcyl;
uint8_t select;
uint8_t status;
/* 0x3f6 command, only meaningful for drive 0 */
uint8_t cmd;
/* depends on bit 4 in select, only meaningful for drive 0 */
struct IDEState *cur_drive;
BlockDriverState *bs;
EndTransferFunc *end_transfer_func;
uint8_t *data_ptr;
uint8_t *data_end;
uint8_t io_buffer[MAX_MULT_SECTORS*512 + 4];
} IDEState;
BlockDriverState *bs_table[MAX_DISKS];
IDEState ide_state[MAX_DISKS];
static void padstr(char *str, const char *src, int len)
{
int i, v;
for(i = 0; i < len; i++) {
if (*src)
v = *src++;
else
v = ' ';
*(char *)((long)str ^ 1) = v;
str++;
}
}
static void ide_identify(IDEState *s)
{
uint16_t *p;
unsigned int oldsize;
memset(s->io_buffer, 0, 512);
p = (uint16_t *)s->io_buffer;
stw(p + 0, 0x0040);
stw(p + 1, s->cylinders);
stw(p + 3, s->heads);
stw(p + 4, 512 * s->sectors); /* sectors */
stw(p + 5, 512); /* sector size */
stw(p + 6, s->sectors);
stw(p + 20, 3); /* buffer type */
stw(p + 21, 512); /* cache size in sectors */
stw(p + 22, 4); /* ecc bytes */
padstr((uint8_t *)(p + 27), "QEMU HARDDISK", 40);
// stw(p + 47, MAX_MULT_SECTORS);
stw(p + 48, 1); /* dword I/O */
stw(p + 49, 1 << 9); /* LBA supported, no DMA */
stw(p + 51, 0x200); /* PIO transfer cycle */
stw(p + 52, 0x200); /* DMA transfer cycle */
stw(p + 54, s->cylinders);
stw(p + 55, s->heads);
stw(p + 56, s->sectors);
oldsize = s->cylinders * s->heads * s->sectors;
stw(p + 57, oldsize);
stw(p + 58, oldsize >> 16);
if (s->mult_sectors)
stw(p + 59, 0x100 | s->mult_sectors);
stw(p + 60, s->nb_sectors);
stw(p + 61, s->nb_sectors >> 16);
stw(p + 80, (1 << 1) | (1 << 2));
stw(p + 82, (1 << 14));
stw(p + 83, (1 << 14));
stw(p + 84, (1 << 14));
stw(p + 85, (1 << 14));
stw(p + 86, 0);
stw(p + 87, (1 << 14));
}