ide_disk.cc revision 848
1837SN/A/*
21762SN/A * Copyright (c) 2003 The Regents of The University of Michigan
3837SN/A * All rights reserved.
4837SN/A *
5837SN/A * Redistribution and use in source and binary forms, with or without
6837SN/A * modification, are permitted provided that the following conditions are
7837SN/A * met: redistributions of source code must retain the above copyright
8837SN/A * notice, this list of conditions and the following disclaimer;
9837SN/A * redistributions in binary form must reproduce the above copyright
10837SN/A * notice, this list of conditions and the following disclaimer in the
11837SN/A * documentation and/or other materials provided with the distribution;
12837SN/A * neither the name of the copyright holders nor the names of its
13837SN/A * contributors may be used to endorse or promote products derived from
14837SN/A * this software without specific prior written permission.
15837SN/A *
16837SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17837SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18837SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19837SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20837SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21837SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22837SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23837SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24837SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25837SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26837SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665SN/A */
282760SN/A
292760SN/A/** @file
30837SN/A * Device model implementation for an IDE disk
31837SN/A */
321730SN/A
33837SN/A#include <cerrno>
34837SN/A#include <cstring>
35837SN/A#include <deque>
3611263Sandreas.sandberg@arm.com#include <string>
3711263Sandreas.sandberg@arm.com
3811263Sandreas.sandberg@arm.com#include "base/cprintf.hh" // csprintf
39837SN/A#include "base/trace.hh"
4010469SN/A#include "dev/disk_image.hh"
41837SN/A#include "dev/ide_disk.hh"
42837SN/A#include "sim/builder.hh"
435882SN/A#include "sim/sim_object.hh"
44837SN/A#include "sim/universe.hh"
456216SN/A
466658SN/Ausing namespace std;
478232SN/A
4811263Sandreas.sandberg@arm.comIdeDisk::IdeDisk(const string &name, DiskImage *img, int delay)
492566SN/A    : SimObject(name), ctrl(NULL), image(img)
503348SN/A{
514762SN/A    diskDelay = delay * ticksPerSecond / 1000;
522566SN/A}
53854SN/A
548737SN/AIdeDisk::~IdeDisk()
558737SN/A{
5610469SN/A}
578737SN/A
588737SN/Avoid
598737SN/AIdeDisk::serialize(ostream &os)
608737SN/A{
61854SN/A}
62854SN/A
63854SN/Avoid
64854SN/AIdeDisk::unserialize(Checkpoint *cp, const string &section)
65854SN/A{
66854SN/A}
67854SN/A
68854SN/A#ifndef DOXYGEN_SHOULD_SKIP_THIS
69854SN/A
70854SN/ABEGIN_DECLARE_SIM_OBJECT_PARAMS(IdeDisk)
71854SN/A
72854SN/A    SimObjectParam<DiskImage *> image;
73854SN/A    Param<int> disk_delay;
74854SN/A
75854SN/AEND_DECLARE_SIM_OBJECT_PARAMS(IdeDisk)
76854SN/A
77854SN/ABEGIN_INIT_SIM_OBJECT_PARAMS(IdeDisk)
78854SN/A
79854SN/A    INIT_PARAM(image, "Disk image"),
80854SN/A    INIT_PARAM_DFLT(disk_delay, "Fixed disk delay in milliseconds", 0)
81854SN/A
82854SN/AEND_INIT_SIM_OBJECT_PARAMS(IdeDisk)
83854SN/A
84854SN/A
85854SN/ACREATE_SIM_OBJECT(IdeDisk)
86854SN/A{
87854SN/A    return new IdeDisk(getInstanceName(), image, disk_delay);
88854SN/A}
89854SN/A
90854SN/AREGISTER_SIM_OBJECT("IdeDisk", IdeDisk)
91837SN/A
921114SN/A#endif //DOXYGEN_SHOULD_SKIP_THIS
932107SN/A