Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / legion / src / host / i686native.c
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: i686native.c
5* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
7*
8* The above named program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public
10* License version 2 as published by the Free Software Foundation.
11*
12* The above named program is distributed in the hope that it will be
13* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this work; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20*
21* ========== Copyright Header End ============================================
22*/
23/*
24 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
26 */
27
28#pragma ident "@(#)i686native.c 1.1 07/01/16 SMI"
29
30#include <stdio.h>
31#include <stdlib.h>
32
33#include <assert.h>
34
35#include "basics.h"
36#include "fatal.h"
37#include "allocate.h"
38#include "simcore.h"
39#include "config.h"
40#include "xicache.h"
41#include "xdcache.h"
42#include "tsparcv9.h"
43#include "tsparcv9internal.h"
44#include "sparcv9cc.h"
45#include "magictraps.h"
46#include "sparcv9decode.h"
47#include "sunmedia_intrin.h"
48#include "fpsim.h"
49
50
51#include <atomic.h>
52
53/* For now, map to Solaris 10 C-library implementations */
54
55void
56host_atomic_get128be(uint64_t *ptr, uint64_t *r1p, uint64_t *r2p)
57{
58 union {
59 __m128i x;
60 uint64_t x1[2];
61 } ux;
62
63 ux.x = _mm_load_si128((__m128i *)ptr);
64 *r1p = ux.x1[0];
65 *r2p = ux.x1[1];
66}
67
68uint32_t
69host_swap(uint32_t *ptr, uint32_t val)
70{
71 return (atomic_swap_32(ptr, val));
72}
73
74uint8_t
75host_ldstub(uint8_t *ptr, uint8_t v1, uint8_t v2)
76{
77 return (atomic_swap_8(ptr, 0xff));
78}
79
80uint32_t
81host_cas32(uint32_t *target, uint32_t cmp, uint32_t newval)
82{
83 return (atomic_cas_32(target, cmp, newval));
84}
85
86uint64_t
87host_cas64(uint64_t *target, uint64_t cmp, uint64_t newval)
88{
89 return (atomic_cas_64(target, cmp, newval));
90}
91
92uint32_t
93sim_atomic_add_32_nv(uint32_t *target, int32_t delta)
94{
95 return (atomic_add_32_nv(target, delta));
96}