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

Comparing BasiliskII/src/uae_cpu/memory.cpp (file contents):
Revision 1.2 by cebix, 1999-11-03T10:56:43Z vs.
Revision 1.9 by gbeauche, 2007-06-13T15:57:45Z

# Line 12 | Line 12
12   #include "sysdeps.h"
13  
14   #include "cpu_emulation.h"
15 + #include "main.h"
16 + #include "video.h"
17 +
18   #include "m68k.h"
19   #include "memory.h"
20   #include "readcpu.h"
21   #include "newcpu.h"
22 < #include "main.h"
23 < #include "video.h"
22 >
23 > #if !REAL_ADDRESSING && !DIRECT_ADDRESSING
24  
25   static bool illegal_mem = false;
26  
# Line 27 | Line 30 | addrbank *mem_banks[65536];
30   addrbank mem_banks[65536];
31   #endif
32  
33 + #ifdef WORDS_BIGENDIAN
34 + # define swap_words(X) (X)
35 + #else
36 + # define swap_words(X) (((X) >> 16) | ((X) << 16))
37 + #endif
38 +
39   #ifdef NO_INLINE_MEMORY_ACCESS
40 < __inline__ uae_u32 longget (uaecptr addr)
40 > uae_u32 longget (uaecptr addr)
41   {
42      return call_mem_get_func (get_mem_bank (addr).lget, addr);
43   }
44 < __inline__ uae_u32 wordget (uaecptr addr)
44 > uae_u32 wordget (uaecptr addr)
45   {
46      return call_mem_get_func (get_mem_bank (addr).wget, addr);
47   }
48 < __inline__ uae_u32 byteget (uaecptr addr)
48 > uae_u32 byteget (uaecptr addr)
49   {
50      return call_mem_get_func (get_mem_bank (addr).bget, addr);
51   }
52 < __inline__ void longput (uaecptr addr, uae_u32 l)
52 > void longput (uaecptr addr, uae_u32 l)
53   {
54      call_mem_put_func (get_mem_bank (addr).lput, addr, l);
55   }
56 < __inline__ void wordput (uaecptr addr, uae_u32 w)
56 > void wordput (uaecptr addr, uae_u32 w)
57   {
58      call_mem_put_func (get_mem_bank (addr).wput, addr, w);
59   }
60 < __inline__ void byteput (uaecptr addr, uae_u32 b)
60 > void byteput (uaecptr addr, uae_u32 b)
61   {
62      call_mem_put_func (get_mem_bank (addr).bput, addr, b);
63   }
# Line 62 | Line 71 | static uae_u32 REGPARAM2 dummy_bget (uae
71   static void REGPARAM2 dummy_lput (uaecptr, uae_u32) REGPARAM;
72   static void REGPARAM2 dummy_wput (uaecptr, uae_u32) REGPARAM;
73   static void REGPARAM2 dummy_bput (uaecptr, uae_u32) REGPARAM;
65 static int REGPARAM2 dummy_check (uaecptr addr, uae_u32 size) REGPARAM;
74  
75   uae_u32 REGPARAM2 dummy_lget (uaecptr addr)
76   {
# Line 104 | Line 112 | void REGPARAM2 dummy_bput (uaecptr addr,
112          write_log ("Illegal bput at %08lx\n", addr);
113   }
114  
107 int REGPARAM2 dummy_check (uaecptr addr, uae_u32 size)
108 {
109    if (illegal_mem)
110        write_log ("Illegal check at %08lx\n", addr);
111
112    return 0;
113 }
114
115   /* Mac RAM (32 bit addressing) */
116  
117   static uae_u32 REGPARAM2 ram_lget(uaecptr) REGPARAM;
# Line 120 | Line 120 | static uae_u32 REGPARAM2 ram_bget(uaecpt
120   static void REGPARAM2 ram_lput(uaecptr, uae_u32) REGPARAM;
121   static void REGPARAM2 ram_wput(uaecptr, uae_u32) REGPARAM;
122   static void REGPARAM2 ram_bput(uaecptr, uae_u32) REGPARAM;
123 static int REGPARAM2 ram_check(uaecptr addr, uae_u32 size) REGPARAM;
123   static uae_u8 *REGPARAM2 ram_xlate(uaecptr addr) REGPARAM;
124  
125 < static uae_u32 RAMBaseDiff;     // RAMBaseHost - RAMBaseMac
125 > static uintptr RAMBaseDiff;     // RAMBaseHost - RAMBaseMac
126  
127   uae_u32 REGPARAM2 ram_lget(uaecptr addr)
128   {
# Line 163 | Line 162 | void REGPARAM2 ram_bput(uaecptr addr, ua
162          *(uae_u8 *)(RAMBaseDiff + addr) = b;
163   }
164  
166 int REGPARAM2 ram_check(uaecptr addr, uae_u32 size)
167 {
168    return (addr - RAMBaseMac + size) < RAMSize;
169 }
170
165   uae_u8 *REGPARAM2 ram_xlate(uaecptr addr)
166   {
167      return (uae_u8 *)(RAMBaseDiff + addr);
# Line 181 | Line 175 | static uae_u32 REGPARAM2 ram24_bget(uaec
175   static void REGPARAM2 ram24_lput(uaecptr, uae_u32) REGPARAM;
176   static void REGPARAM2 ram24_wput(uaecptr, uae_u32) REGPARAM;
177   static void REGPARAM2 ram24_bput(uaecptr, uae_u32) REGPARAM;
184 static int REGPARAM2 ram24_check(uaecptr addr, uae_u32 size) REGPARAM;
178   static uae_u8 *REGPARAM2 ram24_xlate(uaecptr addr) REGPARAM;
179  
180   uae_u32 REGPARAM2 ram24_lget(uaecptr addr)
# Line 222 | Line 215 | void REGPARAM2 ram24_bput(uaecptr addr,
215          *(uae_u8 *)(RAMBaseDiff + (addr & 0xffffff)) = b;
216   }
217  
225 int REGPARAM2 ram24_check(uaecptr addr, uae_u32 size)
226 {
227    return ((addr & 0xffffff) - RAMBaseMac + size) < RAMSize;
228 }
229
218   uae_u8 *REGPARAM2 ram24_xlate(uaecptr addr)
219   {
220      return (uae_u8 *)(RAMBaseDiff + (addr & 0xffffff));
# Line 240 | Line 228 | static uae_u32 REGPARAM2 rom_bget(uaecpt
228   static void REGPARAM2 rom_lput(uaecptr, uae_u32) REGPARAM;
229   static void REGPARAM2 rom_wput(uaecptr, uae_u32) REGPARAM;
230   static void REGPARAM2 rom_bput(uaecptr, uae_u32) REGPARAM;
243 static int REGPARAM2 rom_check(uaecptr addr, uae_u32 size) REGPARAM;
231   static uae_u8 *REGPARAM2 rom_xlate(uaecptr addr) REGPARAM;
232  
233 < static uae_u32 ROMBaseDiff;     // ROMBaseHost - ROMBaseMac
233 > static uintptr ROMBaseDiff;     // ROMBaseHost - ROMBaseMac
234  
235   uae_u32 REGPARAM2 rom_lget(uaecptr addr)
236   {
# Line 282 | Line 269 | void REGPARAM2 rom_bput(uaecptr addr, ua
269          write_log ("Illegal ROM bput at %08lx\n", addr);
270   }
271  
285 int REGPARAM2 rom_check(uaecptr addr, uae_u32 size)
286 {
287    return (addr - ROMBaseMac + size) < ROMSize;
288 }
289
272   uae_u8 *REGPARAM2 rom_xlate(uaecptr addr)
273   {
274      return (uae_u8 *)(ROMBaseDiff + addr);
# Line 297 | Line 279 | uae_u8 *REGPARAM2 rom_xlate(uaecptr addr
279   static uae_u32 REGPARAM2 rom24_lget(uaecptr) REGPARAM;
280   static uae_u32 REGPARAM2 rom24_wget(uaecptr) REGPARAM;
281   static uae_u32 REGPARAM2 rom24_bget(uaecptr) REGPARAM;
300 static int REGPARAM2 rom24_check(uaecptr addr, uae_u32 size) REGPARAM;
282   static uae_u8 *REGPARAM2 rom24_xlate(uaecptr addr) REGPARAM;
283  
284   uae_u32 REGPARAM2 rom24_lget(uaecptr addr)
# Line 319 | Line 300 | uae_u32 REGPARAM2 rom24_bget(uaecptr add
300      return (uae_u32)*(uae_u8 *)(ROMBaseDiff + (addr & 0xffffff));
301   }
302  
322 int REGPARAM2 rom24_check(uaecptr addr, uae_u32 size)
323 {
324    return ((addr & 0xffffff) - ROMBaseMac + size) < ROMSize;
325 }
326
303   uae_u8 *REGPARAM2 rom24_xlate(uaecptr addr)
304   {
305      return (uae_u8 *)(ROMBaseDiff + (addr & 0xffffff));
# Line 351 | Line 327 | static void REGPARAM2 frame_host_565_wpu
327   static uae_u32 REGPARAM2 frame_host_888_lget(uaecptr) REGPARAM;
328   static void REGPARAM2 frame_host_888_lput(uaecptr, uae_u32) REGPARAM;
329  
354 static int REGPARAM2 frame_check(uaecptr addr, uae_u32 size) REGPARAM;
330   static uae_u8 *REGPARAM2 frame_xlate(uaecptr addr) REGPARAM;
331  
332 < static uae_u32 FrameBaseDiff;   // MacFrameBaseHost - MacFrameBaseMac
332 > static uintptr FrameBaseDiff;   // MacFrameBaseHost - MacFrameBaseMac
333  
334   uae_u32 REGPARAM2 frame_direct_lget(uaecptr addr)
335   {
# Line 399 | Line 374 | uae_u32 REGPARAM2 frame_host_555_lget(ua
374      uae_u32 *m, l;
375      m = (uae_u32 *)(FrameBaseDiff + addr);
376      l = *m;
377 <    return (l >> 16) | (l << 16);
377 >        return swap_words(l);
378   }
379  
380   uae_u32 REGPARAM2 frame_host_555_wget(uaecptr addr)
# Line 413 | Line 388 | void REGPARAM2 frame_host_555_lput(uaecp
388   {
389      uae_u32 *m;
390      m = (uae_u32 *)(FrameBaseDiff + addr);
391 <    *m = (l >> 16) | (l << 16);
391 >    *m = swap_words(l);
392   }
393  
394   void REGPARAM2 frame_host_555_wput(uaecptr addr, uae_u32 w)
# Line 429 | Line 404 | uae_u32 REGPARAM2 frame_host_565_lget(ua
404      m = (uae_u32 *)(FrameBaseDiff + addr);
405      l = *m;
406      l = (l & 0x001f001f) | ((l >> 1) & 0x7fe07fe0);
407 <    return (l >> 16) | (l << 16);
407 >    return swap_words(l);
408   }
409  
410   uae_u32 REGPARAM2 frame_host_565_wget(uaecptr addr)
# Line 445 | Line 420 | void REGPARAM2 frame_host_565_lput(uaecp
420      uae_u32 *m;
421      m = (uae_u32 *)(FrameBaseDiff + addr);
422      l = (l & 0x001f001f) | ((l << 1) & 0xffc0ffc0);
423 <    *m = (l >> 16) | (l << 16);
423 >    *m = swap_words(l);
424   }
425  
426   void REGPARAM2 frame_host_565_wput(uaecptr addr, uae_u32 w)
# Line 469 | Line 444 | void REGPARAM2 frame_host_888_lput(uaecp
444      *m = l;
445   }
446  
472 int REGPARAM2 frame_check(uaecptr addr, uae_u32 size)
473 {
474    return (addr - MacFrameBaseMac + size) < MacFrameSize;
475 }
476
447   uae_u8 *REGPARAM2 frame_xlate(uaecptr addr)
448   {
449      return (uae_u8 *)(FrameBaseDiff + addr);
# Line 481 | Line 451 | uae_u8 *REGPARAM2 frame_xlate(uaecptr ad
451  
452   /* Default memory access functions */
453  
484 int REGPARAM2 default_check (uaecptr a, uae_u32 b)
485 {
486    return 0;
487 }
488
454   uae_u8 *REGPARAM2 default_xlate (uaecptr a)
455   {
456      write_log("Your Mac program just did something terribly stupid\n");
# Line 497 | Line 462 | uae_u8 *REGPARAM2 default_xlate (uaecptr
462   addrbank dummy_bank = {
463      dummy_lget, dummy_wget, dummy_bget,
464      dummy_lput, dummy_wput, dummy_bput,
465 <    default_xlate, dummy_check
465 >    default_xlate
466   };
467  
468   addrbank ram_bank = {
469      ram_lget, ram_wget, ram_bget,
470      ram_lput, ram_wput, ram_bput,
471 <    ram_xlate, ram_check
471 >    ram_xlate
472   };
473  
474   addrbank ram24_bank = {
475      ram24_lget, ram24_wget, ram24_bget,
476      ram24_lput, ram24_wput, ram24_bput,
477 <    ram24_xlate, ram24_check
477 >    ram24_xlate
478   };
479  
480   addrbank rom_bank = {
481      rom_lget, rom_wget, rom_bget,
482      rom_lput, rom_wput, rom_bput,
483 <    rom_xlate, rom_check
483 >    rom_xlate
484   };
485  
486   addrbank rom24_bank = {
487      rom24_lget, rom24_wget, rom24_bget,
488      rom_lput, rom_wput, rom_bput,
489 <    rom24_xlate, rom24_check
489 >    rom24_xlate
490   };
491  
492   addrbank frame_direct_bank = {
493      frame_direct_lget, frame_direct_wget, frame_direct_bget,
494      frame_direct_lput, frame_direct_wput, frame_direct_bput,
495 <    frame_xlate, frame_check
495 >    frame_xlate
496   };
497  
498   addrbank frame_host_555_bank = {
499      frame_host_555_lget, frame_host_555_wget, frame_direct_bget,
500      frame_host_555_lput, frame_host_555_wput, frame_direct_bput,
501 <    frame_xlate, frame_check
501 >    frame_xlate
502   };
503  
504   addrbank frame_host_565_bank = {
505      frame_host_565_lget, frame_host_565_wget, frame_direct_bget,
506      frame_host_565_lput, frame_host_565_wput, frame_direct_bput,
507 <    frame_xlate, frame_check
507 >    frame_xlate
508   };
509  
510   addrbank frame_host_888_bank = {
511      frame_host_888_lget, frame_direct_wget, frame_direct_bget,
512      frame_host_888_lput, frame_direct_wput, frame_direct_bput,
513 <    frame_xlate, frame_check
513 >    frame_xlate
514   };
515  
516   void memory_init(void)
517   {
518 <        char buffer[4096];
554 <        char *nam;
555 <        int i, fd;
556 <
557 <        for(i=0; i<65536; i++)
518 >        for(long i=0; i<65536; i++)
519                  put_mem_bank(i<<16, &dummy_bank);
520  
521          // Limit RAM size to not overlap ROM
561 #if REAL_ADDRESSING
562        uint32 ram_size = RAMSize;
563 #else
522          uint32 ram_size = RAMSize > ROMBaseMac ? ROMBaseMac : RAMSize;
565 #endif
523  
524 <        RAMBaseDiff = (uae_u32)RAMBaseHost - (uae_u32)RAMBaseMac;
525 <        ROMBaseDiff = (uae_u32)ROMBaseHost - (uae_u32)ROMBaseMac;
526 <        FrameBaseDiff = (uae_u32)MacFrameBaseHost - (uae_u32)MacFrameBaseMac;
524 >        RAMBaseDiff = (uintptr)RAMBaseHost - (uintptr)RAMBaseMac;
525 >        ROMBaseDiff = (uintptr)ROMBaseHost - (uintptr)ROMBaseMac;
526 >        FrameBaseDiff = (uintptr)MacFrameBaseHost - (uintptr)MacFrameBaseMac;
527  
528          // Map RAM and ROM
529          if (TwentyFourBitAddressing) {
# Line 609 | Line 566 | void map_banks(addrbank *bank, int start
566          for (bnr = start; bnr < start+size; bnr++)
567              put_mem_bank((bnr + hioffs) << 16, bank);
568   }
569 +
570 + #endif /* !REAL_ADDRESSING && !DIRECT_ADDRESSING */
571 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines