protos.h 2.07 KB
/*
 * Copyright (C) 1998 by the Board of Trustees
 *    of Leland Stanford Junior University.
 * Copyright (C) 1998 Digital Equipment Corporation
 *
 * This file is part of the SimOS distribution.
 * See LICENSE file for terms of the license.
 *
 */

#ifndef _PROTOS_H_
#define _PROTOS_H_

/*
 * Prototype declarations and inlined functions used in several source files
 */

#include <malloc.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <standards.h>

#include "globals.h"
#include "sim.h"

extern void fatal __ ((char *,...));
extern void warning __ ((char *,...));
static ulong map_shared (thread_ptr, long);
extern void wakeup_thr (thread_ptr pthread);
extern void sleep_thr (thread_ptr pthread);
extern void aint_cvt_fp_mem (int opnum, double fpreg, long *memloc);
ulong tlb_miss (thread_ptr pthread, long addr,
		long vpage, long tbkey, long tbtag, int mmap);

/*
 * A direct mapped TLB of size TB_SIZE is being simulated here. So, the TLB
 * lookup is very fast. If we miss in the TLB, a tlb_miss handler is
 * invoked. 
 */

#ifdef __GNUC__
inline
#else
# pragma inline(addr2phys)
#endif
ulong static
addr2phys (thread_ptr pthread, long addr)
{
    long vpage, tbkey, tbtag;
    struct page_table_entry *pg;

    vpage = TB_VPAGE (addr);
    tbkey = TB_KEY (vpage);
    tbtag = TB_TAG (vpage);

    pg = pthread->page_bucket[tbkey];
    if (pg) {
	    if (pg->lookaside->tag == tbtag) {
		return ((ulong) pg->lookaside->page + TB_OFFSET (addr));
	    }
    }
    return (tlb_miss (pthread, addr, vpage, tbkey, tbtag, 0));
}

#ifdef SOLO
#ifdef __GNUC__
inline
#else
# pragma inline(text_addr2phys)
#endif
ulong static
text_addr2phys (thread_ptr pthread, long addr)
{
    long vpage, tbkey, tbtag;
    struct page_table_entry *pg;

    vpage = TB_VPAGE (addr);
    tbkey = TB_KEY (vpage);
    tbtag = TB_TAG (vpage);

    pg = pthread->page_bucket[tbkey];
    if (pg) {
	    if (pg->lookaside->tag == tbtag) {
		return ((ulong) pg->lookaside->page + TB_OFFSET (addr));
	    }
    }
    return (text_tlb_miss (pthread, addr, vpage, tbkey, tbtag, 0));
}
#endif


#endif /* _PROTOS_H */