/[gxemul]/trunk/src/memory_rw.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/memory_rw.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 39 by dpavlin, Mon Oct 8 16:21:17 2007 UTC revision 40 by dpavlin, Mon Oct 8 16:22:11 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: memory_rw.c,v 1.101 2007/02/10 14:04:51 debug Exp $   *  $Id: memory_rw.c,v 1.102 2007/04/16 15:13:44 debug Exp $
29   *   *
30   *  Generic memory_rw(), with special hacks for specific CPU families.   *  Generic memory_rw(), with special hacks for specific CPU families.
31   *   *
# Line 373  not just the device in question. Line 373  not just the device in question.
373                      paddr & ~offset_mask);                      paddr & ~offset_mask);
374    
375          /*          /*
376           *  If writing, then invalidate code translations for the (physical)           *  If writing, or if mapping a page where writing is ok later on,
377           *  page address:           *  then invalidate code translations for the (physical) page address:
378           */           */
379          if (writeflag == MEM_WRITE && cpu->invalidate_code_translation != NULL)          if ((writeflag == MEM_WRITE
380    #if !defined(MEM_USERLAND)
381                || ok == 2
382    #endif
383                ) && cpu->invalidate_code_translation != NULL)
384                  cpu->invalidate_code_translation(cpu, paddr, INVALIDATE_PADDR);                  cpu->invalidate_code_translation(cpu, paddr, INVALIDATE_PADDR);
385    
386          if ((paddr&((1<<BITS_PER_MEMBLOCK)-1)) + len > (1<<BITS_PER_MEMBLOCK)) {          if ((paddr&((1<<BITS_PER_MEMBLOCK)-1)) + len > (1<<BITS_PER_MEMBLOCK)) {
# Line 384  not just the device in question. Line 388  not just the device in question.
388                  exit(1);                  exit(1);
389          }          }
390    
391          if (writeflag == MEM_WRITE) {          /*  And finally, read or write the data:  */
392                  /*  Ugly optimization, but it works:  */          if (writeflag == MEM_WRITE)
393                  if (len == sizeof(uint32_t) && (offset & 3)==0                  memcpy(memblock + offset, data, len);
394                      && ((size_t)data&3)==0)          else
395                          *(uint32_t *)(memblock + offset) = *(uint32_t *)data;                  memcpy(data, memblock + offset, len);
                 else if (len == sizeof(uint8_t))  
                         *(uint8_t *)(memblock + offset) = *(uint8_t *)data;  
                 else  
                         memcpy(memblock + offset, data, len);  
         } else {  
                 /*  Ugly optimization, but it works:  */  
                 if (len == sizeof(uint32_t) && (offset & 3)==0  
                     && ((size_t)data&3)==0)  
                         *(uint32_t *)data = *(uint32_t *)(memblock + offset);  
                 else if (len == sizeof(uint8_t))  
                         *(uint8_t *)data = *(uint8_t *)(memblock + offset);  
                 else  
                         memcpy(data, memblock + offset, len);  
         }  
   
396    
397  do_return_ok:  do_return_ok:
398          return MEMORY_ACCESS_OK;          return MEMORY_ACCESS_OK;

Legend:
Removed from v.39  
changed lines
  Added in v.40

  ViewVC Help
Powered by ViewVC 1.1.26