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
4 : * be found in the LICENSE file.
5 : */
6 :
7 : /*
8 : * NaCl local descriptor table (LDT) management - common for all platforms
9 : */
10 :
11 : #include "native_client/src/trusted/service_runtime/arch/x86/nacl_ldt_x86.h"
12 : /* for LDT_ENTRIES */
13 : #include "native_client/src/trusted/service_runtime/arch/x86/sel_ldr_x86.h"
14 :
15 : /* TODO(gregoryd): These need to come from a header file. */
16 : extern int NaClLdtInitPlatformSpecific();
17 : extern int NaClLdtFiniPlatformSpecific();
18 :
19 :
20 14 : int NaClLdtInit() {
21 14 : if (!NaClLdtInitPlatformSpecific()) {
22 0 : return 0;
23 : }
24 : /* Allocate the last LDT entry to force LDT grow to its maximum size */
25 14 : if (!NaClLdtAllocateSelector(LDT_ENTRIES - 1, 0,
26 : NACL_LDT_DESCRIPTOR_DATA, 0, 0, 0)) {
27 0 : return 0;
28 : }
29 14 : return 1;
30 : }
31 :
32 :
33 9 : void NaClLdtFini() {
34 9 : NaClLdtFiniPlatformSpecific();
35 9 : }
|