1ec82026cSGerd Hoffmann /* 2ec82026cSGerd Hoffmann * QEMU IDE Emulation: ISA Bus support. 3ec82026cSGerd Hoffmann * 4ec82026cSGerd Hoffmann * Copyright (c) 2003 Fabrice Bellard 5ec82026cSGerd Hoffmann * Copyright (c) 2006 Openedhand Ltd. 6ec82026cSGerd Hoffmann * 7ec82026cSGerd Hoffmann * Permission is hereby granted, free of charge, to any person obtaining a copy 8ec82026cSGerd Hoffmann * of this software and associated documentation files (the "Software"), to deal 9ec82026cSGerd Hoffmann * in the Software without restriction, including without limitation the rights 10ec82026cSGerd Hoffmann * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11ec82026cSGerd Hoffmann * copies of the Software, and to permit persons to whom the Software is 12ec82026cSGerd Hoffmann * furnished to do so, subject to the following conditions: 13ec82026cSGerd Hoffmann * 14ec82026cSGerd Hoffmann * The above copyright notice and this permission notice shall be included in 15ec82026cSGerd Hoffmann * all copies or substantial portions of the Software. 16ec82026cSGerd Hoffmann * 17ec82026cSGerd Hoffmann * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18ec82026cSGerd Hoffmann * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19ec82026cSGerd Hoffmann * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20ec82026cSGerd Hoffmann * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21ec82026cSGerd Hoffmann * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22ec82026cSGerd Hoffmann * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23ec82026cSGerd Hoffmann * THE SOFTWARE. 24ec82026cSGerd Hoffmann */ 2559f2a787SGerd Hoffmann #include <hw/hw.h> 2659f2a787SGerd Hoffmann #include <hw/pc.h> 27ec82026cSGerd Hoffmann #include "block.h" 28ec82026cSGerd Hoffmann #include "block_int.h" 29ec82026cSGerd Hoffmann #include "sysemu.h" 30ec82026cSGerd Hoffmann #include "dma.h" 3159f2a787SGerd Hoffmann 3259f2a787SGerd Hoffmann #include <hw/ide/internal.h> 33ec82026cSGerd Hoffmann 34ec82026cSGerd Hoffmann /***********************************************************/ 35ec82026cSGerd Hoffmann /* ISA IDE definitions */ 36ec82026cSGerd Hoffmann 37cebbe6d4SGerd Hoffmann typedef struct ISAIDEState { 38cebbe6d4SGerd Hoffmann IDEBus *bus; 39cebbe6d4SGerd Hoffmann } ISAIDEState; 40cebbe6d4SGerd Hoffmann 41cebbe6d4SGerd Hoffmann static void isa_ide_save(QEMUFile* f, void *opaque) 42cebbe6d4SGerd Hoffmann { 43cebbe6d4SGerd Hoffmann ISAIDEState *s = opaque; 44cebbe6d4SGerd Hoffmann 45cebbe6d4SGerd Hoffmann idebus_save(f, s->bus); 46cebbe6d4SGerd Hoffmann ide_save(f, &s->bus->ifs[0]); 47cebbe6d4SGerd Hoffmann ide_save(f, &s->bus->ifs[1]); 48cebbe6d4SGerd Hoffmann } 49cebbe6d4SGerd Hoffmann 50cebbe6d4SGerd Hoffmann static int isa_ide_load(QEMUFile* f, void *opaque, int version_id) 51cebbe6d4SGerd Hoffmann { 52cebbe6d4SGerd Hoffmann ISAIDEState *s = opaque; 53cebbe6d4SGerd Hoffmann 54cebbe6d4SGerd Hoffmann idebus_load(f, s->bus, version_id); 55cebbe6d4SGerd Hoffmann ide_load(f, &s->bus->ifs[0], version_id); 56cebbe6d4SGerd Hoffmann ide_load(f, &s->bus->ifs[1], version_id); 57cebbe6d4SGerd Hoffmann return 0; 58cebbe6d4SGerd Hoffmann } 59cebbe6d4SGerd Hoffmann 60ec82026cSGerd Hoffmann void isa_ide_init(int iobase, int iobase2, qemu_irq irq, 61*f455e98cSGerd Hoffmann DriveInfo *hd0, DriveInfo *hd1) 62ec82026cSGerd Hoffmann { 63cebbe6d4SGerd Hoffmann ISAIDEState *s; 64ec82026cSGerd Hoffmann 65cebbe6d4SGerd Hoffmann s = qemu_mallocz(sizeof(*s)); 66cebbe6d4SGerd Hoffmann s->bus = qemu_mallocz(sizeof(IDEBus)); 67ec82026cSGerd Hoffmann 68cebbe6d4SGerd Hoffmann ide_init2(s->bus, hd0, hd1, irq); 69cebbe6d4SGerd Hoffmann ide_init_ioport(s->bus, iobase, iobase2); 70cebbe6d4SGerd Hoffmann register_savevm("isa-ide", 0, 3, isa_ide_save, isa_ide_load, s); 71ec82026cSGerd Hoffmann } 72