version 1.22, 2008/12/05 13:08:11 |
version 1.23, 2009/04/24 17:45:40 |
|
|
/* $NetBSD$ */ |
/* $NetBSD$ */ |
|
|
/*- |
/*- |
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. |
* Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. |
* All rights reserved. |
* All rights reserved. |
* |
* |
* This code is derived from software contributed to The NetBSD Foundation |
* This code is derived from software contributed to The NetBSD Foundation |
Line 46 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 46 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#define ALIGN64 .align 64 |
#define ALIGN64 .align 64 |
#define ALIGN32 .align 32 |
#define ALIGN32 .align 32 |
#define LOCK(num) .Lpatch/**/num: lock |
#define LOCK(num) .Lpatch/**/num: lock |
|
#define RET(num) .Lret/**/num: ret; nop; nop; ret |
#define ENDLABEL(name,a) .align a; LABEL(name) |
#define ENDLABEL(name,a) .align a; LABEL(name) |
|
|
#if !defined(LOCKDEBUG) |
#if !defined(LOCKDEBUG) |
Line 59 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 60 __KERNEL_RCSID(0, "$NetBSD$"); |
|
|
|
ENTRY(mutex_enter) |
ENTRY(mutex_enter) |
movl 4(%esp), %edx |
movl 4(%esp), %edx |
movl CPUVAR(CURLWP), %ecx |
|
xorl %eax, %eax |
xorl %eax, %eax |
|
movl %fs:CPU_INFO_CURLWP(%eax), %ecx |
LOCK(1) |
LOCK(1) |
cmpxchgl %ecx, (%edx) |
cmpxchgl %ecx, (%edx) |
jnz 1f |
jnz 1f |
ret |
RET(1) |
1: |
1: |
jmp _C_LABEL(mutex_vector_enter) |
jmp _C_LABEL(mutex_vector_enter) |
END(mutex_enter) |
END(mutex_enter) |
|
|
*/ |
*/ |
ENTRY(mutex_exit) |
ENTRY(mutex_exit) |
movl 4(%esp), %edx |
movl 4(%esp), %edx |
movl CPUVAR(CURLWP), %eax |
|
xorl %ecx, %ecx |
xorl %ecx, %ecx |
|
movl %fs:CPU_INFO_CURLWP(%ecx), %eax |
cmpxchgl %ecx, (%edx) |
cmpxchgl %ecx, (%edx) |
jnz 1f |
jnz 1f |
ret |
ret |
|
|
LOCK(2) |
LOCK(2) |
cmpxchgl %ecx, (%edx) |
cmpxchgl %ecx, (%edx) |
jnz 1f |
jnz 1f |
ret |
RET(2) |
1: |
1: |
jmp 0b |
jmp 0b |
|
|
/* |
/* |
* Writer |
* Writer |
*/ |
*/ |
2: movl CPUVAR(CURLWP), %ecx |
2: xorl %eax, %eax |
xorl %eax, %eax |
movl %fs:CPU_INFO_CURLWP(%eax), %ecx |
orl $RW_WRITE_LOCKED, %ecx |
orl $RW_WRITE_LOCKED, %ecx |
LOCK(3) |
LOCK(3) |
cmpxchgl %ecx, (%edx) |
cmpxchgl %ecx, (%edx) |
jnz 3f |
jnz 3f |
ret |
RET(3) |
3: |
3: |
jmp _C_LABEL(rw_vector_enter) |
jmp _C_LABEL(rw_vector_enter) |
END(rw_enter) |
END(rw_enter) |
Line 187 ENTRY(rw_tryenter) |
|
Line 188 ENTRY(rw_tryenter) |
|
movl (%edx), %eax |
movl (%edx), %eax |
0: |
0: |
testb $(RW_WRITE_LOCKED|RW_WRITE_WANTED), %al |
testb $(RW_WRITE_LOCKED|RW_WRITE_WANTED), %al |
jnz 3f |
jnz 4f |
leal RW_READ_INCR(%eax), %ecx |
leal RW_READ_INCR(%eax), %ecx |
LOCK(12) |
LOCK(12) |
cmpxchgl %ecx, (%edx) |
cmpxchgl %ecx, (%edx) |
jnz 1f |
jnz 1f |
movl %edx, %eax /* nonzero */ |
movl %edx, %eax /* nonzero */ |
ret |
RET(4) |
1: |
1: |
jmp 0b |
jmp 0b |
|
|
Line 201 ENTRY(rw_tryenter) |
|
Line 202 ENTRY(rw_tryenter) |
|
* Writer |
* Writer |
*/ |
*/ |
2: |
2: |
movl CPUVAR(CURLWP), %ecx |
|
orl $RW_WRITE_LOCKED, %ecx |
|
xorl %eax, %eax |
xorl %eax, %eax |
|
movl %fs:CPU_INFO_CURLWP(%eax), %ecx |
|
orl $RW_WRITE_LOCKED, %ecx |
LOCK(13) |
LOCK(13) |
cmpxchgl %ecx, (%edx) |
cmpxchgl %ecx, (%edx) |
movl $0, %eax |
movl $0, %eax |
setz %al |
setz %al |
ret |
|
3: |
3: |
|
RET(5) |
|
4: |
xorl %eax, %eax |
xorl %eax, %eax |
ret |
jmp 3b |
END(rw_tryenter) |
END(rw_tryenter) |
|
|
#ifndef __XEN__ |
#ifndef __XEN__ |
Line 237 ENTRY(mutex_spin_enter) |
|
Line 239 ENTRY(mutex_spin_enter) |
|
xchgb %al, MTX_LOCK(%edx) /* lock it */ |
xchgb %al, MTX_LOCK(%edx) /* lock it */ |
testb %al, %al |
testb %al, %al |
jnz 3f |
jnz 3f |
ret |
RET(6) |
3: |
3: |
jmp _C_LABEL(mutex_spin_retry) |
jmp _C_LABEL(mutex_spin_retry) |
|
|
Line 326 NENTRY(__cpu_simple_lock) |
|
Line 328 NENTRY(__cpu_simple_lock) |
|
LOCK(6) |
LOCK(6) |
cmpxchgb %ah, (%edx) |
cmpxchgb %ah, (%edx) |
jnz 2f |
jnz 2f |
ret |
RET(7) |
2: |
2: |
movl $0x0100, %eax |
movl $0x0100, %eax |
pause |
pause |
Line 350 ENTRY(__cpu_simple_lock_try) |
|
Line 352 ENTRY(__cpu_simple_lock_try) |
|
cmpxchgb %ah, (%edx) |
cmpxchgb %ah, (%edx) |
movl $0, %eax |
movl $0, %eax |
setz %al |
setz %al |
ret |
RET(8) |
END(__cpu_simple_lock_try) |
END(__cpu_simple_lock_try) |
|
|
/* |
/* |
Line 365 LABEL(x86_lockpatch) |
|
Line 367 LABEL(x86_lockpatch) |
|
.long .Lpatch13 |
.long .Lpatch13 |
.long 0 |
.long 0 |
#endif |
#endif |
|
|
|
LABEL(x86_retpatch) |
|
#ifndef LOCKDEBUG |
|
.long .Lret1, .Lret2, .Lret3, .Lret4, .Lret5 |
|
#ifndef __XEN__ |
|
.long .Lret6 |
|
#endif |
|
#endif |
|
.long .Lret7, .Lret8 |
|
.long 0 |