Merge tag 'linux-watchdog-4.20-rc1' of git://www.linux-watchdog.org/linux-watchdog
[sfrench/cifs-2.6.git] / arch / powerpc / kernel / vdso64 / datapage.S
1 /*
2  * Access to the shared data page by the vDSO & syscall map
3  *
4  * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org), IBM Corp.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version
9  * 2 of the License, or (at your option) any later version.
10  */
11
12 #include <asm/processor.h>
13 #include <asm/ppc_asm.h>
14 #include <asm/asm-offsets.h>
15 #include <asm/unistd.h>
16 #include <asm/vdso.h>
17
18         .text
19 .global __kernel_datapage_offset;
20 __kernel_datapage_offset:
21         .long   0
22
23 V_FUNCTION_BEGIN(__get_datapage)
24   .cfi_startproc
25         /* We don't want that exposed or overridable as we want other objects
26          * to be able to bl directly to here
27          */
28         .protected __get_datapage
29         .hidden __get_datapage
30
31         mflr    r0
32   .cfi_register lr,r0
33
34         bcl     20,31,data_page_branch
35 data_page_branch:
36         mflr    r3
37         mtlr    r0
38         addi    r3, r3, __kernel_datapage_offset-data_page_branch
39         lwz     r0,0(r3)
40   .cfi_restore lr
41         add     r3,r0,r3
42         blr
43   .cfi_endproc
44 V_FUNCTION_END(__get_datapage)
45
46 /*
47  * void *__kernel_get_syscall_map(unsigned int *syscall_count) ;
48  *
49  * returns a pointer to the syscall map. the map is agnostic to the
50  * size of "long", unlike kernel bitops, it stores bits from top to
51  * bottom so that memory actually contains a linear bitmap
52  * check for syscall N by testing bit (0x80000000 >> (N & 0x1f)) of
53  * 32 bits int at N >> 5.
54  */
55 V_FUNCTION_BEGIN(__kernel_get_syscall_map)
56   .cfi_startproc
57         mflr    r12
58   .cfi_register lr,r12
59         mr      r4,r3
60         bl      V_LOCAL_FUNC(__get_datapage)
61         mtlr    r12
62         addi    r3,r3,CFG_SYSCALL_MAP64
63         cmpldi  cr0,r4,0
64         crclr   cr0*4+so
65         beqlr
66         li      r0,NR_syscalls
67         stw     r0,0(r4)
68         blr
69   .cfi_endproc
70 V_FUNCTION_END(__kernel_get_syscall_map)
71
72
73 /*
74  * void unsigned long  __kernel_get_tbfreq(void);
75  *
76  * returns the timebase frequency in HZ
77  */
78 V_FUNCTION_BEGIN(__kernel_get_tbfreq)
79   .cfi_startproc
80         mflr    r12
81   .cfi_register lr,r12
82         bl      V_LOCAL_FUNC(__get_datapage)
83         ld      r3,CFG_TB_TICKS_PER_SEC(r3)
84         mtlr    r12
85         crclr   cr0*4+so
86         blr
87   .cfi_endproc
88 V_FUNCTION_END(__kernel_get_tbfreq)