Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / native_client / src / trusted / service_runtime / arch / x86 / nacl_ldt_x86.h
1 /*
2  * Copyright 2008 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7 /*
8  * NaCl local descriptor table (LDT) managment
9  */
10 #ifndef SERVICE_RUNTIME_NACL_LDT_H__
11 #define SERVICE_RUNTIME_NACL_LDT_H__ 1
12
13 #include "native_client/src/include/portability.h"
14
15 EXTERN_C_BEGIN
16
17 /* TODO(petr): this should go to linux/x86 */
18 #if NACL_LINUX
19 /*
20  * The modify_ldt system call is used to get and set the local descriptor
21  * table.
22  */
23 extern int modify_ldt(int func, void* ptr, unsigned long bytecount);
24 #endif
25
26 /*
27  * Module initialization and finalization.
28  */
29 extern int NaClLdtInit(void);
30 extern void NaClLdtFini(void);
31
32 /*
33  * NaClLdtAllocateSelector creates an entry installed in the local descriptor
34  * table. If successfully installed, it returns a non-zero selector.  If it
35  * fails to install the entry, it returns zero.
36  */
37 typedef enum {
38   NACL_LDT_DESCRIPTOR_DATA,
39   NACL_LDT_DESCRIPTOR_CODE
40 } NaClLdtDescriptorType;
41
42 uint16_t NaClLdtAllocatePageSelector(NaClLdtDescriptorType type,
43                                      int read_exec_only,
44                                      void* base_addr,
45                                      uint32_t size_in_pages);
46
47 uint16_t NaClLdtAllocateByteSelector(NaClLdtDescriptorType type,
48                                      int read_exec_only,
49                                      void* base_addr,
50                                      uint32_t size_in_bytes);
51
52 uint16_t NaClLdtChangePageSelector(int32_t entry_number,
53                                    NaClLdtDescriptorType type,
54                                    int read_exec_only,
55                                    void* base_addr,
56                                    uint32_t size_in_pages);
57
58 uint16_t NaClLdtChangeByteSelector(int32_t entry_number,
59                                    NaClLdtDescriptorType type,
60                                    int read_exec_only,
61                                    void* base_addr,
62                                    uint32_t size_in_bytes);
63
64 uint16_t NaClLdtAllocateSelector(int entry_number,
65                                  int size_is_in_pages,
66                                  NaClLdtDescriptorType type,
67                                  int read_exec_only,
68                                  void* base_addr,
69                                  uint32_t size_minus_one);
70
71 /*
72  * NaClLdtDeleteSelector frees the LDT entry associated with a given selector.
73  */
74 void NaClLdtDeleteSelector(uint16_t selector);
75
76 /*
77  * NaClLdtPrintSelector prints the local descriptor table for the specified
78  * selector.
79  */
80 void NaClLdtPrintSelector(uint16_t selector);
81
82 EXTERN_C_END
83
84 #endif
85