OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc2/] [or1ksim/] [cpu/] [or32/] [op_i386.h] - Blame information for rev 1780

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1452 nogj
/* op_i386.h -- i386 specific support routines for micro operations
2
   Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org
3
 
4
This file is part of OpenRISC 1000 Architectural Simulator.
5
 
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
 
20
#include "common_i386.h"
21
 
22
#define OP_JUMP(x) asm("jmp *%0" : : "rm" (x))
23
 
24
#define FORCE_RET asm volatile ("")
25
 
26
/* Handles the scheduler and PC updateing.  Yes, useing MMX is a requirement. It
27
 * just won't change.  This must be as compact as possible */
28 1481 nogj
#define HANDLE_SCHED(func, jmp) asm("paddd %%mm1, %%mm0\n" \
29
                                    "\tmovd %%mm0, %%eax\n" \
30
                                    "\ttestl %%eax, %%eax\n" \
31
                                    "\tjg ." jmp "\n" \
32
                                    "\tcall "#func"\n" \
33
                                    "\t." jmp ":" : : )
34 1452 nogj
 
35
static inline int32_t do_cycles(void)
36
{
37
  register uint32_t cycles;
38
 
39
  asm("paddd %%mm1, %%mm0\n"
40
      "\tmovd %%mm0, %0\n"
41
      : "=r" (cycles));
42
  return cycles;
43
}
44
 
45
/* Joins runtime.sim.mem_cycles with the cycle counter */
46
static inline void join_mem_cycles(void)
47
{
48
  runtime.sim.mem_cycles = -runtime.sim.mem_cycles;
49
  asm volatile ("movd %0, %%mm2\n"
50
                "\tpaddd %%mm2, %%mm0"
51
                : : "m" (runtime.sim.mem_cycles));
52
  runtime.sim.mem_cycles = 0;
53
}
54
 
55 1481 nogj
static inline void or_longjmp(void *loc) __attribute__((noreturn));
56
static inline void or_longjmp(void *loc)
57
{
58
  /* We push a trampoline address (dyn_ret_stack_prot) onto the stack to be able
59
   * to detect if any ret instructions found their way into an operation. */
60
  asm("\tmovl %0, %%eax\n"
61
      "\tmovl %1, %%esp\n"
62
      "\tmovl $%2, %%ebp\n"
63
      "\tpush $dyn_ret_stack_prot\n"
64
      "\tpush $dyn_ret_stack_prot\n"
65
      "\tpush $dyn_ret_stack_prot\n"
66
      "\tjmp *%%eax\n"
67
      :
68
      : "m" (loc),
69
        "m" (rec_stack_base),
70
        "m" (cpu_state));
71
}
72
 
73
 
74
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.