ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/macos_util.cpp
(Generate patch)

Comparing SheepShaver/src/macos_util.cpp (file contents):
Revision 1.1.1.1 by cebix, 2002-02-04T16:58:13Z vs.
Revision 1.5 by gbeauche, 2004-01-10T08:46:56Z

# Line 27 | Line 27
27   #include "xlowmem.h"
28   #include "emul_op.h"
29   #include "macos_util.h"
30 + #include "thunks.h"
31  
32   #define DEBUG 0
33   #include "debug.h"
# Line 150 | Line 151 | void FileDiskLayout(loff_t size, uint8 *
151   *  lib and sym must be Pascal strings!
152   */
153  
154 < void *FindLibSymbol(char *lib, char *sym)
154 > void *FindLibSymbol(char *lib_str, char *sym_str)
155   {
156 <        uint32 conn_id = 0;
157 <        void *main_addr = NULL;
158 <        char err[256] = "";
159 <        uint32 *sym_addr = NULL;
160 <        uint32 sym_class = 0;
156 >        SheepVar32 conn_id = 0;
157 >        SheepVar32 main_addr = 0;
158 >        SheepArray<256> err;
159 >        WriteMacInt8(err.addr(), 0);
160 >        SheepVar32 sym_addr = 0;
161 >        SheepVar32 sym_class = 0;
162  
163 <        D(bug("FindLibSymbol %s in %s...\n", sym+1, lib+1));
163 >        SheepString lib(lib_str);
164 >        SheepString sym(sym_str);
165  
166 <        if (*(uint32 *)XLM_RUN_MODE == MODE_EMUL_OP) {
166 >        D(bug("FindLibSymbol %s in %s...\n", sym.value()+1, lib.value()+1));
167 >
168 >        if (ReadMacInt32(XLM_RUN_MODE) == MODE_EMUL_OP) {
169                  M68kRegisters r;
170          
171                  // Find shared library
172                  static const uint16 proc1[] = {
173 <                        0x558f,                                 // subq.l       #2,a7
174 <                        0x2f08,                                 // move.l       a0,-(a7)
175 <                        0x2f3c, 0x7077, 0x7063, // move.l       #'pwpc',-(a7)
176 <                        0x2f3c, 0, 1,                   // move.l       #kReferenceCFrag,-(a7)
177 <                        0x2f09,                                 // move.l       a1,-(a7)
178 <                        0x2f0a,                                 // move.l       a2,-(a7)
179 <                        0x2f0b,                                 // move.l       a3,-(a7)
180 <                        0x3f3c, 1,                              // (GetSharedLibrary)
181 <                        0xaa5a,                                 // CFMDispatch
182 <                        0x301f,                                 // move.w       (a7)+,d0
183 <                        M68K_RTS
173 >                        PW(0x558f),                                                     // subq.l       #2,a7
174 >                        PW(0x2f08),                                                     // move.l       a0,-(a7)
175 >                        PW(0x2f3c), PW(0x7077), PW(0x7063),     // move.l       #'pwpc',-(a7)
176 >                        PW(0x2f3c), PW(0x0000), PW(0x0001),     // move.l       #kReferenceCFrag,-(a7)
177 >                        PW(0x2f09),                                                     // move.l       a1,-(a7)
178 >                        PW(0x2f0a),                                                     // move.l       a2,-(a7)
179 >                        PW(0x2f0b),                                                     // move.l       a3,-(a7)
180 >                        PW(0x3f3c), PW(0x0001),                         // (GetSharedLibrary)
181 >                        PW(0xaa5a),                                                     // CFMDispatch
182 >                        PW(0x301f),                                                     // move.w       (a7)+,d0
183 >                        PW(M68K_RTS)
184                  };
185 <                r.a[0] = (uint32)lib;
186 <                r.a[1] = (uint32)&conn_id;
187 <                r.a[2] = (uint32)&main_addr;
188 <                r.a[3] = (uint32)err;
185 >                r.a[0] = lib.addr();
186 >                r.a[1] = conn_id.addr();
187 >                r.a[2] = main_addr.addr();
188 >                r.a[3] = err.addr();
189                  Execute68k((uint32)proc1, &r);
190 <                D(bug(" GetSharedLibrary: ret %d, connection ID %ld, main %p\n", (int16)r.d[0], conn_id, main_addr));
190 >                D(bug(" GetSharedLibrary: ret %d, connection ID %ld, main %p\n", (int16)r.d[0], conn_id.value(), main_addr.value()));
191                  if (r.d[0])
192                          return NULL;
193          
194                  // Find symbol
195                  static const uint16 proc2[] = {
196 <                        0x558f,                 // subq.l       #2,a7
197 <                        0x2f00,                 // move.l       d0,-(a7)
198 <                        0x2f08,                 // move.l       a0,-(a7)
199 <                        0x2f09,                 // move.l       a1,-(a7)
200 <                        0x2f0a,                 // move.l       a2,-(a7)
201 <                        0x3f3c, 5,              // (FindSymbol)
202 <                        0xaa5a,                 // CFMDispatch
203 <                        0x301f,                 // move.w       (a7)+,d0
204 <                        M68K_RTS
196 >                        PW(0x558f),                                     // subq.l       #2,a7
197 >                        PW(0x2f00),                                     // move.l       d0,-(a7)
198 >                        PW(0x2f08),                                     // move.l       a0,-(a7)
199 >                        PW(0x2f09),                                     // move.l       a1,-(a7)
200 >                        PW(0x2f0a),                                     // move.l       a2,-(a7)
201 >                        PW(0x3f3c), PW(0x0005),         // (FindSymbol)
202 >                        PW(0xaa5a),                                     // CFMDispatch
203 >                        PW(0x301f),                                     // move.w       (a7)+,d0
204 >                        PW(M68K_RTS)
205                  };
206 <                r.d[0] = conn_id;
207 <                r.a[0] = (uint32)sym;
208 <                r.a[1] = (uint32)&sym_addr;
209 <                r.a[2] = (uint32)&sym_class;
206 >                r.d[0] = conn_id.value();
207 >                r.a[0] = sym.addr();
208 >                r.a[1] = sym_addr.addr();
209 >                r.a[2] = sym_class.addr();
210                  Execute68k((uint32)proc2, &r);
211 <                D(bug(" FindSymbol: ret %d, sym_addr %p, sym_class %ld\n", (int16)r.d[0], sym_addr, sym_class));
211 >                D(bug(" FindSymbol1: ret %d, sym_addr %p, sym_class %ld\n", (int16)r.d[0], sym_addr.value(), sym_class.value()));
212   //!! CloseConnection()?
213                  if (r.d[0])
214                          return NULL;
215                  else
216 <                        return sym_addr;
216 >                        return (void *)sym_addr.value();
217  
218          } else {
219  
# Line 217 | Line 222 | void *FindLibSymbol(char *lib, char *sym
222                          return 0;
223                  }
224                  int16 res;
225 <                res = GetSharedLibrary(lib, FOURCC('p','w','p','c'), 1, &conn_id, &main_addr, err);
226 <                D(bug(" GetSharedLibrary: ret %d, connection ID %ld, main %p\n", res, conn_id, main_addr));
225 >                res = GetSharedLibrary(lib.value(), FOURCC('p','w','p','c'), 1, (uint32 *)conn_id.addr(), (void **)main_addr.addr(), (char *)err.addr());
226 >                D(bug(" GetSharedLibrary: ret %d, connection ID %ld, main %p\n", res, conn_id.value(), main_addr.value()));
227                  if (res)
228                          return NULL;
229 <                res = FindSymbol(conn_id, sym, (void **)&sym_addr, &sym_class);
230 <                D(bug(" FindSymbol: ret %d, sym_addr %p, sym_class %ld\n", res, sym_addr, sym_class));
229 >                res = FindSymbol(conn_id.value(), sym.value(), (void **)sym_addr.addr(), (uint32 *)sym_class.addr());
230 >                D(bug(" FindSymbol: ret %d, sym_addr %p, sym_class %ld\n", res, sym_addr.value(), sym_class.value()));
231   //!!??          CloseConnection(&conn_id);
232                  if (res)
233                          return NULL;
234                  else
235 <                        return sym_addr;
235 >                        return (void *)sym_addr.value();
236          }
237   }
238  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines