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.
8 * NaCl local descriptor table (LDT) managment
10 #ifndef SERVICE_RUNTIME_NACL_LDT_H__
11 #define SERVICE_RUNTIME_NACL_LDT_H__ 1
13 #include "native_client/src/include/portability.h"
17 /* TODO(petr): this should go to linux/x86 */
20 * The modify_ldt system call is used to get and set the local descriptor
23 extern int modify_ldt(int func, void* ptr, unsigned long bytecount);
27 * Module initialization and finalization.
29 extern int NaClLdtInit(void);
30 extern void NaClLdtFini(void);
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.
38 NACL_LDT_DESCRIPTOR_DATA,
39 NACL_LDT_DESCRIPTOR_CODE
40 } NaClLdtDescriptorType;
42 uint16_t NaClLdtAllocatePageSelector(NaClLdtDescriptorType type,
45 uint32_t size_in_pages);
47 uint16_t NaClLdtAllocateByteSelector(NaClLdtDescriptorType type,
50 uint32_t size_in_bytes);
52 uint16_t NaClLdtChangePageSelector(int32_t entry_number,
53 NaClLdtDescriptorType type,
56 uint32_t size_in_pages);
58 uint16_t NaClLdtChangeByteSelector(int32_t entry_number,
59 NaClLdtDescriptorType type,
62 uint32_t size_in_bytes);
64 uint16_t NaClLdtAllocateSelector(int entry_number,
66 NaClLdtDescriptorType type,
69 uint32_t size_minus_one);
72 * NaClLdtDeleteSelector frees the LDT entry associated with a given selector.
74 void NaClLdtDeleteSelector(uint16_t selector);
77 * NaClLdtPrintSelector prints the local descriptor table for the specified
80 void NaClLdtPrintSelector(uint16_t selector);