blob: 1c120c04b950bf232f2503d9e32b6d440f44c2f1 [file] [log] [blame]
Patrick Williams520786c2023-06-25 16:20:36 -05001Upstream-Status: Pending
2
Patrick Williamsb48b7b42016-08-17 15:04:38 -05003Upstream-Statue: Pending
4[from ftp://195.220.108.108/linux/fedora/linux/development/rawhide/source/SRPMS/l/libx86-1.1-21.fc23.src.rpm]
5
6diff -ur libx86-1.1/lrmi.c libx86-1.1.hack/lrmi.c
7--- libx86-1.1/lrmi.c 2006-10-30 15:10:16.000000000 -0500
8+++ libx86-1.1.hack/lrmi.c 2009-10-26 15:55:42.000000000 -0400
9@@ -136,7 +136,7 @@
10 if (context.ready)
11 return 1;
12
13- if (!LRMI_common_init())
14+ if (!LRMI_common_init(0))
15 return 0;
16
17 /*
18diff -ur libx86-1.1/thunk.c libx86-1.1.hack/thunk.c
19--- libx86-1.1/thunk.c 2008-04-02 20:48:00.000000000 -0400
20+++ libx86-1.1.hack/thunk.c 2009-10-26 16:05:39.000000000 -0400
21@@ -139,11 +139,11 @@
22 int i;
23 X86EMU_intrFuncs intFuncs[256];
24
25- if (!LRMI_common_init())
26+ mmap_addr = LRMI_common_init(1);
27+
28+ if (!mmap_addr)
29 return 0;
30
31- mmap_addr = 0;
32-
33 X86EMU_pioFuncs pioFuncs = {
34 (&x_inb),
35 (&x_inw),
36@@ -169,10 +169,10 @@
37 X86_ESP = 0xFFF9;
38 memset (stack, 0, 64*1024);
39
40- *((char *)0) = 0x4f; /* Make sure that we end up jumping back to a
41- halt instruction */
42+ *mmap_addr = 0x4f; /* Make sure that we end up jumping back to a
43+ halt instruction */
44
45- M.mem_base = 0;
46+ M.mem_base = (unsigned long)mmap_addr;
47 M.mem_size = 1024*1024;
48
49 return 1;
50diff -ur libx86-1.1/x86-common.c libx86-1.1.hack/x86-common.c
51--- libx86-1.1/x86-common.c 2008-05-16 12:56:23.000000000 -0400
52+++ libx86-1.1.hack/x86-common.c 2009-10-26 16:03:21.000000000 -0400
53@@ -45,14 +45,15 @@
54 static struct {
55 int ready;
56 int count;
57+ void *offset;
58 struct mem_block blocks[REAL_MEM_BLOCKS];
59 } mem_info = { 0 };
60
61 static int
62-real_mem_init(void)
63+real_mem_init(int high_page)
64 {
65 void *m;
66- int fd_zero;
67+ int fd_zero, flags = MAP_SHARED;
68
69 if (mem_info.ready)
70 return 1;
71@@ -63,9 +64,12 @@
72 return 0;
73 }
74
75+ if (!high_page)
76+ flags |= MAP_FIXED;
77+
78 m = mmap((void *)REAL_MEM_BASE, REAL_MEM_SIZE,
79- PROT_READ | PROT_WRITE | PROT_EXEC,
80- MAP_FIXED | MAP_SHARED, fd_zero, 0);
81+ PROT_READ | PROT_WRITE | PROT_EXEC,
82+ flags, fd_zero, 0);
83
84 if (m == (void *)-1) {
85 perror("mmap /dev/zero");
86@@ -76,6 +80,7 @@
87 close(fd_zero);
88
89 mem_info.ready = 1;
90+ mem_info.offset = m;
91 mem_info.count = 1;
92 mem_info.blocks[0].size = REAL_MEM_SIZE;
93 mem_info.blocks[0].free = 1;
94@@ -87,7 +92,7 @@
95 real_mem_deinit(void)
96 {
97 if (mem_info.ready) {
98- munmap((void *)REAL_MEM_BASE, REAL_MEM_SIZE);
99+ munmap(mem_info.offset, REAL_MEM_SIZE);
100 mem_info.ready = 0;
101 }
102 }
103@@ -119,7 +124,7 @@
104 LRMI_alloc_real(int size)
105 {
106 int i;
107- char *r = (char *)REAL_MEM_BASE;
108+ char *r = (char *)mem_info.offset;
109
110 if (!mem_info.ready)
111 return NULL;
112@@ -151,7 +156,7 @@
113 LRMI_free_real(void *m)
114 {
115 int i;
116- char *r = (char *)REAL_MEM_BASE;
117+ char *r = (char *)mem_info.offset;
118
119 if (!mem_info.ready)
120 return;
121@@ -200,13 +205,15 @@
122 return *(unsigned short *)(i * 4);
123 }
124
125-int LRMI_common_init(void)
126+void *LRMI_common_init(int high_page)
127 {
128- void *m;
129+ void *m, *offset;
130 int fd_mem;
131
132- if (!real_mem_init())
133- return 0;
134+ if (!real_mem_init(high_page))
135+ return NULL;
136+
137+ offset = mem_info.offset - REAL_MEM_BASE;
138
139 /*
140 Map the Interrupt Vectors (0x0 - 0x400) + BIOS data (0x400 - 0x502)
141@@ -217,33 +224,33 @@
142 if (fd_mem == -1) {
143 real_mem_deinit();
144 perror("open /dev/mem");
145- return 0;
146+ return NULL;
147 }
148
149- m = mmap((void *)0, 0x502,
150- PROT_READ | PROT_WRITE | PROT_EXEC,
151- MAP_FIXED | MAP_SHARED, fd_mem, 0);
152+ m = mmap(offset, 0x502,
153+ PROT_READ | PROT_WRITE | PROT_EXEC,
154+ MAP_FIXED | MAP_SHARED, fd_mem, 0);
155
156 if (m == (void *)-1) {
157 close(fd_mem);
158 real_mem_deinit();
159 perror("mmap /dev/mem");
160- return 0;
161+ return NULL;
162 }
163
164- m = mmap((void *)0xa0000, 0x100000 - 0xa0000,
165+ m = mmap(offset+0xa0000, 0x100000 - 0xa0000,
166 PROT_READ | PROT_WRITE | PROT_EXEC,
167 MAP_FIXED | MAP_SHARED, fd_mem, 0xa0000);
168
169 if (m == (void *)-1) {
170- munmap((void *)0, 0x502);
171+ munmap(offset, 0x502);
172 close(fd_mem);
173 real_mem_deinit();
174 perror("mmap /dev/mem");
175- return 0;
176+ return NULL;
177 }
178
179 close(fd_mem);
180
181- return 1;
182+ return offset;
183 }
184diff -ur libx86-1.1/x86-common.h libx86-1.1.hack/x86-common.h
185--- libx86-1.1/x86-common.h 2006-09-07 18:44:27.000000000 -0400
186+++ libx86-1.1.hack/x86-common.h 2009-10-26 16:01:19.000000000 -0400
187@@ -40,4 +40,4 @@
188
189 void *LRMI_alloc_real(int size);
190 void LRMI_free_real(void *m);
191-int LRMI_common_init(void);
192+void *LRMI_common_init(int high_page);