1 |
|
/* |
2 |
|
* name_registry.cpp - Name Registry handling |
3 |
|
* |
4 |
< |
* SheepShaver (C) 1997-2004 Christian Bauer and Marc Hellwig |
4 |
> |
* SheepShaver (C) Christian Bauer and Marc Hellwig |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
37 |
|
static uint32 rcec_tvect = 0; |
38 |
|
static inline int16 RegistryCStrEntryCreate(uintptr arg1, const char *arg2, uint32 arg3) |
39 |
|
{ |
40 |
< |
return (int16)CallMacOS3(rcec_ptr, rcec_tvect, (const RegEntryID *)arg1, Host2MacAddr((uint8 *)arg2), arg3); |
40 |
> |
SheepString arg2str(arg2); |
41 |
> |
return (int16)CallMacOS3(rcec_ptr, rcec_tvect, (const RegEntryID *)arg1, arg2str.addr(), arg3); |
42 |
|
} |
43 |
|
typedef int16 (*rpc_ptr)(const RegEntryID *, const char *, const void *, uint32); |
44 |
|
static uint32 rpc_tvect = 0; |
45 |
|
static inline int16 RegistryPropertyCreate(uintptr arg1, const char *arg2, uintptr arg3, uint32 arg4) |
46 |
|
{ |
47 |
< |
return (int16)CallMacOS4(rpc_ptr, rpc_tvect, (const RegEntryID *)arg1, Host2MacAddr((uint8 *)arg2), (const void *)arg3, arg4); |
47 |
> |
SheepString arg2str(arg2); |
48 |
> |
return (int16)CallMacOS4(rpc_ptr, rpc_tvect, (const RegEntryID *)arg1, arg2str.addr(), (const void *)arg3, arg4); |
49 |
> |
} |
50 |
> |
static inline int16 RegistryPropertyCreateStr(uintptr arg1, const char *arg2, const char *arg3) |
51 |
> |
{ |
52 |
> |
SheepString arg3str(arg3); |
53 |
> |
return RegistryPropertyCreate(arg1, arg2, arg3str.addr(), strlen(arg3) + 1); |
54 |
|
} |
48 |
– |
#define RegistryPropertyCreateStr(e,n,s) RegistryPropertyCreate(e,n,Host2MacAddr((uint8 *)s),strlen(s)+1) |
55 |
|
|
56 |
|
// Video driver stub |
57 |
|
static const uint8 video_driver[] = { |
60 |
|
|
61 |
|
// Ethernet driver stub |
62 |
|
static const uint8 ethernet_driver[] = { |
63 |
+ |
#ifdef USE_ETHER_FULL_DRIVER |
64 |
+ |
#include "EthernetDriverFull.i" |
65 |
+ |
#else |
66 |
|
#include "EthernetDriverStub.i" |
67 |
+ |
#endif |
68 |
|
}; |
69 |
|
|
70 |
|
// Helper for RegEntryID |
97 |
|
SheepRegEntryID aapl_rom; |
98 |
|
if (!RegistryCStrEntryCreate(device_tree.addr(), "AAPL,ROM", aapl_rom.addr())) { |
99 |
|
RegistryPropertyCreateStr(aapl_rom.addr(), "device_type", "rom"); |
100 |
< |
SheepPair reg(ROM_BASE, ROM_SIZE); |
100 |
> |
SheepPair reg(ROMBase, ROM_SIZE); |
101 |
|
RegistryPropertyCreate(aapl_rom.addr(), "reg", reg.addr(), 8); |
102 |
|
} |
103 |
|
|
104 |
|
// Create "PowerPC,60x" |
105 |
|
SheepRegEntryID power_pc; |
106 |
< |
char *str; |
106 |
> |
const char *str; |
107 |
|
switch (PVR >> 16) { |
108 |
|
case 1: // 601 |
109 |
|
str = "PowerPC,601"; |
135 |
|
case 80: // 860 |
136 |
|
str = "PowerPC,860"; |
137 |
|
break; |
138 |
+ |
case 12: // 7400, 7410, 7450, 7455, 7457 |
139 |
+ |
case 0x800c: |
140 |
+ |
case 0x8000: |
141 |
+ |
case 0x8001: |
142 |
+ |
case 0x8002: |
143 |
+ |
str = "PowerPC,G4"; |
144 |
+ |
break; |
145 |
|
default: |
146 |
|
str = "PowerPC,???"; |
147 |
|
break; |
330 |
|
if (!RegistryCStrEntryCreate(device_tree.addr(), "video", video.addr())) { |
331 |
|
RegistryPropertyCreateStr(video.addr(), "AAPL,connector", "monitor"); |
332 |
|
RegistryPropertyCreateStr(video.addr(), "device_type", "display"); |
333 |
< |
RegistryPropertyCreate(video.addr(), "driver,AAPL,MacOS,PowerPC", Host2MacAddr((uint8 *)video_driver), sizeof(video_driver)); |
333 |
> |
SheepArray<sizeof(video_driver)> the_video_driver; |
334 |
> |
Host2Mac_memcpy(the_video_driver.addr(), video_driver, sizeof(video_driver)); |
335 |
> |
RegistryPropertyCreate(video.addr(), "driver,AAPL,MacOS,PowerPC", the_video_driver.addr(), sizeof(video_driver)); |
336 |
|
RegistryPropertyCreateStr(video.addr(), "model", "SheepShaver Video"); |
337 |
|
} |
338 |
|
|
341 |
|
if (!RegistryCStrEntryCreate(device_tree.addr(), "ethernet", ethernet.addr())) { |
342 |
|
RegistryPropertyCreateStr(ethernet.addr(), "AAPL,connector", "ethernet"); |
343 |
|
RegistryPropertyCreateStr(ethernet.addr(), "device_type", "network"); |
344 |
< |
RegistryPropertyCreate(ethernet.addr(), "driver,AAPL,MacOS,PowerPC", Host2MacAddr((uint8 *)ethernet_driver), sizeof(ethernet_driver)); |
344 |
> |
SheepArray<sizeof(ethernet_driver)> the_ethernet_driver; |
345 |
> |
Host2Mac_memcpy(the_ethernet_driver.addr(), ethernet_driver, sizeof(ethernet_driver)); |
346 |
> |
RegistryPropertyCreate(ethernet.addr(), "driver,AAPL,MacOS,PowerPC", the_ethernet_driver.addr(), sizeof(ethernet_driver)); |
347 |
|
// local-mac-address |
348 |
|
// max-frame-size 2048 |
349 |
|
} |
354 |
|
void PatchNameRegistry(void) |
355 |
|
{ |
356 |
|
// Find RegistryCStrEntryCreate() and RegistryPropertyCreate() TVECTs |
357 |
< |
rcec_tvect = (uint32)FindLibSymbol("\017NameRegistryLib", "\027RegistryCStrEntryCreate"); |
357 |
> |
rcec_tvect = FindLibSymbol("\017NameRegistryLib", "\027RegistryCStrEntryCreate"); |
358 |
|
D(bug("RegistryCStrEntryCreate TVECT at %08x\n", rcec_tvect)); |
359 |
< |
rpc_tvect = (uint32)FindLibSymbol("\017NameRegistryLib", "\026RegistryPropertyCreate"); |
359 |
> |
rpc_tvect = FindLibSymbol("\017NameRegistryLib", "\026RegistryPropertyCreate"); |
360 |
|
D(bug("RegistryPropertyCreate TVECT at %08x\n", rpc_tvect)); |
361 |
|
if (rcec_tvect == 0 || rpc_tvect == 0) { |
362 |
|
ErrorAlert(GetString(STR_NO_NAME_REGISTRY_ERR)); |