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

Comparing SheepShaver/src/BeOS/main_beos.cpp (file contents):
Revision 1.15 by gbeauche, 2004-11-22T21:22:58Z vs.
Revision 1.16 by gbeauche, 2005-01-30T21:19:07Z

# Line 74 | Line 74
74   #include "xpram.h"
75   #include "timer.h"
76   #include "adb.h"
77 #include "sony.h"
78 #include "disk.h"
79 #include "cdrom.h"
80 #include "scsi.h"
77   #include "video.h"
82 #include "audio.h"
83 #include "ether.h"
84 #include "serial.h"
85 #include "clip.h"
86 #include "extfs.h"
78   #include "sys.h"
79   #include "macos_util.h"
80   #include "rom_patches.h"
81   #include "user_strings.h"
91 #include "thunks.h"
82  
83   #include "sheep_driver.h"
84  
# Line 371 | Line 361 | void SheepShaver::MessageReceived(BMessa
361   void SheepShaver::StartEmulator(void)
362   {
363          char str[256];
374        int16 i16;
364  
365          // Open sheep driver and remap low memory
366          sheep_fd = open("/dev/sheep", 0);
# Line 481 | Line 470 | void SheepShaver::StartEmulator(void)
470          }
471          D(bug("DR Emulator area %ld at %p\n", dr_emulator_area, DREmulatorAddr));
472  
473 <        // Load NVRAM
474 <        XPRAMInit();
486 <
487 <        // Set boot volume
488 <        i16 = PrefsFindInt32("bootdrive");
489 <        XPRAM[0x1378] = i16 >> 8;
490 <        XPRAM[0x1379] = i16 & 0xff;
491 <        i16 = PrefsFindInt32("bootdriver");
492 <        XPRAM[0x137a] = i16 >> 8;
493 <        XPRAM[0x137b] = i16 & 0xff;
494 <
495 <        // Create BootGlobs at top of Mac memory
496 <        memset((void *)(RAMBase + RAMSize - 4096), 0, 4096);
497 <        BootGlobsAddr = RAMBase + RAMSize - 0x1c;
498 <        uint32 *boot_globs = (uint32 *)BootGlobsAddr;
499 <        boot_globs[-5] = htonl(RAMBase + RAMSize);              // MemTop
500 <        boot_globs[0] = htonl(RAMBase);                                 // First RAM bank
501 <        boot_globs[1] = htonl(RAMSize);
502 <        boot_globs[2] = htonl((uint32)-1);                              // End of bank table
503 <
504 <        // Init thunks
505 <        if (!InitThunks()) {
506 <                PostMessage(B_QUIT_REQUESTED);
507 <                return;
508 <        }
509 <
510 <        // Init drivers
511 <        SonyInit();
512 <        DiskInit();
513 <        CDROMInit();
514 <        SCSIInit();
515 <
516 <        // Init external file system
517 <        ExtFSInit();
518 <
519 <        // Init audio
520 <        AudioInit();
521 <
522 <        // Init network
523 <        EtherInit();
524 <
525 <        // Init serial ports
526 <        SerialInit();
527 <
528 <        // Init Time Manager
529 <        TimerInit();
530 <
531 <        // Init clipboard
532 <        ClipInit();
533 <
534 <        // Init video
535 <        if (!VideoInit()) {
536 <                PostMessage(B_QUIT_REQUESTED);
537 <                return;
538 <        }
539 <
540 <        // Install ROM patches
541 <        if (!PatchROM()) {
542 <                ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR));
473 >        // Initialize everything
474 >        if (!InitAll()) {
475                  PostMessage(B_QUIT_REQUESTED);
476                  return;
477          }
478 +        D(bug("Initialization complete\n"));
479  
480          // Clear caches (as we loaded and patched code) and write protect ROM
481   #if !EMULATED_PPC
# Line 550 | Line 483 | void SheepShaver::StartEmulator(void)
483   #endif
484          set_area_protection(rom_area, B_READ_AREA);
485  
553        // Initialize Kernel Data
554        memset(kernel_data, 0, sizeof(KernelData));
555        if (ROMType == ROMTYPE_NEWWORLD) {
556                static uint32 of_dev_tree[4] = {0, 0, 0, 0};
557                static uint8 vector_lookup_tbl[128];
558                static uint8 vector_mask_tbl[64];
559                memset((uint8 *)kernel_data + 0xb80, 0x3d, 0x80);
560                memset(vector_lookup_tbl, 0, 128);
561                memset(vector_mask_tbl, 0, 64);
562                kernel_data->v[0xb80 >> 2] = htonl(ROM_BASE);
563                kernel_data->v[0xb84 >> 2] = htonl((uint32)of_dev_tree);        // OF device tree base
564                kernel_data->v[0xb90 >> 2] = htonl((uint32)vector_lookup_tbl);
565                kernel_data->v[0xb94 >> 2] = htonl((uint32)vector_mask_tbl);
566                kernel_data->v[0xb98 >> 2] = htonl(ROM_BASE);                           // OpenPIC base
567                kernel_data->v[0xbb0 >> 2] = htonl(0);                                          // ADB base
568                kernel_data->v[0xc20 >> 2] = htonl(RAMSize);
569                kernel_data->v[0xc24 >> 2] = htonl(RAMSize);
570                kernel_data->v[0xc30 >> 2] = htonl(RAMSize);
571                kernel_data->v[0xc34 >> 2] = htonl(RAMSize);
572                kernel_data->v[0xc38 >> 2] = htonl(0x00010020);
573                kernel_data->v[0xc3c >> 2] = htonl(0x00200001);
574                kernel_data->v[0xc40 >> 2] = htonl(0x00010000);
575                kernel_data->v[0xc50 >> 2] = htonl(RAMBase);
576                kernel_data->v[0xc54 >> 2] = htonl(RAMSize);
577                kernel_data->v[0xf60 >> 2] = htonl(PVR);
578                kernel_data->v[0xf64 >> 2] = htonl(CPUClockSpeed);
579                kernel_data->v[0xf68 >> 2] = htonl(BusClockSpeed);
580                kernel_data->v[0xf6c >> 2] = htonl(CPUClockSpeed);
581        } else {
582                kernel_data->v[0xc80 >> 2] = htonl(RAMSize);
583                kernel_data->v[0xc84 >> 2] = htonl(RAMSize);
584                kernel_data->v[0xc90 >> 2] = htonl(RAMSize);
585                kernel_data->v[0xc94 >> 2] = htonl(RAMSize);
586                kernel_data->v[0xc98 >> 2] = htonl(0x00010020);
587                kernel_data->v[0xc9c >> 2] = htonl(0x00200001);
588                kernel_data->v[0xca0 >> 2] = htonl(0x00010000);
589                kernel_data->v[0xcb0 >> 2] = htonl(RAMBase);
590                kernel_data->v[0xcb4 >> 2] = htonl(RAMSize);
591                kernel_data->v[0xf80 >> 2] = htonl(PVR);
592                kernel_data->v[0xf84 >> 2] = htonl(CPUClockSpeed);
593                kernel_data->v[0xf88 >> 2] = htonl(BusClockSpeed);
594                kernel_data->v[0xf8c >> 2] = htonl(CPUClockSpeed);
595        }
596
486          // Initialize extra low memory
487 <        D(bug("Initializing Low Memory...\n"));
599 <        memset(NULL, 0, 0x3000);
600 <        WriteMacInt32(XLM_SIGNATURE, 'Baah');                                                   // Signature to detect SheepShaver
601 <        WriteMacInt32(XLM_KERNEL_DATA, (uint32)kernel_data);                    // For trap replacement routines
487 >        D(bug("Initializing extra Low Memory...\n"));
488          WriteMacInt32(XLM_SHEEP_OBJ, (uint32)this);                                             // Pointer to SheepShaver object
489 <        WriteMacInt32(XLM_PVR, PVR);                                                                    // Theoretical PVR
604 <        WriteMacInt32(XLM_BUS_CLOCK, BusClockSpeed);                                    // For DriverServicesLib patch
605 <        WriteMacInt16(XLM_EXEC_RETURN_OPCODE, M68K_EXEC_RETURN);                // For Execute68k() (RTS from the executed 68k code will jump here and end 68k mode)
606 <        WriteMacInt32(XLM_ZERO_PAGE, SheepMem::ZeroPage());                             // Pointer to read-only page with all bits set to 0
607 < #if !EMULATED_PPC
608 <        WriteMacInt32(XLM_TOC, (uint32)TOC);                                                    // TOC pointer of emulator
609 <        WriteMacInt32(XLM_ETHER_INIT, *(uint32 *)InitStreamModule);             // DLPI ethernet driver functions
610 <        WriteMacInt32(XLM_ETHER_TERM, *(uint32 *)TerminateStreamModule);
611 <        WriteMacInt32(XLM_ETHER_OPEN, *(uint32 *)ether_open);
612 <        WriteMacInt32(XLM_ETHER_CLOSE, *(uint32 *)ether_close);
613 <        WriteMacInt32(XLM_ETHER_WPUT, *(uint32 *)ether_wput);
614 <        WriteMacInt32(XLM_ETHER_RSRV, *(uint32 *)ether_rsrv);
615 <        WriteMacInt32(XLM_VIDEO_DOIO, *(uint32 *)VideoDoDriverIO);
616 < #endif
617 <        D(bug("Low Memory initialized\n"));
489 >        D(bug("Extra Low Memory initialized\n"));
490  
491          // Disallow quitting with Alt-Q from now on
492          AllowQuitting = false;
# Line 670 | Line 542 | void SheepShaver::Quit(void)
542          if (emul_thread > 0)
543                  wait_for_thread(emul_thread, &l);
544  
545 <        // Save NVRAM
546 <        XPRAMExit();
675 <
676 <        // Exit clipboard
677 <        ClipExit();
678 <
679 <        // Exit Time Manager
680 <        TimerExit();
681 <
682 <        // Exit serial
683 <        SerialExit();
684 <
685 <        // Exit network
686 <        EtherExit();
687 <
688 <        // Exit audio
689 <        AudioExit();
690 <
691 <        // Exit video
692 <        VideoExit();
693 <
694 <        // Exit external file system
695 <        ExtFSExit();
696 <
697 <        // Exit drivers
698 <        SCSIExit();
699 <        CDROMExit();
700 <        DiskExit();
701 <        SonyExit();
702 <
703 <        // Delete thunks
704 <        ThunksExit();
545 >        // Deinitialize everything
546 >        ExitAll();
547  
548          // Delete SheepShaver globals
549          SheepMem::Exit();
# Line 1349 | Line 1191 | void MakeExecutable(int dummy, uint32 st
1191   }
1192  
1193  
1352 /*
1353 *  Patch things after system startup (gets called by disk driver accRun routine)
1354 */
1355
1356 void PatchAfterStartup(void)
1357 {
1358        ExecuteNative(NATIVE_VIDEO_INSTALL_ACCEL);
1359        InstallExtFS();
1360 }
1361
1362
1194   /*
1195   *  NVRAM watchdog thread (saves NVRAM every minute)
1196   */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines