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

Comparing SheepShaver/src/Unix/main_unix.cpp (file contents):
Revision 1.46 by gbeauche, 2004-07-01T22:55:02Z vs.
Revision 1.47 by gbeauche, 2004-07-03T10:39:06Z

# Line 127 | Line 127
127   #include "debug.h"
128  
129  
130 + #ifdef HAVE_DIRENT_H
131 + #include <dirent.h>
132 + #endif
133 +
134   #ifdef USE_SDL
135   #include <SDL.h>
136   #endif
# Line 275 | Line 279 | uint32 DRCacheAddr;            // Address of DR Ca
279   uint32 PVR;                             // Theoretical PVR
280   int64 CPUClockSpeed;    // Processor clock speed (Hz)
281   int64 BusClockSpeed;    // Bus clock speed (Hz)
282 + int64 TimebaseSpeed;    // Timebase clock speed (Hz)
283  
284  
285   // Global variables
# Line 566 | Line 571 | int main(int argc, char **argv)
571          PVR = 0x00040000;                       // Default: 604
572          CPUClockSpeed = 100000000;      // Default: 100MHz
573          BusClockSpeed = 100000000;      // Default: 100MHz
574 +        TimebaseSpeed =  25000000;      // Default:  25MHz
575   #if EMULATED_PPC
576          PVR = 0x000c0000;                       // Default: 7400 (with AltiVec)
577   #elif defined(__APPLE__) && defined(__MACH__)
# Line 670 | Line 676 | int main(int argc, char **argv)
676                          BusClockSpeed = value.l;
677                  fclose(proc_file);
678          }
679 +
680 +        // Get actual timebase frequency
681 +        TimebaseSpeed = BusClockSpeed / 4;
682 +        DIR *cpus_dir;
683 +        if ((cpus_dir = opendir("/proc/device-tree/cpus")) != NULL) {
684 +                struct dirent *cpu_entry;
685 +                while ((cpu_entry = readdir(cpus_dir)) != NULL) {
686 +                        if (strstr(cpu_entry->d_name, "PowerPC,") == cpu_entry->d_name) {
687 +                                char timebase_freq_node[256];
688 +                                sprintf(timebase_freq_node, "/proc/device-tree/cpus/%s/timebase-frequency", cpu_entry->d_name);
689 +                                proc_file = fopen(timebase_freq_node, "r");
690 +                                if (proc_file) {
691 +                                        union { uint8 b[4]; uint32 l; } value;
692 +                                        if (fread(value.b, sizeof(value), 1, proc_file) == 1)
693 +                                                TimebaseSpeed = value.l;
694 +                                        fclose(proc_file);
695 +                                }
696 +                        }
697 +                }
698 +                closedir(cpus_dir);
699 +        }
700   #endif
701          D(bug("PVR: %08x (assumed)\n", PVR));
702  
# Line 954 | Line 981 | int main(int argc, char **argv)
981                  kernel_data->v[0xf60 >> 2] = htonl(PVR);
982                  kernel_data->v[0xf64 >> 2] = htonl(CPUClockSpeed);                      // clock-frequency
983                  kernel_data->v[0xf68 >> 2] = htonl(BusClockSpeed);                      // bus-frequency
984 <                kernel_data->v[0xf6c >> 2] = htonl(BusClockSpeed / 4);          // timebase-frequency
984 >                kernel_data->v[0xf6c >> 2] = htonl(TimebaseSpeed);                      // timebase-frequency
985          } else {
986                  kernel_data->v[0xc80 >> 2] = htonl(RAMSize);
987                  kernel_data->v[0xc84 >> 2] = htonl(RAMSize);
# Line 968 | Line 995 | int main(int argc, char **argv)
995                  kernel_data->v[0xf80 >> 2] = htonl(PVR);
996                  kernel_data->v[0xf84 >> 2] = htonl(CPUClockSpeed);                      // clock-frequency
997                  kernel_data->v[0xf88 >> 2] = htonl(BusClockSpeed);                      // bus-frequency
998 <                kernel_data->v[0xf8c >> 2] = htonl(BusClockSpeed / 4);          // timebase-frequency
998 >                kernel_data->v[0xf8c >> 2] = htonl(TimebaseSpeed);                      // timebase-frequency
999          }
1000  
1001          // Initialize extra low memory

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines