[BACK]Return to simplelock.h CVS log [TXT][DIR] Up to [local] / sys / sys

File: [local] / sys / sys / simplelock.h (download)

Revision 1.1.1.1 (vendor branch), Tue Mar 4 16:16:13 2008 UTC (16 years, 1 month ago) by nbrk
Branch: OPENBSD_4_2_BASE, MAIN
CVS Tags: jornada-partial-support-wip, HEAD
Changes since 1.1: +0 -0 lines

Import of OpenBSD 4.2 release kernel tree with initial code to support 
Jornada 720/728, StrongARM 1110-based handheld PC.
At this point kernel roots on NFS and boots into vfs_mountroot() and traps.
What is supported:
- glass console, Jornada framebuffer (jfb) works in 16bpp direct color mode
(needs some palette tweaks for non black/white/blue colors, i think)
- saic, SA11x0 interrupt controller (needs cleanup)
- sacom, SA11x0 UART (supported only as boot console for now)
- SA11x0 GPIO controller fully supported (but can't handle multiple interrupt
handlers on one gpio pin)
- sassp, SSP port on SA11x0 that attaches spibus
- Jornada microcontroller (jmcu) to control kbd, battery, etc throught
the SPI bus (wskbd attaches on jmcu, but not tested)
- tod functions seem work
- initial code for SA-1111 (chip companion) : this is TODO

Next important steps, i think:
- gpio and intc on sa1111
- pcmcia support for sa11x0 (and sa1111 help logic)
- REAL root on nfs when we have PCMCIA support (we may use any of supported pccard NICs)
- root on wd0! (using already supported PCMCIA-ATA)

/*	$OpenBSD: simplelock.h,v 1.11 2004/06/13 21:49:28 niklas Exp $	*/

#ifndef _SIMPLELOCK_H_
#define _SIMPLELOCK_H_

#ifdef MULTIPROCESSOR
#include <machine/lock.h>
#endif

/*
 * A simple spin lock.
 *
 * This structure only sets one bit of data, but is sized based on the
 * minimum word size that can be operated on by the hardware test-and-set
 * instruction. It is only needed for multiprocessors, as uniprocessors
 * will always run to completion or a sleep. It is an error to hold one
 * of these locks while a process is sleeping.
 */
struct simplelock {
#ifdef MULTIPROCESSOR
	__cpu_simple_lock_t lock_data;
#else
	int	lock_data;
#endif
};

#ifdef _KERNEL

/*
 * We can't debug locks when we use them in real life.
 */
#if defined(MULTIPROCESSOR) && defined(LOCKDEBUG)
#undef LOCKDEBUG
#endif

#if !defined(MULTIPROCESSOR) || 1

#define SLOCK_LOCKED 1
#define SLOCK_UNLOCKED 0

#ifndef LOCKDEBUG

#define	simple_lock(lkp)
#define	simple_lock_try(lkp)	(1)	/* always succeeds */
#define	simple_unlock(lkp)
#define simple_lock_assert(lkp)

static __inline void simple_lock_init(struct simplelock *lkp)
{

	lkp->lock_data = SLOCK_UNLOCKED;
}

#else

void _simple_unlock(__volatile struct simplelock *, const char *, int);
int _simple_lock_try(__volatile struct simplelock *, const char *, int);
void _simple_lock(__volatile struct simplelock *, const char *, int);
void _simple_lock_assert(__volatile struct simplelock *, int, const char *, int);

void simple_lock_init(struct simplelock *);
#define simple_unlock(lkp) _simple_unlock(lkp, __FILE__, __LINE__)
#define simple_lock_try(lkp) _simple_lock_try(lkp, __FILE__, __LINE__)
#define simple_lock(lkp) _simple_lock(lkp, __FILE__, __LINE__)
#define simple_lock_assert(lkp, state) _simple_lock_assert(lkp, state, __FILE__, __LINE__)

#endif /* !defined(LOCKDEBUG) */

#else  /* MULTIPROCESSOR */

/*
 * The simple-lock routines are the primitives out of which the lock
 * package is built. The machine-dependent code must implement an
 * atomic test_and_set operation that indivisibly sets the simple lock
 * to non-zero and returns its old value. It also assumes that the
 * setting of the lock to zero below is indivisible. Simple locks may
 * only be used for exclusive locks.
 */

static __inline void simple_lock_init(struct simplelock *lkp)
{
	__cpu_simple_lock_init(&lkp->lock_data);
}

static __inline void simple_lock(__volatile struct simplelock *lkp)
{
	__cpu_simple_lock(&lkp->lock_data);
}

static __inline int simple_lock_try(__volatile struct simplelock *lkp)
{
	return (__cpu_simple_lock_try(&lkp->lock_data));
}

static __inline void simple_unlock(__volatile struct simplelock *lkp)
{
	__cpu_simple_unlock(&lkp->lock_data);
}
#endif /* MULTIPROCESSOR */

#endif /* _KERNEL */

#endif /* !_SIMPLELOCK_H_ */