OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [sim/] [cr16/] [endian.c] - Blame information for rev 252

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

Line No. Rev Author Line
1 227 jeremybenn
/* Simulation code for the CR16 processor.
2
   Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
3
   Contributed by M Ranga Swami Reddy <MR.Swami.Reddy@nsc.com>
4
 
5
   This file is part of GDB, the GNU debugger.
6
 
7
   This program is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 3, or (at your option)
10
   any later version.
11
 
12
   This program is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
16
 
17
   You should have received a copy of the GNU General Public License
18
   along with this program. If not, see <http://www.gnu.org/licenses/>.  */
19
 
20
 
21
/* If we're being compiled as a .c file, rather than being included in
22
   cr16_sim.h, then ENDIAN_INLINE won't be defined yet.  */
23
 
24
#ifndef ENDIAN_INLINE
25
#define NO_ENDIAN_INLINE
26
#include "cr16_sim.h"
27
#define ENDIAN_INLINE
28
#endif
29
 
30
ENDIAN_INLINE uint16
31
get_word (x)
32
      uint8 *x;
33
{
34
  return *(uint16 *)x;
35
}
36
 
37
ENDIAN_INLINE uint32
38
get_longword (x)
39
      uint8 *x;
40
{
41
  return (((uint32) *(uint16 *)x) << 16) | ((uint32) *(uint16 *)(x+2));
42
}
43
 
44
ENDIAN_INLINE int64
45
get_longlong (x)
46
      uint8 *x;
47
{
48
  uint32 top = get_longword (x);
49
  uint32 bottom = get_longword (x+4);
50
  return (((int64)top)<<32) | (int64)bottom;
51
}
52
 
53
ENDIAN_INLINE void
54
write_word (addr, data)
55
     uint8 *addr;
56
     uint16 data;
57
{
58
  addr[1] = (data >> 8) & 0xff;
59
  addr[0] = data & 0xff;
60
 
61
}
62
 
63
ENDIAN_INLINE void
64
write_longword (addr, data)
65
     uint8 *addr;
66
     uint32 data;
67
{
68
  *(uint16 *)(addr + 2) = (uint16)(data >> 16);
69
  *(uint16 *)(addr) = (uint16)data;
70
}
71
 
72
ENDIAN_INLINE void
73
write_longlong (addr, data)
74
     uint8 *addr;
75
     int64 data;
76
{
77
  write_longword (addr+4, (uint32)(data >> 32));
78
  write_longword (addr, (uint32)data);
79
}

powered by: WebSVN 2.1.0

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