Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
/*-
|
2001-09-03 22:03:25 +00:00
|
|
|
* Copyright (c) 1998 Doug Rabson.
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
* Copyright (c) 2001 Jake Burkholder.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
2001-08-09 02:09:34 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
2001-08-09 02:09:34 +00:00
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
2001-09-03 22:03:25 +00:00
|
|
|
* from: FreeBSD: src/sys/i386/include/atomic.h,v 1.20 2001/02/11
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
2001-07-31 06:05:05 +00:00
|
|
|
#ifndef _MACHINE_ATOMIC_H_
|
|
|
|
#define _MACHINE_ATOMIC_H_
|
|
|
|
|
|
|
|
#include <machine/cpufunc.h>
|
|
|
|
|
2011-10-01 00:22:24 +00:00
|
|
|
#define mb() __asm__ __volatile__ ("membar #MemIssue": : :"memory")
|
|
|
|
#define wmb() mb()
|
|
|
|
#define rmb() mb()
|
|
|
|
|
2001-12-29 06:48:43 +00:00
|
|
|
/* Userland needs different ASI's. */
|
|
|
|
#ifdef _KERNEL
|
|
|
|
#define __ASI_ATOMIC ASI_N
|
|
|
|
#else
|
|
|
|
#define __ASI_ATOMIC ASI_P
|
|
|
|
#endif
|
|
|
|
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
/*
|
2001-07-31 06:05:05 +00:00
|
|
|
* Various simple arithmetic on memory which is atomic in the presence
|
|
|
|
* of interrupts and multiple processors. See atomic(9) for details.
|
|
|
|
* Note that efficient hardware support exists only for the 32 and 64
|
|
|
|
* bit variants; the 8 and 16 bit versions are not provided and should
|
|
|
|
* not be used in MI code.
|
|
|
|
*
|
|
|
|
* This implementation takes advantage of the fact that the sparc64
|
|
|
|
* cas instruction is both a load and a store. The loop is often coded
|
|
|
|
* as follows:
|
|
|
|
*
|
|
|
|
* do {
|
|
|
|
* expect = *p;
|
|
|
|
* new = expect + 1;
|
|
|
|
* } while (cas(p, expect, new) != expect);
|
|
|
|
*
|
|
|
|
* which performs an unnnecessary load on each iteration that the cas
|
|
|
|
* operation fails. Modified as follows:
|
|
|
|
*
|
|
|
|
* expect = *p;
|
|
|
|
* for (;;) {
|
|
|
|
* new = expect + 1;
|
|
|
|
* result = cas(p, expect, new);
|
|
|
|
* if (result == expect)
|
|
|
|
* break;
|
|
|
|
* expect = result;
|
|
|
|
* }
|
|
|
|
*
|
2002-12-21 08:53:26 +00:00
|
|
|
* the return value of cas is used to avoid the extra reload.
|
2001-07-31 06:05:05 +00:00
|
|
|
*
|
2011-10-01 00:11:03 +00:00
|
|
|
* We only include a memory barrier in the rel variants as in total store
|
|
|
|
* order which we use for running the kernel and all of the userland atomic
|
|
|
|
* loads and stores behave as if the were followed by a membar with a mask
|
|
|
|
* of #LoadLoad | #LoadStore | #StoreStore. In order to be also sufficient
|
2011-12-03 13:51:57 +00:00
|
|
|
* for use of relaxed memory ordering, the atomic_cas() in the acq variants
|
2011-10-01 00:11:03 +00:00
|
|
|
* additionally would have to be followed by a membar #LoadLoad | #LoadStore.
|
|
|
|
* Due to the suggested assembly syntax of the membar operands containing a
|
|
|
|
* # character, they cannot be used in macros. The cmask and mmask bits thus
|
2001-07-31 06:05:05 +00:00
|
|
|
* are hard coded in machine/cpufunc.h and used here through macros.
|
2011-10-01 00:11:03 +00:00
|
|
|
* Hopefully the bit numbers won't change in the future.
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
*/
|
|
|
|
|
2004-05-22 00:47:26 +00:00
|
|
|
#define itype(sz) uint ## sz ## _t
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
|
2011-10-01 00:22:24 +00:00
|
|
|
#define atomic_cas_32(p, e, s) casa((p), (e), (s), __ASI_ATOMIC)
|
|
|
|
#define atomic_cas_64(p, e, s) casxa((p), (e), (s), __ASI_ATOMIC)
|
2001-07-31 06:05:05 +00:00
|
|
|
|
|
|
|
#define atomic_cas(p, e, s, sz) \
|
2011-10-01 00:22:24 +00:00
|
|
|
atomic_cas_ ## sz((p), (e), (s))
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
|
2001-07-31 06:05:05 +00:00
|
|
|
#define atomic_cas_acq(p, e, s, sz) ({ \
|
|
|
|
itype(sz) v; \
|
2011-10-01 00:22:24 +00:00
|
|
|
v = atomic_cas((p), (e), (s), sz); \
|
2012-10-09 14:32:30 +00:00
|
|
|
__compiler_membar(); \
|
2001-07-31 06:05:05 +00:00
|
|
|
v; \
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
})
|
|
|
|
|
2001-07-31 06:05:05 +00:00
|
|
|
#define atomic_cas_rel(p, e, s, sz) ({ \
|
|
|
|
itype(sz) v; \
|
|
|
|
membar(LoadStore | StoreStore); \
|
2011-10-01 00:22:24 +00:00
|
|
|
v = atomic_cas((p), (e), (s), sz); \
|
2001-07-31 06:05:05 +00:00
|
|
|
v; \
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
})
|
|
|
|
|
2002-12-21 08:53:26 +00:00
|
|
|
#define atomic_op(p, op, v, sz) ({ \
|
2001-07-31 06:05:05 +00:00
|
|
|
itype(sz) e, r, s; \
|
2011-10-01 00:22:24 +00:00
|
|
|
for (e = *(volatile itype(sz) *)(p);; e = r) { \
|
|
|
|
s = e op (v); \
|
|
|
|
r = atomic_cas_ ## sz((p), e, s); \
|
2001-07-31 06:05:05 +00:00
|
|
|
if (r == e) \
|
|
|
|
break; \
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
} \
|
2002-12-21 08:53:26 +00:00
|
|
|
e; \
|
|
|
|
})
|
2001-07-31 06:05:05 +00:00
|
|
|
|
2002-12-21 08:53:26 +00:00
|
|
|
#define atomic_op_acq(p, op, v, sz) ({ \
|
|
|
|
itype(sz) t; \
|
2011-10-01 00:22:24 +00:00
|
|
|
t = atomic_op((p), op, (v), sz); \
|
2012-10-09 14:32:30 +00:00
|
|
|
__compiler_membar(); \
|
2002-12-21 08:53:26 +00:00
|
|
|
t; \
|
|
|
|
})
|
2001-07-31 06:05:05 +00:00
|
|
|
|
2002-12-21 08:53:26 +00:00
|
|
|
#define atomic_op_rel(p, op, v, sz) ({ \
|
|
|
|
itype(sz) t; \
|
2001-07-31 06:05:05 +00:00
|
|
|
membar(LoadStore | StoreStore); \
|
2011-10-01 00:22:24 +00:00
|
|
|
t = atomic_op((p), op, (v), sz); \
|
2002-12-21 08:53:26 +00:00
|
|
|
t; \
|
|
|
|
})
|
2001-07-31 06:05:05 +00:00
|
|
|
|
2001-09-03 22:03:25 +00:00
|
|
|
#define atomic_load(p, sz) \
|
2011-10-01 00:22:24 +00:00
|
|
|
atomic_cas((p), 0, 0, sz)
|
2001-09-03 22:03:25 +00:00
|
|
|
|
2001-07-31 06:05:05 +00:00
|
|
|
#define atomic_load_acq(p, sz) ({ \
|
|
|
|
itype(sz) v; \
|
2011-10-01 00:22:24 +00:00
|
|
|
v = atomic_load((p), sz); \
|
2012-10-09 14:32:30 +00:00
|
|
|
__compiler_membar(); \
|
2001-07-31 06:05:05 +00:00
|
|
|
v; \
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
})
|
|
|
|
|
2001-07-31 06:05:05 +00:00
|
|
|
#define atomic_load_clear(p, sz) ({ \
|
|
|
|
itype(sz) e, r; \
|
2011-10-01 00:22:24 +00:00
|
|
|
for (e = *(volatile itype(sz) *)(p);; e = r) { \
|
|
|
|
r = atomic_cas((p), e, 0, sz); \
|
2001-07-31 06:05:05 +00:00
|
|
|
if (r == e) \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
e; \
|
|
|
|
})
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
|
2001-09-03 22:03:25 +00:00
|
|
|
#define atomic_store(p, v, sz) do { \
|
2001-07-31 06:05:05 +00:00
|
|
|
itype(sz) e, r; \
|
2011-10-01 00:22:24 +00:00
|
|
|
for (e = *(volatile itype(sz) *)(p);; e = r) { \
|
|
|
|
r = atomic_cas((p), e, (v), sz); \
|
2001-07-31 06:05:05 +00:00
|
|
|
if (r == e) \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2001-09-03 22:03:25 +00:00
|
|
|
#define atomic_store_rel(p, v, sz) do { \
|
|
|
|
membar(LoadStore | StoreStore); \
|
2011-10-01 00:22:24 +00:00
|
|
|
atomic_store((p), (v), sz); \
|
2001-09-03 22:03:25 +00:00
|
|
|
} while (0)
|
|
|
|
|
2001-07-31 06:05:05 +00:00
|
|
|
#define ATOMIC_GEN(name, ptype, vtype, atype, sz) \
|
|
|
|
\
|
2002-12-21 08:53:26 +00:00
|
|
|
static __inline vtype \
|
2001-07-31 06:05:05 +00:00
|
|
|
atomic_add_ ## name(volatile ptype p, atype v) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return ((vtype)atomic_op((p), +, (v), sz)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
2002-12-21 08:53:26 +00:00
|
|
|
static __inline vtype \
|
2001-07-31 06:05:05 +00:00
|
|
|
atomic_add_acq_ ## name(volatile ptype p, atype v) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return ((vtype)atomic_op_acq((p), +, (v), sz)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
2002-12-21 08:53:26 +00:00
|
|
|
static __inline vtype \
|
2001-07-31 06:05:05 +00:00
|
|
|
atomic_add_rel_ ## name(volatile ptype p, atype v) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return ((vtype)atomic_op_rel((p), +, (v), sz)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
|
|
|
\
|
2002-12-21 08:53:26 +00:00
|
|
|
static __inline vtype \
|
2001-07-31 06:05:05 +00:00
|
|
|
atomic_clear_ ## name(volatile ptype p, atype v) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return ((vtype)atomic_op((p), &, ~(v), sz)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
2002-12-21 08:53:26 +00:00
|
|
|
static __inline vtype \
|
2001-07-31 06:05:05 +00:00
|
|
|
atomic_clear_acq_ ## name(volatile ptype p, atype v) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return ((vtype)atomic_op_acq((p), &, ~(v), sz)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
2002-12-21 08:53:26 +00:00
|
|
|
static __inline vtype \
|
2001-07-31 06:05:05 +00:00
|
|
|
atomic_clear_rel_ ## name(volatile ptype p, atype v) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return ((vtype)atomic_op_rel((p), &, ~(v), sz)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
static __inline int \
|
|
|
|
atomic_cmpset_ ## name(volatile ptype p, vtype e, vtype s) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return (((vtype)atomic_cas((p), (e), (s), sz)) == (e)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
|
|
|
static __inline int \
|
|
|
|
atomic_cmpset_acq_ ## name(volatile ptype p, vtype e, vtype s) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return (((vtype)atomic_cas_acq((p), (e), (s), sz)) == (e)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
|
|
|
static __inline int \
|
|
|
|
atomic_cmpset_rel_ ## name(volatile ptype p, vtype e, vtype s) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return (((vtype)atomic_cas_rel((p), (e), (s), sz)) == (e)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
static __inline vtype \
|
2001-09-03 22:03:25 +00:00
|
|
|
atomic_load_ ## name(volatile ptype p) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return ((vtype)atomic_cas((p), 0, 0, sz)); \
|
2001-09-03 22:03:25 +00:00
|
|
|
} \
|
|
|
|
static __inline vtype \
|
2001-07-31 06:05:05 +00:00
|
|
|
atomic_load_acq_ ## name(volatile ptype p) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return ((vtype)atomic_cas_acq((p), 0, 0, sz)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
static __inline vtype \
|
|
|
|
atomic_readandclear_ ## name(volatile ptype p) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return ((vtype)atomic_load_clear((p), sz)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
|
|
|
\
|
2002-12-21 08:53:26 +00:00
|
|
|
static __inline vtype \
|
2001-07-31 06:05:05 +00:00
|
|
|
atomic_set_ ## name(volatile ptype p, atype v) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return ((vtype)atomic_op((p), |, (v), sz)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
2002-12-21 08:53:26 +00:00
|
|
|
static __inline vtype \
|
2001-07-31 06:05:05 +00:00
|
|
|
atomic_set_acq_ ## name(volatile ptype p, atype v) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return ((vtype)atomic_op_acq((p), |, (v), sz)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
2002-12-21 08:53:26 +00:00
|
|
|
static __inline vtype \
|
2001-07-31 06:05:05 +00:00
|
|
|
atomic_set_rel_ ## name(volatile ptype p, atype v) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return ((vtype)atomic_op_rel((p), |, (v), sz)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
|
|
|
\
|
2002-12-21 08:53:26 +00:00
|
|
|
static __inline vtype \
|
2001-07-31 06:05:05 +00:00
|
|
|
atomic_subtract_ ## name(volatile ptype p, atype v) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return ((vtype)atomic_op((p), -, (v), sz)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
2002-12-21 08:53:26 +00:00
|
|
|
static __inline vtype \
|
2001-07-31 06:05:05 +00:00
|
|
|
atomic_subtract_acq_ ## name(volatile ptype p, atype v) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return ((vtype)atomic_op_acq((p), -, (v), sz)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
2002-12-21 08:53:26 +00:00
|
|
|
static __inline vtype \
|
2001-07-31 06:05:05 +00:00
|
|
|
atomic_subtract_rel_ ## name(volatile ptype p, atype v) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
return ((vtype)atomic_op_rel((p), -, (v), sz)); \
|
2001-07-31 06:05:05 +00:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
static __inline void \
|
2001-09-03 22:03:25 +00:00
|
|
|
atomic_store_ ## name(volatile ptype p, vtype v) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
atomic_store((p), (v), sz); \
|
2001-09-03 22:03:25 +00:00
|
|
|
} \
|
|
|
|
static __inline void \
|
2001-07-31 06:05:05 +00:00
|
|
|
atomic_store_rel_ ## name(volatile ptype p, vtype v) \
|
|
|
|
{ \
|
2011-10-01 00:22:24 +00:00
|
|
|
atomic_store_rel((p), (v), sz); \
|
2001-07-31 06:05:05 +00:00
|
|
|
}
|
|
|
|
|
2004-05-22 00:52:16 +00:00
|
|
|
ATOMIC_GEN(int, u_int *, u_int, u_int, 32);
|
|
|
|
ATOMIC_GEN(32, uint32_t *, uint32_t, uint32_t, 32);
|
2001-07-31 06:05:05 +00:00
|
|
|
|
2004-05-22 00:52:16 +00:00
|
|
|
ATOMIC_GEN(long, u_long *, u_long, u_long, 64);
|
|
|
|
ATOMIC_GEN(64, uint64_t *, uint64_t, uint64_t, 64);
|
2001-07-31 06:05:05 +00:00
|
|
|
|
2005-07-15 18:17:59 +00:00
|
|
|
ATOMIC_GEN(ptr, uintptr_t *, uintptr_t, uintptr_t, 64);
|
2001-07-31 06:05:05 +00:00
|
|
|
|
2005-09-27 17:39:11 +00:00
|
|
|
#define atomic_fetchadd_int atomic_add_int
|
|
|
|
#define atomic_fetchadd_32 atomic_add_32
|
2008-03-19 07:27:24 +00:00
|
|
|
#define atomic_fetchadd_long atomic_add_long
|
2005-09-27 17:39:11 +00:00
|
|
|
|
2001-07-31 06:05:05 +00:00
|
|
|
#undef ATOMIC_GEN
|
|
|
|
#undef atomic_cas
|
|
|
|
#undef atomic_cas_acq
|
|
|
|
#undef atomic_cas_rel
|
|
|
|
#undef atomic_op
|
|
|
|
#undef atomic_op_acq
|
|
|
|
#undef atomic_op_rel
|
|
|
|
#undef atomic_load_acq
|
|
|
|
#undef atomic_store_rel
|
|
|
|
#undef atomic_load_clear
|
Add skeleton machine dependent headers and c files for a port of freebsd
to a new architecture. This is the base of the sparc64 port, but contains
limited machine dependent code, and can be used a base for ports. Included
are:
- standard machine dependent headers, tweaked for a 64 bit, big endian
architecture, including empty versions of all the machine dependent
structures
- a machine independent atomic.h, which can be used until a port has
support for interrupts and the operations really need to be atomic
- stub versions of all the machine dependent functions, which panic
when called and print out the name of the function that needs to
be implemented. functions which are normally in assembly files are
not included, but this should reduce the number of different undefined
references on the first few compiles from hundreds to 5 or 6
Given minimal startup code and console support it should be trivial to
make this compile and run the first few sysinits on almost any architecture.
Requested by: alfred, imp, jhb
2001-07-31 05:45:16 +00:00
|
|
|
|
|
|
|
#endif /* !_MACHINE_ATOMIC_H_ */
|