Commit 486579de70a08098edf3c59eec3e6482a8136e32

Authored by balrog
1 parent 69d6451c

SH: improve the way sh7750 registers io memory (Takashi YOSHII).

Fixes to be needed for commit #5849 "Change MMIO callbacks..."
 hw/sh7750.c:
  - Divide region of CPU control registers to avoid overlapping
    to peripheral modules.
  - Delete unused var "icr", which had moved to hw/sh_intc.c.
 hw/sm501.c:
  - Merge non page aligned palette registers into the region of
    control registers.

Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5934 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 41 additions and 55 deletions
hw/sh7750.c
@@ -60,7 +60,6 @@ typedef struct SH7750State { @@ -60,7 +60,6 @@ typedef struct SH7750State {
60 uint16_t periph_portdirb; /* Direction seen from the peripherals */ 60 uint16_t periph_portdirb; /* Direction seen from the peripherals */
61 sh7750_io_device *devices[NB_DEVICES]; /* External peripherals */ 61 sh7750_io_device *devices[NB_DEVICES]; /* External peripherals */
62 62
63 - uint16_t icr;  
64 /* Cache */ 63 /* Cache */
65 uint32_t ccr; 64 uint32_t ccr;
66 65
@@ -222,8 +221,6 @@ static uint32_t sh7750_mem_readw(void *opaque, target_phys_addr_t addr) @@ -222,8 +221,6 @@ static uint32_t sh7750_mem_readw(void *opaque, target_phys_addr_t addr)
222 return porta_lines(s); 221 return porta_lines(s);
223 case SH7750_PDTRB_A7: 222 case SH7750_PDTRB_A7:
224 return portb_lines(s); 223 return portb_lines(s);
225 - case 0x1fd00000:  
226 - return s->icr;  
227 default: 224 default:
228 error_access("word read", addr); 225 error_access("word read", addr);
229 assert(0); 226 assert(0);
@@ -328,9 +325,6 @@ static void sh7750_mem_writew(void *opaque, target_phys_addr_t addr, @@ -328,9 +325,6 @@ static void sh7750_mem_writew(void *opaque, target_phys_addr_t addr,
328 assert(0); 325 assert(0);
329 } 326 }
330 return; 327 return;
331 - case 0x1fd00000:  
332 - s->icr = mem_value;  
333 - return;  
334 default: 328 default:
335 error_access("word write", addr); 329 error_access("word write", addr);
336 assert(0); 330 assert(0);
@@ -687,8 +681,12 @@ SH7750State *sh7750_init(CPUSH4State * cpu) @@ -687,8 +681,12 @@ SH7750State *sh7750_init(CPUSH4State * cpu)
687 sh7750_io_memory = cpu_register_io_memory(0, 681 sh7750_io_memory = cpu_register_io_memory(0,
688 sh7750_mem_read, 682 sh7750_mem_read,
689 sh7750_mem_write, s); 683 sh7750_mem_write, s);
690 - cpu_register_physical_memory_offset(0x1c000000, 0x04000000,  
691 - sh7750_io_memory, 0x1c000000); 684 + cpu_register_physical_memory_offset(0x1f000000, 0x1000,
  685 + sh7750_io_memory, 0x1f000000);
  686 + cpu_register_physical_memory_offset(0x1f800000, 0x1000,
  687 + sh7750_io_memory, 0x1f800000);
  688 + cpu_register_physical_memory_offset(0x1fc00000, 0x1000,
  689 + sh7750_io_memory, 0x1fc00000);
692 690
693 sh7750_mm_cache_and_tlb = cpu_register_io_memory(0, 691 sh7750_mm_cache_and_tlb = cpu_register_io_memory(0,
694 sh7750_mmct_read, 692 sh7750_mmct_read,
hw/sm501.c
@@ -638,6 +638,32 @@ static CPUWriteMemoryFunc *sm501_system_config_writefn[] = { @@ -638,6 +638,32 @@ static CPUWriteMemoryFunc *sm501_system_config_writefn[] = {
638 &sm501_system_config_write, 638 &sm501_system_config_write,
639 }; 639 };
640 640
  641 +static uint32_t sm501_palette_read(void *opaque, target_phys_addr_t addr)
  642 +{
  643 + SM501State * s = (SM501State *)opaque;
  644 + SM501_DPRINTF("sm501 palette read addr=%x\n", (int)addr);
  645 +
  646 + /* TODO : consider BYTE/WORD access */
  647 + /* TODO : consider endian */
  648 +
  649 + assert(0 <= addr && addr < 0x400 * 3);
  650 + return *(uint32_t*)&s->dc_palette[addr];
  651 +}
  652 +
  653 +static void sm501_palette_write(void *opaque,
  654 + target_phys_addr_t addr, uint32_t value)
  655 +{
  656 + SM501State * s = (SM501State *)opaque;
  657 + SM501_DPRINTF("sm501 palette write addr=%x, val=%x\n",
  658 + (int)addr, value);
  659 +
  660 + /* TODO : consider BYTE/WORD access */
  661 + /* TODO : consider endian */
  662 +
  663 + assert(0 <= addr && addr < 0x400 * 3);
  664 + *(uint32_t*)&s->dc_palette[addr] = value;
  665 +}
  666 +
641 static uint32_t sm501_disp_ctrl_read(void *opaque, target_phys_addr_t addr) 667 static uint32_t sm501_disp_ctrl_read(void *opaque, target_phys_addr_t addr)
642 { 668 {
643 SM501State * s = (SM501State *)opaque; 669 SM501State * s = (SM501State *)opaque;
@@ -719,6 +745,10 @@ static uint32_t sm501_disp_ctrl_read(void *opaque, target_phys_addr_t addr) @@ -719,6 +745,10 @@ static uint32_t sm501_disp_ctrl_read(void *opaque, target_phys_addr_t addr)
719 ret = s->dc_crt_hwc_addr; 745 ret = s->dc_crt_hwc_addr;
720 break; 746 break;
721 747
  748 + case SM501_DC_PANEL_PALETTE ... SM501_DC_PANEL_PALETTE + 0x400*3 - 4:
  749 + ret = sm501_palette_read(opaque, addr - SM501_DC_PANEL_PALETTE);
  750 + break;
  751 +
722 default: 752 default:
723 printf("sm501 disp ctrl : not implemented register read." 753 printf("sm501 disp ctrl : not implemented register read."
724 " addr=%x\n", (int)addr); 754 " addr=%x\n", (int)addr);
@@ -823,6 +853,10 @@ static void sm501_disp_ctrl_write(void *opaque, @@ -823,6 +853,10 @@ static void sm501_disp_ctrl_write(void *opaque,
823 s->dc_crt_hwc_addr = value & 0x0000FFFF; 853 s->dc_crt_hwc_addr = value & 0x0000FFFF;
824 break; 854 break;
825 855
  856 + case SM501_DC_PANEL_PALETTE ... SM501_DC_PANEL_PALETTE + 0x400*3 - 4:
  857 + sm501_palette_write(opaque, addr - SM501_DC_PANEL_PALETTE, value);
  858 + break;
  859 +
826 default: 860 default:
827 printf("sm501 disp ctrl : not implemented register write." 861 printf("sm501 disp ctrl : not implemented register write."
828 " addr=%x, val=%x\n", (int)addr, value); 862 " addr=%x, val=%x\n", (int)addr, value);
@@ -842,45 +876,6 @@ static CPUWriteMemoryFunc *sm501_disp_ctrl_writefn[] = { @@ -842,45 +876,6 @@ static CPUWriteMemoryFunc *sm501_disp_ctrl_writefn[] = {
842 &sm501_disp_ctrl_write, 876 &sm501_disp_ctrl_write,
843 }; 877 };
844 878
845 -static uint32_t sm501_palette_read(void *opaque, target_phys_addr_t addr)  
846 -{  
847 - SM501State * s = (SM501State *)opaque;  
848 - SM501_DPRINTF("sm501 palette read addr=%x\n", (int)addr);  
849 -  
850 - /* TODO : consider BYTE/WORD access */  
851 - /* TODO : consider endian */  
852 -  
853 - assert(0 <= addr && addr < 0x400 * 3);  
854 - return *(uint32_t*)&s->dc_palette[addr];  
855 -}  
856 -  
857 -static void sm501_palette_write(void *opaque,  
858 - target_phys_addr_t addr, uint32_t value)  
859 -{  
860 - SM501State * s = (SM501State *)opaque;  
861 - SM501_DPRINTF("sm501 palette write addr=%x, val=%x\n",  
862 - (int)addr, value);  
863 -  
864 - /* TODO : consider BYTE/WORD access */  
865 - /* TODO : consider endian */  
866 -  
867 - assert(0 <= addr && addr < 0x400 * 3);  
868 - *(uint32_t*)&s->dc_palette[addr] = value;  
869 -}  
870 -  
871 -static CPUReadMemoryFunc *sm501_palette_readfn[] = {  
872 - &sm501_palette_read,  
873 - &sm501_palette_read,  
874 - &sm501_palette_read,  
875 -};  
876 -  
877 -static CPUWriteMemoryFunc *sm501_palette_writefn[] = {  
878 - &sm501_palette_write,  
879 - &sm501_palette_write,  
880 - &sm501_palette_write,  
881 -};  
882 -  
883 -  
884 /* draw line functions for all console modes */ 879 /* draw line functions for all console modes */
885 880
886 #include "pixel_ops.h" 881 #include "pixel_ops.h"
@@ -1070,7 +1065,6 @@ void sm501_init(DisplayState *ds, uint32_t base, unsigned long local_mem_base, @@ -1070,7 +1065,6 @@ void sm501_init(DisplayState *ds, uint32_t base, unsigned long local_mem_base,
1070 SM501State * s; 1065 SM501State * s;
1071 int sm501_system_config_index; 1066 int sm501_system_config_index;
1072 int sm501_disp_ctrl_index; 1067 int sm501_disp_ctrl_index;
1073 - int sm501_palette_index;  
1074 1068
1075 /* allocate management data region */ 1069 /* allocate management data region */
1076 s = (SM501State *)qemu_mallocz(sizeof(SM501State)); 1070 s = (SM501State *)qemu_mallocz(sizeof(SM501State));
@@ -1098,13 +1092,7 @@ void sm501_init(DisplayState *ds, uint32_t base, unsigned long local_mem_base, @@ -1098,13 +1092,7 @@ void sm501_init(DisplayState *ds, uint32_t base, unsigned long local_mem_base,
1098 sm501_disp_ctrl_index = cpu_register_io_memory(0, sm501_disp_ctrl_readfn, 1092 sm501_disp_ctrl_index = cpu_register_io_memory(0, sm501_disp_ctrl_readfn,
1099 sm501_disp_ctrl_writefn, s); 1093 sm501_disp_ctrl_writefn, s);
1100 cpu_register_physical_memory(base + MMIO_BASE_OFFSET + SM501_DC, 1094 cpu_register_physical_memory(base + MMIO_BASE_OFFSET + SM501_DC,
1101 - 0x400, sm501_disp_ctrl_index);  
1102 -  
1103 - sm501_palette_index = cpu_register_io_memory(0, sm501_palette_readfn,  
1104 - sm501_palette_writefn, s);  
1105 - cpu_register_physical_memory(base + MMIO_BASE_OFFSET  
1106 - + SM501_DC + SM501_DC_PANEL_PALETTE,  
1107 - 0x400 * 3, sm501_palette_index); 1095 + 0x1000, sm501_disp_ctrl_index);
1108 1096
1109 /* bridge to serial emulation module */ 1097 /* bridge to serial emulation module */
1110 if (chr) 1098 if (chr)