blob: 2a7eb5452aba79fc4d2b2c709642b0e71cfc6130 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <asm/processor.h>
13#include <asm/ppc_asm.h>
Sam Ravnborg0013a852005-09-09 20:57:26 +020014#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <asm/unistd.h>
16#include <asm/vdso.h>
17
18 .text
Michael Neulingc9748092015-09-25 14:01:40 +100019 .global __kernel_datapage_offset;
20__kernel_datapage_offset:
21 .long 0
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023V_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
Michael Neulingc9748092015-09-25 14:01:40 +100034 bcl 20,31,data_page_branch
35data_page_branch:
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 mflr r3
37 mtlr r0
Michael Neulingc9748092015-09-25 14:01:40 +100038 addi r3, r3, __kernel_datapage_offset-data_page_branch
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 lwz r0,0(r3)
Alan Modra039eb3d2018-09-14 13:10:04 +093040 .cfi_restore lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 add r3,r0,r3
42 blr
43 .cfi_endproc
44V_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 */
55V_FUNCTION_BEGIN(__kernel_get_syscall_map)
56 .cfi_startproc
57 mflr r12
58 .cfi_register lr,r12
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 mr r4,r3
60 bl __get_datapage@local
61 mtlr r12
62 addi r3,r3,CFG_SYSCALL_MAP32
63 cmpli cr0,r4,0
64 beqlr
Rashmica Guptaf43194e2015-11-19 17:04:53 +110065 li r0,NR_syscalls
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 stw r0,0(r4)
Benjamin Herrenschmidt5d66da32005-11-16 13:54:32 +110067 crclr cr0*4+so
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 blr
69 .cfi_endproc
70V_FUNCTION_END(__kernel_get_syscall_map)
Benjamin Herrenschmidta7f290d2005-11-11 21:15:21 +110071
72/*
73 * void unsigned long long __kernel_get_tbfreq(void);
74 *
75 * returns the timebase frequency in HZ
76 */
77V_FUNCTION_BEGIN(__kernel_get_tbfreq)
78 .cfi_startproc
79 mflr r12
80 .cfi_register lr,r12
81 bl __get_datapage@local
Benjamin Herrenschmidta7f290d2005-11-11 21:15:21 +110082 lwz r4,(CFG_TB_TICKS_PER_SEC + 4)(r3)
Benjamin Herrenschmidt0c37ec22005-11-14 14:55:58 +110083 lwz r3,CFG_TB_TICKS_PER_SEC(r3)
Benjamin Herrenschmidta7f290d2005-11-11 21:15:21 +110084 mtlr r12
Benjamin Herrenschmidt5d66da32005-11-16 13:54:32 +110085 crclr cr0*4+so
Benjamin Herrenschmidt0c37ec22005-11-14 14:55:58 +110086 blr
Benjamin Herrenschmidta7f290d2005-11-11 21:15:21 +110087 .cfi_endproc
88V_FUNCTION_END(__kernel_get_tbfreq)