1 | # Copyright (c) 2001, Stanford University
|
---|
2 | # All rights reserved.
|
---|
3 | #
|
---|
4 | # See the file LICENSE.txt for information on redistributing this software.
|
---|
5 |
|
---|
6 |
|
---|
7 | from __future__ import print_function
|
---|
8 | import sys
|
---|
9 |
|
---|
10 | import apiutil
|
---|
11 |
|
---|
12 |
|
---|
13 | def GenerateEntrypoints():
|
---|
14 |
|
---|
15 | #apiutil.CopyrightC()
|
---|
16 |
|
---|
17 | # Get sorted list of dispatched functions.
|
---|
18 | # The order is very important - it must match cr_opcodes.h
|
---|
19 | # and spu_dispatch_table.h
|
---|
20 | print('%include "iprt/asmdefs.mac"')
|
---|
21 | print("")
|
---|
22 | print("%ifdef RT_ARCH_AMD64")
|
---|
23 | print("extern glim")
|
---|
24 | print("%else ; X86")
|
---|
25 | print("extern glim")
|
---|
26 | print("%endif")
|
---|
27 | print("")
|
---|
28 |
|
---|
29 | keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
|
---|
30 |
|
---|
31 | for index in range(len(keys)):
|
---|
32 | func_name = keys[index]
|
---|
33 | if apiutil.Category(func_name) == "Chromium":
|
---|
34 | continue
|
---|
35 | if apiutil.Category(func_name) == "VBox":
|
---|
36 | continue
|
---|
37 |
|
---|
38 | print("BEGINPROC_EXPORTED gl%s" % func_name)
|
---|
39 | print("%ifdef RT_ARCH_AMD64")
|
---|
40 | print("\tmov \trax, qword glim+%d" % (8*index))
|
---|
41 | print("\tjmp \t[rax]")
|
---|
42 | print("%else ; X86")
|
---|
43 | print("\tmov \teax, dword glim+%d" % (4*index))
|
---|
44 | print("\tjmp \t[eax]")
|
---|
45 | print("%endif")
|
---|
46 | print("ENDPROC gl%s" % func_name)
|
---|
47 | print("")
|
---|
48 |
|
---|
49 |
|
---|
50 | print(';')
|
---|
51 | print('; Aliases')
|
---|
52 | print(';')
|
---|
53 |
|
---|
54 | # Now loop over all the functions and take care of any aliases
|
---|
55 | allkeys = apiutil.GetAllFunctions(sys.argv[1]+"/APIspec.txt")
|
---|
56 | for func_name in allkeys:
|
---|
57 | if "omit" in apiutil.ChromiumProps(func_name):
|
---|
58 | continue
|
---|
59 |
|
---|
60 | if func_name in keys:
|
---|
61 | # we already processed this function earlier
|
---|
62 | continue
|
---|
63 |
|
---|
64 | # alias is the function we're aliasing
|
---|
65 | alias = apiutil.Alias(func_name)
|
---|
66 | if alias:
|
---|
67 | # this dict lookup should never fail (raise an exception)!
|
---|
68 | index = keys.index(alias)
|
---|
69 | print("BEGINPROC_EXPORTED gl%s" % func_name)
|
---|
70 | print("%ifdef RT_ARCH_AMD64")
|
---|
71 | print("\tmov \trax, qword glim+%d" % (8*index))
|
---|
72 | print("\tjmp \t[rax]")
|
---|
73 | print("%else ; X86")
|
---|
74 | print("\tmov \teax, dword glim+%d" % (4*index))
|
---|
75 | print("\tjmp \t[eax]")
|
---|
76 | print("%endif")
|
---|
77 | print("ENDPROC gl%s" % func_name)
|
---|
78 | print("")
|
---|
79 |
|
---|
80 |
|
---|
81 | print(';')
|
---|
82 | print('; No-op stubs')
|
---|
83 | print(';')
|
---|
84 |
|
---|
85 | # Now generate no-op stub functions
|
---|
86 | for func_name in allkeys:
|
---|
87 | if "stub" in apiutil.ChromiumProps(func_name):
|
---|
88 | print("BEGINPROC_EXPORTED gl%s" % func_name)
|
---|
89 | print("\tleave")
|
---|
90 | print("\tret")
|
---|
91 | print("ENDPROC gl%s" % func_name)
|
---|
92 | print("")
|
---|
93 |
|
---|
94 |
|
---|
95 | GenerateEntrypoints()
|
---|
96 |
|
---|