110810Sbr@bsdpad.com/* 210810Sbr@bsdpad.com * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com> 310810Sbr@bsdpad.com * All rights reserved. 410810Sbr@bsdpad.com * 510810Sbr@bsdpad.com * This software was developed by the University of Cambridge Computer 610810Sbr@bsdpad.com * Laboratory as part of the CTSRD Project, with support from the UK Higher 710810Sbr@bsdpad.com * Education Innovation Fund (HEIF). 810810Sbr@bsdpad.com * 910810Sbr@bsdpad.com * Redistribution and use in source and binary forms, with or without 1010810Sbr@bsdpad.com * modification, are permitted provided that the following conditions are 1110810Sbr@bsdpad.com * met: redistributions of source code must retain the above copyright 1210810Sbr@bsdpad.com * notice, this list of conditions and the following disclaimer; 1310810Sbr@bsdpad.com * redistributions in binary form must reproduce the above copyright 1410810Sbr@bsdpad.com * notice, this list of conditions and the following disclaimer in the 1510810Sbr@bsdpad.com * documentation and/or other materials provided with the distribution; 1610810Sbr@bsdpad.com * neither the name of the copyright holders nor the names of its 1710810Sbr@bsdpad.com * contributors may be used to endorse or promote products derived from 1810810Sbr@bsdpad.com * this software without specific prior written permission. 1910810Sbr@bsdpad.com * 2010810Sbr@bsdpad.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2110810Sbr@bsdpad.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2210810Sbr@bsdpad.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2310810Sbr@bsdpad.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2410810Sbr@bsdpad.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2510810Sbr@bsdpad.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2610810Sbr@bsdpad.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2710810Sbr@bsdpad.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2810810Sbr@bsdpad.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2910810Sbr@bsdpad.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3010810Sbr@bsdpad.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3110810Sbr@bsdpad.com */ 3210810Sbr@bsdpad.com 3310810Sbr@bsdpad.com#ifndef __KERN_FREEBSD_EVENTS_HH__ 3410810Sbr@bsdpad.com#define __KERN_FREEBSD_EVENTS_HH__ 3510810Sbr@bsdpad.com 3610810Sbr@bsdpad.com#include "kern/system_events.hh" 3710810Sbr@bsdpad.com 3810810Sbr@bsdpad.comnamespace FreeBSD { 3910810Sbr@bsdpad.com 4010810Sbr@bsdpad.com/** A class to skip udelay() and related calls in the kernel. 4110810Sbr@bsdpad.com * This class has two additional parameters that take the argument to udelay and 4210810Sbr@bsdpad.com * manipulated it to come up with ns and eventually ticks to quiesce for. 4310810Sbr@bsdpad.com * See descriptions of argDivToNs and argMultToNs below. 4410810Sbr@bsdpad.com */ 4510810Sbr@bsdpad.comclass UDelayEvent : public SkipFuncEvent 4610810Sbr@bsdpad.com{ 4710810Sbr@bsdpad.com private: 4810810Sbr@bsdpad.com /** value to divide arg by to create ns. This is present beacues the linux 4910810Sbr@bsdpad.com * kernel code sometime precomputes the first multiply that is done in 5010810Sbr@bsdpad.com * udelay() if the parameter is a constant. We need to undo it so here is 5110810Sbr@bsdpad.com * how. */ 5210810Sbr@bsdpad.com uint64_t argDivToNs; 5310810Sbr@bsdpad.com 5410810Sbr@bsdpad.com /** value to multiple arg by to create ns. Nominally, this is 1000 to 5510810Sbr@bsdpad.com * convert us to ns, but since linux can do some preprocessing of constant 5610810Sbr@bsdpad.com * values something else might be required. */ 5710810Sbr@bsdpad.com uint64_t argMultToNs; 5810810Sbr@bsdpad.com 5910810Sbr@bsdpad.com public: 6010810Sbr@bsdpad.com UDelayEvent(PCEventQueue *q, const std::string &desc, Addr addr, 6110810Sbr@bsdpad.com uint64_t mult, uint64_t div) 6210810Sbr@bsdpad.com : SkipFuncEvent(q, desc, addr), argDivToNs(div), argMultToNs(mult) {} 6310810Sbr@bsdpad.com virtual void process(ThreadContext *xc); 6410810Sbr@bsdpad.com}; 6510810Sbr@bsdpad.com 6610810Sbr@bsdpad.com} 6710810Sbr@bsdpad.com 6810810Sbr@bsdpad.com#endif 69