Commit 1a7c5536 authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6:
  sparc64: Get rid of indirect p1275 PROM call buffer.
  sparc64: Fill a missing delay slot.
  sparc64: Make lock backoff really a NOP on UP builds.
  sparc64: simple microoptimizations for atomic functions
  sparc64: Make rwsems 64-bit.
  sparc64: Really fix atomic64_t interface types.
parents bd45fe53 25edd694
...@@ -20,14 +20,14 @@ ...@@ -20,14 +20,14 @@
#define atomic64_set(v, i) (((v)->counter) = i) #define atomic64_set(v, i) (((v)->counter) = i)
extern void atomic_add(int, atomic_t *); extern void atomic_add(int, atomic_t *);
extern void atomic64_add(int, atomic64_t *); extern void atomic64_add(long, atomic64_t *);
extern void atomic_sub(int, atomic_t *); extern void atomic_sub(int, atomic_t *);
extern void atomic64_sub(int, atomic64_t *); extern void atomic64_sub(long, atomic64_t *);
extern int atomic_add_ret(int, atomic_t *); extern int atomic_add_ret(int, atomic_t *);
extern long atomic64_add_ret(int, atomic64_t *); extern long atomic64_add_ret(long, atomic64_t *);
extern int atomic_sub_ret(int, atomic_t *); extern int atomic_sub_ret(int, atomic_t *);
extern long atomic64_sub_ret(int, atomic64_t *); extern long atomic64_sub_ret(long, atomic64_t *);
#define atomic_dec_return(v) atomic_sub_ret(1, v) #define atomic_dec_return(v) atomic_sub_ret(1, v)
#define atomic64_dec_return(v) atomic64_sub_ret(1, v) #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
......
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
#define BACKOFF_SETUP(reg) \ #define BACKOFF_SETUP(reg) \
mov 1, reg mov 1, reg
#define BACKOFF_LABEL(spin_label, continue_label) \
spin_label
#define BACKOFF_SPIN(reg, tmp, label) \ #define BACKOFF_SPIN(reg, tmp, label) \
mov reg, tmp; \ mov reg, tmp; \
88: brnz,pt tmp, 88b; \ 88: brnz,pt tmp, 88b; \
...@@ -22,9 +25,11 @@ ...@@ -22,9 +25,11 @@
#else #else
#define BACKOFF_SETUP(reg) #define BACKOFF_SETUP(reg)
#define BACKOFF_SPIN(reg, tmp, label) \
ba,pt %xcc, label; \ #define BACKOFF_LABEL(spin_label, continue_label) \
nop; continue_label
#define BACKOFF_SPIN(reg, tmp, label)
#endif #endif
......
...@@ -185,9 +185,8 @@ extern int prom_getunumber(int syndrome_code, ...@@ -185,9 +185,8 @@ extern int prom_getunumber(int syndrome_code,
char *buf, int buflen); char *buf, int buflen);
/* Retain physical memory to the caller across soft resets. */ /* Retain physical memory to the caller across soft resets. */
extern unsigned long prom_retain(const char *name, extern int prom_retain(const char *name, unsigned long size,
unsigned long pa_low, unsigned long pa_high, unsigned long align, unsigned long *paddr);
long size, long align);
/* Load explicit I/D TLB entries into the calling processor. */ /* Load explicit I/D TLB entries into the calling processor. */
extern long prom_itlb_load(unsigned long index, extern long prom_itlb_load(unsigned long index,
...@@ -287,26 +286,6 @@ extern void prom_sun4v_guest_soft_state(void); ...@@ -287,26 +286,6 @@ extern void prom_sun4v_guest_soft_state(void);
extern int prom_ihandle2path(int handle, char *buffer, int bufsize); extern int prom_ihandle2path(int handle, char *buffer, int bufsize);
/* Client interface level routines. */ /* Client interface level routines. */
extern long p1275_cmd(const char *, long, ...); extern void p1275_cmd_direct(unsigned long *);
#if 0
#define P1275_SIZE(x) ((((long)((x) / 32)) << 32) | (x))
#else
#define P1275_SIZE(x) x
#endif
/* We support at most 16 input and 1 output argument */
#define P1275_ARG_NUMBER 0
#define P1275_ARG_IN_STRING 1
#define P1275_ARG_OUT_BUF 2
#define P1275_ARG_OUT_32B 3
#define P1275_ARG_IN_FUNCTION 4
#define P1275_ARG_IN_BUF 5
#define P1275_ARG_IN_64B 6
#define P1275_IN(x) ((x) & 0xf)
#define P1275_OUT(x) (((x) << 4) & 0xf0)
#define P1275_INOUT(i,o) (P1275_IN(i)|P1275_OUT(o))
#define P1275_ARG(n,x) ((x) << ((n)*3 + 8))
#endif /* !(__SPARC64_OPLIB_H) */ #endif /* !(__SPARC64_OPLIB_H) */
/* rwsem-const.h: RW semaphore counter constants. */
#ifndef _SPARC64_RWSEM_CONST_H
#define _SPARC64_RWSEM_CONST_H
#define RWSEM_UNLOCKED_VALUE 0x00000000
#define RWSEM_ACTIVE_BIAS 0x00000001
#define RWSEM_ACTIVE_MASK 0x0000ffff
#define RWSEM_WAITING_BIAS (-0x00010000)
#define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS
#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
#endif /* _SPARC64_RWSEM_CONST_H */
...@@ -15,16 +15,21 @@ ...@@ -15,16 +15,21 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <asm/rwsem-const.h>
struct rwsem_waiter; struct rwsem_waiter;
struct rw_semaphore { struct rw_semaphore {
signed int count; signed long count;
spinlock_t wait_lock; #define RWSEM_UNLOCKED_VALUE 0x00000000L
struct list_head wait_list; #define RWSEM_ACTIVE_BIAS 0x00000001L
#define RWSEM_ACTIVE_MASK 0xffffffffL
#define RWSEM_WAITING_BIAS (-RWSEM_ACTIVE_MASK-1)
#define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS
#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
spinlock_t wait_lock;
struct list_head wait_list;
#ifdef CONFIG_DEBUG_LOCK_ALLOC #ifdef CONFIG_DEBUG_LOCK_ALLOC
struct lockdep_map dep_map; struct lockdep_map dep_map;
#endif #endif
}; };
...@@ -41,6 +46,11 @@ struct rw_semaphore { ...@@ -41,6 +46,11 @@ struct rw_semaphore {
#define DECLARE_RWSEM(name) \ #define DECLARE_RWSEM(name) \
struct rw_semaphore name = __RWSEM_INITIALIZER(name) struct rw_semaphore name = __RWSEM_INITIALIZER(name)
extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem);
extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem);
extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
extern void __init_rwsem(struct rw_semaphore *sem, const char *name, extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
struct lock_class_key *key); struct lock_class_key *key);
...@@ -51,27 +61,103 @@ do { \ ...@@ -51,27 +61,103 @@ do { \
__init_rwsem((sem), #sem, &__key); \ __init_rwsem((sem), #sem, &__key); \
} while (0) } while (0)
extern void __down_read(struct rw_semaphore *sem); /*
extern int __down_read_trylock(struct rw_semaphore *sem); * lock for reading
extern void __down_write(struct rw_semaphore *sem); */
extern int __down_write_trylock(struct rw_semaphore *sem); static inline void __down_read(struct rw_semaphore *sem)
extern void __up_read(struct rw_semaphore *sem); {
extern void __up_write(struct rw_semaphore *sem); if (unlikely(atomic64_inc_return((atomic64_t *)(&sem->count)) <= 0L))
extern void __downgrade_write(struct rw_semaphore *sem); rwsem_down_read_failed(sem);
}
static inline int __down_read_trylock(struct rw_semaphore *sem)
{
long tmp;
while ((tmp = sem->count) >= 0L) {
if (tmp == cmpxchg(&sem->count, tmp,
tmp + RWSEM_ACTIVE_READ_BIAS)) {
return 1;
}
}
return 0;
}
/*
* lock for writing
*/
static inline void __down_write_nested(struct rw_semaphore *sem, int subclass) static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
{ {
__down_write(sem); long tmp;
tmp = atomic64_add_return(RWSEM_ACTIVE_WRITE_BIAS,
(atomic64_t *)(&sem->count));
if (unlikely(tmp != RWSEM_ACTIVE_WRITE_BIAS))
rwsem_down_write_failed(sem);
} }
static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem) static inline void __down_write(struct rw_semaphore *sem)
{ {
return atomic_add_return(delta, (atomic_t *)(&sem->count)); __down_write_nested(sem, 0);
}
static inline int __down_write_trylock(struct rw_semaphore *sem)
{
long tmp;
tmp = cmpxchg(&sem->count, RWSEM_UNLOCKED_VALUE,
RWSEM_ACTIVE_WRITE_BIAS);
return tmp == RWSEM_UNLOCKED_VALUE;
} }
static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem) /*
* unlock after reading
*/
static inline void __up_read(struct rw_semaphore *sem)
{
long tmp;
tmp = atomic64_dec_return((atomic64_t *)(&sem->count));
if (unlikely(tmp < -1L && (tmp & RWSEM_ACTIVE_MASK) == 0L))
rwsem_wake(sem);
}
/*
* unlock after writing
*/
static inline void __up_write(struct rw_semaphore *sem)
{
if (unlikely(atomic64_sub_return(RWSEM_ACTIVE_WRITE_BIAS,
(atomic64_t *)(&sem->count)) < 0L))
rwsem_wake(sem);
}
/*
* implement atomic add functionality
*/
static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
{
atomic64_add(delta, (atomic64_t *)(&sem->count));
}
/*
* downgrade write lock to read lock
*/
static inline void __downgrade_write(struct rw_semaphore *sem)
{
long tmp;
tmp = atomic64_add_return(-RWSEM_WAITING_BIAS, (atomic64_t *)(&sem->count));
if (tmp < 0L)
rwsem_downgrade_wake(sem);
}
/*
* implement exchange and add functionality
*/
static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
{ {
atomic_add(delta, (atomic_t *)(&sem->count)); return atomic64_add_return(delta, (atomic64_t *)(&sem->count));
} }
static inline int rwsem_is_locked(struct rw_semaphore *sem) static inline int rwsem_is_locked(struct rw_semaphore *sem)
......
...@@ -106,6 +106,7 @@ do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \ ...@@ -106,6 +106,7 @@ do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \
*/ */
#define write_pic(__p) \ #define write_pic(__p) \
__asm__ __volatile__("ba,pt %%xcc, 99f\n\t" \ __asm__ __volatile__("ba,pt %%xcc, 99f\n\t" \
" nop\n\t" \
".align 64\n" \ ".align 64\n" \
"99:wr %0, 0x0, %%pic\n\t" \ "99:wr %0, 0x0, %%pic\n\t" \
"rd %%pic, %%g0" : : "r" (__p)) "rd %%pic, %%g0" : : "r" (__p))
......
...@@ -15,7 +15,7 @@ lib-$(CONFIG_SPARC32) += divdi3.o udivdi3.o ...@@ -15,7 +15,7 @@ lib-$(CONFIG_SPARC32) += divdi3.o udivdi3.o
lib-$(CONFIG_SPARC32) += copy_user.o locks.o lib-$(CONFIG_SPARC32) += copy_user.o locks.o
lib-y += atomic_$(BITS).o lib-y += atomic_$(BITS).o
lib-$(CONFIG_SPARC32) += lshrdi3.o ashldi3.o lib-$(CONFIG_SPARC32) += lshrdi3.o ashldi3.o
lib-y += rwsem_$(BITS).o lib-$(CONFIG_SPARC32) += rwsem_32.o
lib-$(CONFIG_SPARC32) += muldi3.o bitext.o cmpdi2.o lib-$(CONFIG_SPARC32) += muldi3.o bitext.o cmpdi2.o
lib-$(CONFIG_SPARC64) += copy_page.o clear_page.o bzero.o lib-$(CONFIG_SPARC64) += copy_page.o clear_page.o bzero.o
......
...@@ -21,7 +21,7 @@ atomic_add: /* %o0 = increment, %o1 = atomic_ptr */ ...@@ -21,7 +21,7 @@ atomic_add: /* %o0 = increment, %o1 = atomic_ptr */
add %g1, %o0, %g7 add %g1, %o0, %g7
cas [%o1], %g1, %g7 cas [%o1], %g1, %g7
cmp %g1, %g7 cmp %g1, %g7
bne,pn %icc, 2f bne,pn %icc, BACKOFF_LABEL(2f, 1b)
nop nop
retl retl
nop nop
...@@ -36,7 +36,7 @@ atomic_sub: /* %o0 = decrement, %o1 = atomic_ptr */ ...@@ -36,7 +36,7 @@ atomic_sub: /* %o0 = decrement, %o1 = atomic_ptr */
sub %g1, %o0, %g7 sub %g1, %o0, %g7
cas [%o1], %g1, %g7 cas [%o1], %g1, %g7
cmp %g1, %g7 cmp %g1, %g7
bne,pn %icc, 2f bne,pn %icc, BACKOFF_LABEL(2f, 1b)
nop nop
retl retl
nop nop
...@@ -51,11 +51,10 @@ atomic_add_ret: /* %o0 = increment, %o1 = atomic_ptr */ ...@@ -51,11 +51,10 @@ atomic_add_ret: /* %o0 = increment, %o1 = atomic_ptr */
add %g1, %o0, %g7 add %g1, %o0, %g7
cas [%o1], %g1, %g7 cas [%o1], %g1, %g7
cmp %g1, %g7 cmp %g1, %g7
bne,pn %icc, 2f bne,pn %icc, BACKOFF_LABEL(2f, 1b)
add %g7, %o0, %g7 add %g1, %o0, %g1
sra %g7, 0, %o0
retl retl
nop sra %g1, 0, %o0
2: BACKOFF_SPIN(%o2, %o3, 1b) 2: BACKOFF_SPIN(%o2, %o3, 1b)
.size atomic_add_ret, .-atomic_add_ret .size atomic_add_ret, .-atomic_add_ret
...@@ -67,11 +66,10 @@ atomic_sub_ret: /* %o0 = decrement, %o1 = atomic_ptr */ ...@@ -67,11 +66,10 @@ atomic_sub_ret: /* %o0 = decrement, %o1 = atomic_ptr */
sub %g1, %o0, %g7 sub %g1, %o0, %g7
cas [%o1], %g1, %g7 cas [%o1], %g1, %g7
cmp %g1, %g7 cmp %g1, %g7
bne,pn %icc, 2f bne,pn %icc, BACKOFF_LABEL(2f, 1b)
sub %g7, %o0, %g7 sub %g1, %o0, %g1
sra %g7, 0, %o0
retl retl
nop sra %g1, 0, %o0
2: BACKOFF_SPIN(%o2, %o3, 1b) 2: BACKOFF_SPIN(%o2, %o3, 1b)
.size atomic_sub_ret, .-atomic_sub_ret .size atomic_sub_ret, .-atomic_sub_ret
...@@ -83,7 +81,7 @@ atomic64_add: /* %o0 = increment, %o1 = atomic_ptr */ ...@@ -83,7 +81,7 @@ atomic64_add: /* %o0 = increment, %o1 = atomic_ptr */
add %g1, %o0, %g7 add %g1, %o0, %g7
casx [%o1], %g1, %g7 casx [%o1], %g1, %g7
cmp %g1, %g7 cmp %g1, %g7
bne,pn %xcc, 2f bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
nop nop
retl retl
nop nop
...@@ -98,7 +96,7 @@ atomic64_sub: /* %o0 = decrement, %o1 = atomic_ptr */ ...@@ -98,7 +96,7 @@ atomic64_sub: /* %o0 = decrement, %o1 = atomic_ptr */
sub %g1, %o0, %g7 sub %g1, %o0, %g7
casx [%o1], %g1, %g7 casx [%o1], %g1, %g7
cmp %g1, %g7 cmp %g1, %g7
bne,pn %xcc, 2f bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
nop nop
retl retl
nop nop
...@@ -113,11 +111,10 @@ atomic64_add_ret: /* %o0 = increment, %o1 = atomic_ptr */ ...@@ -113,11 +111,10 @@ atomic64_add_ret: /* %o0 = increment, %o1 = atomic_ptr */
add %g1, %o0, %g7 add %g1, %o0, %g7
casx [%o1], %g1, %g7 casx [%o1], %g1, %g7
cmp %g1, %g7 cmp %g1, %g7
bne,pn %xcc, 2f bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
add %g7, %o0, %g7
mov %g7, %o0
retl
nop nop
retl
add %g1, %o0, %o0
2: BACKOFF_SPIN(%o2, %o3, 1b) 2: BACKOFF_SPIN(%o2, %o3, 1b)
.size atomic64_add_ret, .-atomic64_add_ret .size atomic64_add_ret, .-atomic64_add_ret
...@@ -129,10 +126,9 @@ atomic64_sub_ret: /* %o0 = decrement, %o1 = atomic_ptr */ ...@@ -129,10 +126,9 @@ atomic64_sub_ret: /* %o0 = decrement, %o1 = atomic_ptr */
sub %g1, %o0, %g7 sub %g1, %o0, %g7
casx [%o1], %g1, %g7 casx [%o1], %g1, %g7
cmp %g1, %g7 cmp %g1, %g7
bne,pn %xcc, 2f bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
sub %g7, %o0, %g7
mov %g7, %o0
retl
nop nop
retl
sub %g1, %o0, %o0
2: BACKOFF_SPIN(%o2, %o3, 1b) 2: BACKOFF_SPIN(%o2, %o3, 1b)
.size atomic64_sub_ret, .-atomic64_sub_ret .size atomic64_sub_ret, .-atomic64_sub_ret
...@@ -22,7 +22,7 @@ test_and_set_bit: /* %o0=nr, %o1=addr */ ...@@ -22,7 +22,7 @@ test_and_set_bit: /* %o0=nr, %o1=addr */
or %g7, %o2, %g1 or %g7, %o2, %g1
casx [%o1], %g7, %g1 casx [%o1], %g7, %g1
cmp %g7, %g1 cmp %g7, %g1
bne,pn %xcc, 2f bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
and %g7, %o2, %g2 and %g7, %o2, %g2
clr %o0 clr %o0
movrne %g2, 1, %o0 movrne %g2, 1, %o0
...@@ -45,7 +45,7 @@ test_and_clear_bit: /* %o0=nr, %o1=addr */ ...@@ -45,7 +45,7 @@ test_and_clear_bit: /* %o0=nr, %o1=addr */
andn %g7, %o2, %g1 andn %g7, %o2, %g1
casx [%o1], %g7, %g1 casx [%o1], %g7, %g1
cmp %g7, %g1 cmp %g7, %g1
bne,pn %xcc, 2f bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
and %g7, %o2, %g2 and %g7, %o2, %g2
clr %o0 clr %o0
movrne %g2, 1, %o0 movrne %g2, 1, %o0
...@@ -68,7 +68,7 @@ test_and_change_bit: /* %o0=nr, %o1=addr */ ...@@ -68,7 +68,7 @@ test_and_change_bit: /* %o0=nr, %o1=addr */
xor %g7, %o2, %g1 xor %g7, %o2, %g1
casx [%o1], %g7, %g1 casx [%o1], %g7, %g1
cmp %g7, %g1 cmp %g7, %g1
bne,pn %xcc, 2f bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
and %g7, %o2, %g2 and %g7, %o2, %g2
clr %o0 clr %o0
movrne %g2, 1, %o0 movrne %g2, 1, %o0
...@@ -91,7 +91,7 @@ set_bit: /* %o0=nr, %o1=addr */ ...@@ -91,7 +91,7 @@ set_bit: /* %o0=nr, %o1=addr */
or %g7, %o2, %g1 or %g7, %o2, %g1
casx [%o1], %g7, %g1 casx [%o1], %g7, %g1
cmp %g7, %g1 cmp %g7, %g1
bne,pn %xcc, 2f bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
nop nop
retl retl
nop nop
...@@ -112,7 +112,7 @@ clear_bit: /* %o0=nr, %o1=addr */ ...@@ -112,7 +112,7 @@ clear_bit: /* %o0=nr, %o1=addr */
andn %g7, %o2, %g1 andn %g7, %o2, %g1
casx [%o1], %g7, %g1 casx [%o1], %g7, %g1
cmp %g7, %g1 cmp %g7, %g1
bne,pn %xcc, 2f bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
nop nop
retl retl
nop nop
...@@ -133,7 +133,7 @@ change_bit: /* %o0=nr, %o1=addr */ ...@@ -133,7 +133,7 @@ change_bit: /* %o0=nr, %o1=addr */
xor %g7, %o2, %g1 xor %g7, %o2, %g1
casx [%o1], %g7, %g1 casx [%o1], %g7, %g1
cmp %g7, %g1 cmp %g7, %g1
bne,pn %xcc, 2f bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
nop nop
retl retl
nop nop
......
/* rwsem.S: RW semaphore assembler.
*
* Written by David S. Miller (davem@redhat.com), 2001.
* Derived from asm-i386/rwsem.h
*/
#include <asm/rwsem-const.h>
.section .sched.text, "ax"
.globl __down_read
__down_read:
1: lduw [%o0], %g1
add %g1, 1, %g7
cas [%o0], %g1, %g7
cmp %g1, %g7
bne,pn %icc, 1b
add %g7, 1, %g7
cmp %g7, 0
bl,pn %icc, 3f
nop
2:
retl
nop
3:
save %sp, -192, %sp
call rwsem_down_read_failed
mov %i0, %o0
ret
restore
.size __down_read, .-__down_read
.globl __down_read_trylock
__down_read_trylock:
1: lduw [%o0], %g1
add %g1, 1, %g7
cmp %g7, 0
bl,pn %icc, 2f
mov 0, %o1
cas [%o0], %g1, %g7
cmp %g1, %g7
bne,pn %icc, 1b
mov 1, %o1
2: retl
mov %o1, %o0
.size __down_read_trylock, .-__down_read_trylock
.globl __down_write
__down_write:
sethi %hi(RWSEM_ACTIVE_WRITE_BIAS), %g1
or %g1, %lo(RWSEM_ACTIVE_WRITE_BIAS), %g1
1:
lduw [%o0], %g3
add %g3, %g1, %g7
cas [%o0], %g3, %g7
cmp %g3, %g7
bne,pn %icc, 1b
cmp %g7, 0
bne,pn %icc, 3f
nop
2: retl
nop
3:
save %sp, -192, %sp
call rwsem_down_write_failed
mov %i0, %o0
ret
restore
.size __down_write, .-__down_write
.globl __down_write_trylock
__down_write_trylock:
sethi %hi(RWSEM_ACTIVE_WRITE_BIAS), %g1
or %g1, %lo(RWSEM_ACTIVE_WRITE_BIAS), %g1
1:
lduw [%o0], %g3
cmp %g3, 0
bne,pn %icc, 2f
mov 0, %o1
add %g3, %g1, %g7
cas [%o0], %g3, %g7
cmp %g3, %g7
bne,pn %icc, 1b
mov 1, %o1
2: retl
mov %o1, %o0
.size __down_write_trylock, .-__down_write_trylock
.globl __up_read
__up_read:
1:
lduw [%o0], %g1
sub %g1, 1, %g7
cas [%o0], %g1, %g7
cmp %g1, %g7
bne,pn %icc, 1b
cmp %g7, 0
bl,pn %icc, 3f
nop
2: retl
nop
3: sethi %hi(RWSEM_ACTIVE_MASK), %g1
sub %g7, 1, %g7
or %g1, %lo(RWSEM_ACTIVE_MASK), %g1
andcc %g7, %g1, %g0
bne,pn %icc, 2b
nop
save %sp, -192, %sp
call rwsem_wake
mov %i0, %o0
ret
restore
.size __up_read, .-__up_read
.globl __up_write
__up_write:
sethi %hi(RWSEM_ACTIVE_WRITE_BIAS), %g1
or %g1, %lo(RWSEM_ACTIVE_WRITE_BIAS), %g1
1:
lduw [%o0], %g3
sub %g3, %g1, %g7
cas [%o0], %g3, %g7
cmp %g3, %g7
bne,pn %icc, 1b
sub %g7, %g1, %g7
cmp %g7, 0
bl,pn %icc, 3f
nop
2:
retl
nop
3:
save %sp, -192, %sp
call rwsem_wake
mov %i0, %o0
ret
restore
.size __up_write, .-__up_write
.globl __downgrade_write
__downgrade_write:
sethi %hi(RWSEM_WAITING_BIAS), %g1
or %g1, %lo(RWSEM_WAITING_BIAS), %g1
1:
lduw [%o0], %g3
sub %g3, %g1, %g7
cas [%o0], %g3, %g7
cmp %g3, %g7
bne,pn %icc, 1b
sub %g7, %g1, %g7
cmp %g7, 0
bl,pn %icc, 3f
nop
2:
retl
nop
3:
save %sp, -192, %sp
call rwsem_downgrade_wake
mov %i0, %o0
ret
restore
.size __downgrade_write, .-__downgrade_write
...@@ -9,18 +9,18 @@ ...@@ -9,18 +9,18 @@
#include <asm/thread_info.h> #include <asm/thread_info.h>
.text .text
.globl prom_cif_interface .globl prom_cif_direct
prom_cif_interface: prom_cif_direct:
sethi %hi(p1275buf), %o0 sethi %hi(p1275buf), %o1
or %o0, %lo(p1275buf), %o0 or %o1, %lo(p1275buf), %o1
ldx [%o0 + 0x010], %o1 ! prom_cif_stack ldx [%o1 + 0x0010], %o2 ! prom_cif_stack
save %o1, -192, %sp save %o2, -192, %sp
ldx [%i0 + 0x008], %l2 ! prom_cif_handler ldx [%i1 + 0x0008], %l2 ! prom_cif_handler
mov %g4, %l0 mov %g4, %l0
mov %g5, %l1 mov %g5, %l1
mov %g6, %l3 mov %g6, %l3
call %l2 call %l2
add %i0, 0x018, %o0 ! prom_args mov %i0, %o0 ! prom_args
mov %l0, %g4 mov %l0, %g4
mov %l1, %g5 mov %l1, %g5
mov %l3, %g6 mov %l3, %g6
......
...@@ -21,14 +21,22 @@ extern int prom_stdin, prom_stdout; ...@@ -21,14 +21,22 @@ extern int prom_stdin, prom_stdout;
inline int inline int
prom_nbgetchar(void) prom_nbgetchar(void)
{ {
unsigned long args[7];
char inc; char inc;
if (p1275_cmd("read", P1275_ARG(1,P1275_ARG_OUT_BUF)| args[0] = (unsigned long) "read";
P1275_INOUT(3,1), args[1] = 3;
prom_stdin, &inc, P1275_SIZE(1)) == 1) args[2] = 1;
args[3] = (unsigned int) prom_stdin;
args[4] = (unsigned long) &inc;
args[5] = 1;
args[6] = (unsigned long) -1;
p1275_cmd_direct(args);
if (args[6] == 1)
return inc; return inc;
else return -1;
return -1;
} }
/* Non blocking put character to console device, returns -1 if /* Non blocking put character to console device, returns -1 if
...@@ -37,12 +45,22 @@ prom_nbgetchar(void) ...@@ -37,12 +45,22 @@ prom_nbgetchar(void)
inline int inline int
prom_nbputchar(char c) prom_nbputchar(char c)
{ {
unsigned long args[7];
char outc; char outc;
outc = c; outc = c;
if (p1275_cmd("write", P1275_ARG(1,P1275_ARG_IN_BUF)|
P1275_INOUT(3,1), args[0] = (unsigned long) "write";
prom_stdout, &outc, P1275_SIZE(1)) == 1) args[1] = 3;
args[2] = 1;
args[3] = (unsigned int) prom_stdout;
args[4] = (unsigned long) &outc;
args[5] = 1;
args[6] = (unsigned long) -1;
p1275_cmd_direct(args);
if (args[6] == 1)
return 0; return 0;
else else
return -1; return -1;
...@@ -67,7 +85,15 @@ prom_putchar(char c) ...@@ -67,7 +85,15 @@ prom_putchar(char c)
void void
prom_puts(const char *s, int len) prom_puts(const char *s, int len)
{ {
p1275_cmd("write", P1275_ARG(1,P1275_ARG_IN_BUF)| unsigned long args[7];
P1275_INOUT(3,1),
prom_stdout, s, P1275_SIZE(len)); args[0] = (unsigned long) "write";
args[1] = 3;
args[2] = 1;
args[3] = (unsigned int) prom_stdout;
args[4] = (unsigned long) s;
args[5] = len;
args[6] = (unsigned long) -1;
p1275_cmd_direct(args);
} }
...@@ -18,16 +18,32 @@ ...@@ -18,16 +18,32 @@
int int
prom_devopen(const char *dstr) prom_devopen(const char *dstr)
{ {
return p1275_cmd ("open", P1275_ARG(0,P1275_ARG_IN_STRING)| unsigned long args[5];
P1275_INOUT(1,1),
dstr); args[0] = (unsigned long) "open";
args[1] = 1;
args[2] = 1;
args[3] = (unsigned long) dstr;
args[4] = (unsigned long) -1;
p1275_cmd_direct(args);
return (int) args[4];
} }
/* Close the device described by device handle 'dhandle'. */ /* Close the device described by device handle 'dhandle'. */
int int
prom_devclose(int dhandle) prom_devclose(int dhandle)
{ {
p1275_cmd ("close", P1275_INOUT(1,0), dhandle); unsigned long args[4];
args[0] = (unsigned long) "close";
args[1] = 1;
args[2] = 0;
args[3] = (unsigned int) dhandle;
p1275_cmd_direct(args);
return 0; return 0;
} }
...@@ -37,5 +53,15 @@ prom_devclose(int dhandle) ...@@ -37,5 +53,15 @@ prom_devclose(int dhandle)
void void
prom_seek(int dhandle, unsigned int seekhi, unsigned int seeklo) prom_seek(int dhandle, unsigned int seekhi, unsigned int seeklo)
{ {
p1275_cmd ("seek", P1275_INOUT(3,1), dhandle, seekhi, seeklo); unsigned long args[7];
args[0] = (unsigned long) "seek";
args[1] = 3;
args[2] = 1;
args[3] = (unsigned int) dhandle;
args[4] = seekhi;
args[5] = seeklo;
args[6] = (unsigned long) -1;
p1275_cmd_direct(args);
} }
This diff is collapsed.
...@@ -22,13 +22,11 @@ struct { ...@@ -22,13 +22,11 @@ struct {
long prom_callback; /* 0x00 */ long prom_callback; /* 0x00 */
void (*prom_cif_handler)(long *); /* 0x08 */ void (*prom_cif_handler)(long *); /* 0x08 */
unsigned long prom_cif_stack; /* 0x10 */ unsigned long prom_cif_stack; /* 0x10 */
unsigned long prom_args [23]; /* 0x18 */
char prom_buffer [3000];
} p1275buf; } p1275buf;
extern void prom_world(int); extern void prom_world(int);
extern void prom_cif_interface(void); extern void prom_cif_direct(unsigned long *args);
extern void prom_cif_callback(void); extern void prom_cif_callback(void);
/* /*
...@@ -36,114 +34,20 @@ extern void prom_cif_callback(void); ...@@ -36,114 +34,20 @@ extern void prom_cif_callback(void);
*/ */
DEFINE_RAW_SPINLOCK(prom_entry_lock); DEFINE_RAW_SPINLOCK(prom_entry_lock);
long p1275_cmd(const char *service, long fmt, ...) void p1275_cmd_direct(unsigned long *args)
{ {
char *p, *q;
unsigned long flags; unsigned long flags;
int nargs, nrets, i;
va_list list;
long attrs, x;
p = p1275buf.prom_buffer;
raw_local_save_flags(flags); raw_local_save_flags(flags);
raw_local_irq_restore(PIL_NMI); raw_local_irq_restore(PIL_NMI);
raw_spin_lock(&prom_entry_lock); raw_spin_lock(&prom_entry_lock);
p1275buf.prom_args[0] = (unsigned long)p; /* service */
strcpy (p, service);
p = (char *)(((long)(strchr (p, 0) + 8)) & ~7);
p1275buf.prom_args[1] = nargs = (fmt & 0x0f); /* nargs */
p1275buf.prom_args[2] = nrets = ((fmt & 0xf0) >> 4); /* nrets */
attrs = fmt >> 8;
va_start(list, fmt);
for (i = 0; i < nargs; i++, attrs >>= 3) {
switch (attrs & 0x7) {
case P1275_ARG_NUMBER:
p1275buf.prom_args[i + 3] =
(unsigned)va_arg(list, long);
break;
case P1275_ARG_IN_64B:
p1275buf.prom_args[i + 3] =
va_arg(list, unsigned long);
break;
case P1275_ARG_IN_STRING:
strcpy (p, va_arg(list, char *));
p1275buf.prom_args[i + 3] = (unsigned long)p;
p = (char *)(((long)(strchr (p, 0) + 8)) & ~7);
break;
case P1275_ARG_OUT_BUF:
(void) va_arg(list, char *);
p1275buf.prom_args[i + 3] = (unsigned long)p;
x = va_arg(list, long);
i++; attrs >>= 3;
p = (char *)(((long)(p + (int)x + 7)) & ~7);
p1275buf.prom_args[i + 3] = x;
break;
case P1275_ARG_IN_BUF:
q = va_arg(list, char *);
p1275buf.prom_args[i + 3] = (unsigned long)p;
x = va_arg(list, long);
i++; attrs >>= 3;
memcpy (p, q, (int)x);
p = (char *)(((long)(p + (int)x + 7)) & ~7);
p1275buf.prom_args[i + 3] = x;
break;
case P1275_ARG_OUT_32B:
(void) va_arg(list, char *);
p1275buf.prom_args[i + 3] = (unsigned long)p;
p += 32;
break;
case P1275_ARG_IN_FUNCTION:
p1275buf.prom_args[i + 3] =
(unsigned long)prom_cif_callback;
p1275buf.prom_callback = va_arg(list, long);
break;
}
}
va_end(list);
prom_world(1); prom_world(1);
prom_cif_interface(); prom_cif_direct(args);
prom_world(0); prom_world(0);
attrs = fmt >> 8;
va_start(list, fmt);
for (i = 0; i < nargs; i++, attrs >>= 3) {
switch (attrs & 0x7) {
case P1275_ARG_NUMBER:
(void) va_arg(list, long);
break;
case P1275_ARG_IN_STRING:
(void) va_arg(list, char *);
break;
case P1275_ARG_IN_FUNCTION:
(void) va_arg(list, long);
break;
case P1275_ARG_IN_BUF:
(void) va_arg(list, char *);
(void) va_arg(list, long);
i++; attrs >>= 3;
break;
case P1275_ARG_OUT_BUF:
p = va_arg(list, char *);
x = va_arg(list, long);
memcpy (p, (char *)(p1275buf.prom_args[i + 3]), (int)x);
i++; attrs >>= 3;
break;
case P1275_ARG_OUT_32B:
p = va_arg(list, char *);
memcpy (p, (char *)(p1275buf.prom_args[i + 3]), 32);
break;
}
}
va_end(list);
x = p1275buf.prom_args [nargs + 3];
raw_spin_unlock(&prom_entry_lock); raw_spin_unlock(&prom_entry_lock);
raw_local_irq_restore(flags); raw_local_irq_restore(flags);
return x;
} }
void prom_cif_init(void *cif_handler, void *cif_stack) void prom_cif_init(void *cif_handler, void *cif_stack)
......
...@@ -16,22 +16,39 @@ ...@@ -16,22 +16,39 @@
#include <asm/oplib.h> #include <asm/oplib.h>
#include <asm/ldc.h> #include <asm/ldc.h>
static int prom_node_to_node(const char *type, int node)
{
unsigned long args[5];
args[0] = (unsigned long) type;
args[1] = 1;
args[2] = 1;
args[3] = (unsigned int) node;
args[4] = (unsigned long) -1;
p1275_cmd_direct(args);
return (int) args[4];
}
/* Return the child of node 'node' or zero if no this node has no /* Return the child of node 'node' or zero if no this node has no
* direct descendent. * direct descendent.
*/ */
inline int __prom_getchild(int node) inline int __prom_getchild(int node)
{ {
return p1275_cmd ("child", P1275_INOUT(1, 1), node); return prom_node_to_node("child", node);
} }
inline int prom_getchild(int node) inline int prom_getchild(int node)
{ {
int cnode; int cnode;
if(node == -1) return 0; if (node == -1)
return 0;
cnode = __prom_getchild(node); cnode = __prom_getchild(node);
if(cnode == -1) return 0; if (cnode == -1)
return (int)cnode; return 0;
return cnode;
} }
EXPORT_SYMBOL(prom_getchild); EXPORT_SYMBOL(prom_getchild);
...@@ -39,10 +56,12 @@ inline int prom_getparent(int node) ...@@ -39,10 +56,12 @@ inline int prom_getparent(int node)
{ {
int cnode; int cnode;
if(node == -1) return 0; if (node == -1)
cnode = p1275_cmd ("parent", P1275_INOUT(1, 1), node); return 0;
if(cnode == -1) return 0; cnode = prom_node_to_node("parent", node);
return (int)cnode; if (cnode == -1)
return 0;
return cnode;
} }
/* Return the next sibling of node 'node' or zero if no more siblings /* Return the next sibling of node 'node' or zero if no more siblings
...@@ -50,7 +69,7 @@ inline int prom_getparent(int node) ...@@ -50,7 +69,7 @@ inline int prom_getparent(int node)
*/ */
inline int __prom_getsibling(int node) inline int __prom_getsibling(int node)
{ {
return p1275_cmd(prom_peer_name, P1275_INOUT(1, 1), node); return prom_node_to_node(prom_peer_name, node);
} }
inline int prom_getsibling(int node) inline int prom_getsibling(int node)
...@@ -72,11 +91,21 @@ EXPORT_SYMBOL(prom_getsibling); ...@@ -72,11 +91,21 @@ EXPORT_SYMBOL(prom_getsibling);
*/ */
inline int prom_getproplen(int node, const char *prop) inline int prom_getproplen(int node, const char *prop)
{ {
if((!node) || (!prop)) return -1; unsigned long args[6];
return p1275_cmd ("getproplen",
P1275_ARG(1,P1275_ARG_IN_STRING)| if (!node || !prop)
P1275_INOUT(2, 1), return -1;
node, prop);
args[0] = (unsigned long) "getproplen";
args[1] = 2;
args[2] = 1;
args[3] = (unsigned int) node;
args[4] = (unsigned long) prop;
args[5] = (unsigned long) -1;
p1275_cmd_direct(args);
return (int) args[5];
} }
EXPORT_SYMBOL(prom_getproplen); EXPORT_SYMBOL(prom_getproplen);
...@@ -87,19 +116,25 @@ EXPORT_SYMBOL(prom_getproplen); ...@@ -87,19 +116,25 @@ EXPORT_SYMBOL(prom_getproplen);
inline int prom_getproperty(int node, const char *prop, inline int prom_getproperty(int node, const char *prop,
char *buffer, int bufsize) char *buffer, int bufsize)
{ {
unsigned long args[8];
int plen; int plen;
plen = prom_getproplen(node, prop); plen = prom_getproplen(node, prop);
if ((plen > bufsize) || (plen == 0) || (plen == -1)) { if ((plen > bufsize) || (plen == 0) || (plen == -1))
return -1; return -1;
} else {
/* Ok, things seem all right. */ args[0] = (unsigned long) prom_getprop_name;
return p1275_cmd(prom_getprop_name, args[1] = 4;
P1275_ARG(1,P1275_ARG_IN_STRING)| args[2] = 1;
P1275_ARG(2,P1275_ARG_OUT_BUF)| args[3] = (unsigned int) node;
P1275_INOUT(4, 1), args[4] = (unsigned long) prop;
node, prop, buffer, P1275_SIZE(plen)); args[5] = (unsigned long) buffer;
} args[6] = bufsize;
args[7] = (unsigned long) -1;
p1275_cmd_direct(args);
return (int) args[7];
} }
EXPORT_SYMBOL(prom_getproperty); EXPORT_SYMBOL(prom_getproperty);
...@@ -110,7 +145,7 @@ inline int prom_getint(int node, const char *prop) ...@@ -110,7 +145,7 @@ inline int prom_getint(int node, const char *prop)
{ {
int intprop; int intprop;
if(prom_getproperty(node, prop, (char *) &intprop, sizeof(int)) != -1) if (prom_getproperty(node, prop, (char *) &intprop, sizeof(int)) != -1)
return intprop; return intprop;
return -1; return -1;
...@@ -126,7 +161,8 @@ int prom_getintdefault(int node, const char *property, int deflt) ...@@ -126,7 +161,8 @@ int prom_getintdefault(int node, const char *property, int deflt)
int retval; int retval;
retval = prom_getint(node, property); retval = prom_getint(node, property);
if(retval == -1) return deflt; if (retval == -1)
return deflt;
return retval; return retval;
} }
...@@ -138,7 +174,8 @@ int prom_getbool(int node, const char *prop) ...@@ -138,7 +174,8 @@ int prom_getbool(int node, const char *prop)
int retval; int retval;
retval = prom_getproplen(node, prop); retval = prom_getproplen(node, prop);
if(retval == -1) return 0; if (retval == -1)
return 0;
return 1; return 1;
} }
EXPORT_SYMBOL(prom_getbool); EXPORT_SYMBOL(prom_getbool);
...@@ -152,7 +189,8 @@ void prom_getstring(int node, const char *prop, char *user_buf, int ubuf_size) ...@@ -152,7 +189,8 @@ void prom_getstring(int node, const char *prop, char *user_buf, int ubuf_size)
int len; int len;
len = prom_getproperty(node, prop, user_buf, ubuf_size); len = prom_getproperty(node, prop, user_buf, ubuf_size);
if(len != -1) return; if (len != -1)
return;
user_buf[0] = 0; user_buf[0] = 0;
} }
EXPORT_SYMBOL(prom_getstring); EXPORT_SYMBOL(prom_getstring);
...@@ -164,7 +202,8 @@ int prom_nodematch(int node, const char *name) ...@@ -164,7 +202,8 @@ int prom_nodematch(int node, const char *name)
{ {
char namebuf[128]; char namebuf[128];
prom_getproperty(node, "name", namebuf, sizeof(namebuf)); prom_getproperty(node, "name", namebuf, sizeof(namebuf));
if(strcmp(namebuf, name) == 0) return 1; if (strcmp(namebuf, name) == 0)
return 1;
return 0; return 0;
} }
...@@ -190,16 +229,29 @@ int prom_searchsiblings(int node_start, const char *nodename) ...@@ -190,16 +229,29 @@ int prom_searchsiblings(int node_start, const char *nodename)
} }
EXPORT_SYMBOL(prom_searchsiblings); EXPORT_SYMBOL(prom_searchsiblings);
static const char *prom_nextprop_name = "nextprop";
/* Return the first property type for node 'node'. /* Return the first property type for node 'node'.
* buffer should be at least 32B in length * buffer should be at least 32B in length
*/ */
inline char *prom_firstprop(int node, char *buffer) inline char *prom_firstprop(int node, char *buffer)
{ {
unsigned long args[7];
*buffer = 0; *buffer = 0;
if(node == -1) return buffer; if (node == -1)
p1275_cmd ("nextprop", P1275_ARG(2,P1275_ARG_OUT_32B)| return buffer;
P1275_INOUT(3, 0),
node, (char *) 0x0, buffer); args[0] = (unsigned long) prom_nextprop_name;
args[1] = 3;
args[2] = 1;
args[3] = (unsigned int) node;
args[4] = 0;
args[5] = (unsigned long) buffer;
args[6] = (unsigned long) -1;
p1275_cmd_direct(args);
return buffer; return buffer;
} }
EXPORT_SYMBOL(prom_firstprop); EXPORT_SYMBOL(prom_firstprop);
...@@ -210,9 +262,10 @@ EXPORT_SYMBOL(prom_firstprop); ...@@ -210,9 +262,10 @@ EXPORT_SYMBOL(prom_firstprop);
*/ */
inline char *prom_nextprop(int node, const char *oprop, char *buffer) inline char *prom_nextprop(int node, const char *oprop, char *buffer)
{ {
unsigned long args[7];
char buf[32]; char buf[32];
if(node == -1) { if (node == -1) {
*buffer = 0; *buffer = 0;
return buffer; return buffer;
} }
...@@ -220,10 +273,17 @@ inline char *prom_nextprop(int node, const char *oprop, char *buffer) ...@@ -220,10 +273,17 @@ inline char *prom_nextprop(int node, const char *oprop, char *buffer)
strcpy (buf, oprop); strcpy (buf, oprop);
oprop = buf; oprop = buf;
} }
p1275_cmd ("nextprop", P1275_ARG(1,P1275_ARG_IN_STRING)|
P1275_ARG(2,P1275_ARG_OUT_32B)| args[0] = (unsigned long) prom_nextprop_name;
P1275_INOUT(3, 0), args[1] = 3;
node, oprop, buffer); args[2] = 1;
args[3] = (unsigned int) node;
args[4] = (unsigned long) oprop;
args[5] = (unsigned long) buffer;
args[6] = (unsigned long) -1;
p1275_cmd_direct(args);
return buffer; return buffer;
} }
EXPORT_SYMBOL(prom_nextprop); EXPORT_SYMBOL(prom_nextprop);
...@@ -231,12 +291,19 @@ EXPORT_SYMBOL(prom_nextprop); ...@@ -231,12 +291,19 @@ EXPORT_SYMBOL(prom_nextprop);
int int
prom_finddevice(const char *name) prom_finddevice(const char *name)
{ {
unsigned long args[5];
if (!name) if (!name)
return 0; return 0;
return p1275_cmd(prom_finddev_name, args[0] = (unsigned long) "finddevice";
P1275_ARG(0,P1275_ARG_IN_STRING)| args[1] = 1;
P1275_INOUT(1, 1), args[2] = 1;
name); args[3] = (unsigned long) name;
args[4] = (unsigned long) -1;
p1275_cmd_direct(args);
return (int) args[4];
} }
EXPORT_SYMBOL(prom_finddevice); EXPORT_SYMBOL(prom_finddevice);
...@@ -247,7 +314,7 @@ int prom_node_has_property(int node, const char *prop) ...@@ -247,7 +314,7 @@ int prom_node_has_property(int node, const char *prop)
*buf = 0; *buf = 0;
do { do {
prom_nextprop(node, buf, buf); prom_nextprop(node, buf, buf);
if(!strcmp(buf, prop)) if (!strcmp(buf, prop))
return 1; return 1;
} while (*buf); } while (*buf);
return 0; return 0;
...@@ -260,6 +327,8 @@ EXPORT_SYMBOL(prom_node_has_property); ...@@ -260,6 +327,8 @@ EXPORT_SYMBOL(prom_node_has_property);
int int
prom_setprop(int node, const char *pname, char *value, int size) prom_setprop(int node, const char *pname, char *value, int size)
{ {
unsigned long args[8];
if (size == 0) if (size == 0)
return 0; return 0;
if ((pname == 0) || (value == 0)) if ((pname == 0) || (value == 0))
...@@ -271,19 +340,37 @@ prom_setprop(int node, const char *pname, char *value, int size) ...@@ -271,19 +340,37 @@ prom_setprop(int node, const char *pname, char *value, int size)
return 0; return 0;
} }
#endif #endif
return p1275_cmd ("setprop", P1275_ARG(1,P1275_ARG_IN_STRING)| args[0] = (unsigned long) "setprop";
P1275_ARG(2,P1275_ARG_IN_BUF)| args[1] = 4;
P1275_INOUT(4, 1), args[2] = 1;
node, pname, value, P1275_SIZE(size)); args[3] = (unsigned int) node;
args[4] = (unsigned long) pname;
args[5] = (unsigned long) value;
args[6] = size;
args[7] = (unsigned long) -1;
p1275_cmd_direct(args);
return (int) args[7];
} }
EXPORT_SYMBOL(prom_setprop); EXPORT_SYMBOL(prom_setprop);
inline int prom_inst2pkg(int inst) inline int prom_inst2pkg(int inst)
{ {
unsigned long args[5];
int node; int node;
node = p1275_cmd ("instance-to-package", P1275_INOUT(1, 1), inst); args[0] = (unsigned long) "instance-to-package";
if (node == -1) return 0; args[1] = 1;
args[2] = 1;
args[3] = (unsigned int) inst;
args[4] = (unsigned long) -1;
p1275_cmd_direct(args);
node = (int) args[4];
if (node == -1)
return 0;
return node; return node;
} }
...@@ -296,17 +383,28 @@ prom_pathtoinode(const char *path) ...@@ -296,17 +383,28 @@ prom_pathtoinode(const char *path)
int node, inst; int node, inst;
inst = prom_devopen (path); inst = prom_devopen (path);
if (inst == 0) return 0; if (inst == 0)
node = prom_inst2pkg (inst); return 0;
prom_devclose (inst); node = prom_inst2pkg(inst);
if (node == -1) return 0; prom_devclose(inst);
if (node == -1)
return 0;
return node; return node;
} }
int prom_ihandle2path(int handle, char *buffer, int bufsize) int prom_ihandle2path(int handle, char *buffer, int bufsize)
{ {
return p1275_cmd("instance-to-path", unsigned long args[7];
P1275_ARG(1,P1275_ARG_OUT_BUF)|
P1275_INOUT(3, 1), args[0] = (unsigned long) "instance-to-path";
handle, buffer, P1275_SIZE(bufsize)); args[1] = 3;
args[2] = 1;
args[3] = (unsigned int) handle;
args[4] = (unsigned long) buffer;
args[5] = bufsize;
args[6] = (unsigned long) -1;
p1275_cmd_direct(args);
return (int) args[6];
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment