reticulatedpines / magiclantern_simplified

A Git based version of Magic Lantern, for those unwilling or unable to work using Mercurial. The vast majority of branches have been removed, with those thought to be important brought in individually and merged.
GNU General Public License v2.0
142 stars 50 forks source link

Digic X: New memory handling #82

Open kitor opened 1 year ago

kitor commented 1 year ago

R5 has a total of 5(?)GB of RAM. There's no ARM PAE enabled. According to MPU tables, there's almost DIGIC8 mapping (see #80) so 1 gig of cacheable RAM mirrored to 1G uncacheable + almost another 1G of uncacheable.

FIO function gained a few new entries: ReadIBus and WriteIBus. There's some translation going on, as BufferAddr is CPUAddr[%#x:%#x]

Digic X is missing "old" SRM / RscMgr at all. A few stubs that exist here and there are just dummy functions that throw an error or assert.

debug_assert(0,"Resource::RscMgrOldApiStub.c",0x2b);

System is substituted by RscMgr2. No smemshowfix command - replaced by res_memshow <int>.

Example output:

res_memshow 4
     4022:  26713.744 [RSCC] ===== Map 0
     4023:  26713.749 [RSCC] ----- Allocated -----
     4024:  26713.753 [RSCC] USER_RENDERING_WORK
     4025:  26713.756 [RSCC] USER_RENDERING_IMAGE_WORK
     4026:  26713.758 [RSCC] USER_BMPVRAM
     4027:  26713.761 [RSCC] USER_AE_WORK
     4028:  26713.763 [RSCC] USER_AE_ENGINE_WORK
     4029:  26713.765 [RSCC] USER_DAF_RAW
     4030:  26713.767 [RSCC] USER_IMGVRAM_1
     4031:  26713.769 [RSCC] USER_IMGVRAM_2
     4032:  26713.771 [RSCC] USER_IMGVRAM_3
     4033:  26713.773 [RSCC] USER_IMGVRAM_4
     4034:  26713.776 [RSCC] USER_STILL_LV_WORK_1
     4035:  26713.778 [RSCC] USER_STILL_LV_WORK_2
     4036:  26713.780 [RSCC] USER_STILL_LV_WORK_3
     4037:  26713.784 [RSCC] USER_INDEXVRAM
     4038:  26713.786 [RSCC] USER_META_STORE_WORK
     4039:  26713.788 [RSCC] USER_DEFECT_PIX_BUF
     4040:  26713.791 [RSCC] USER_TVAF_WORK
     4041:  26713.793 [RSCC] USER_IBP_DATA
     4042:  26713.795 [RSCC] USER_AF_PINTDATA
     4043:  26713.799 [RSCC] USER_HDMI_RAW_META_STORE_WORK
     4044:  26713.801 [RSCC] USER_MEM3_CH2_B
     4045:  26713.805 [RSCC] ------ Waiting ------
     4046:  26713.815 [RSCC] =====

===

Some functions report addresses in form of more-than-32bit values:

K421[1]>VramRead
     3909:   7226.072 [DISP] PNL Addr:0x300000000 W:1024 H:682
channel = Peripheral::MemifCommon::CheckIbusAddress((layer->ibus).lo,(layer->ibus).hi,"Ximr/XimrApiSub.c",480);
Peripheral::MemifArbiter::MemifCheckPriority(channel,1);
buf = Peripheral::MemifCommon::CheckIbusAddress((layer->ibus).lo,(layer->ibus).hi,"Ximr/XimrApiSub.c",480);
Peripheral::MemifSelfRefresh::FUN_e08c7dfc(buf);

Number above bit 31 seems to be related to "ibus address", as:

      if (((size != 0x80000000) && (size != 0x20000000)) && (size != 0x40000000)) {
        bl_printf("Unexpected Size : %08x\n");
        return 1;
      }

Interesting function name: SystemIF::MapCpuBuffer.c MapCpuBufferToIbusBuffer(), UnmapCpuBuffer() seems to suggest there's some memory banking happening?

dibus evshell command may give a clue how to at least read other ibus channels(?):

K421[1]>dibus
0x100000000:     04 f0 1f e5 00 00 00 e0  - 00 00 00 00 01 00 00 00 
0x100000010:     c6 01 00 00 00 60 fc df  - 28 76 19 00 88 be 2a 00 
0x100000020:     7c ab 2a 00 7c ea 0f 00  - 28 ab 2a 00 00 00 00 00 
0x100000030:     fe 7f ff df fe ff ff ff  - fe ff df ff fb ff ff 7f 
0x100000040:     bd db df ff f8 5f fe ff  - ea ff ff ff ef ff ef bd 
0x100000050:     7f ff df ff df 7f ff fe  - fb fd fe fc df fe d7 ff 
0x100000060:     ff fe ff 7f fb ff fd 7f  - fe ff ff fc ff fe cf fd 
0x100000070:     ff ff f5 fd ff 7f ff ff  - fd d2 ff ff ff ff ff ff 
0x100000080:     ff 7f ff ba df fd fd ff  - df bf fd bb e7 3b ff ff 
0x100000090:     ff fd fe ff ef ff ff ff  - f7 ff ff df ff ff ef fb 
0x1000000a0:     ff ef d5 ff fe ff fe f7  - ff 2f df ff ff 7f bf ff 
0x1000000b0:     ff ff fd ff fb ef ff ff  - ff 7f f7 7f ff ff fb ff 
0x1000000c0:     ff 7a f7 3f af 7f df ff  - ff fe df ff cf df ff f9 
0x1000000d0:     ff d7 ff ff ff df ee ff  - ff ff ef f9 ff ef ff ff 
0x1000000e0:     f7 ff de f4 bf fb dd fb  - df fe 7f fd fa fd db dd 
0x1000000f0:     df fb ff ff f5 ef ff df  - ff fb ff ce ff ee ff e5 
 dibus returned 256(0x100)
K421[1]>dibus 2
0x200000000:     06 01 00 00 00 22 01 60  - 01 ff ff a0 00 00 00 00 
0x200000010:     00 00 00 00 00 00 00 00  - 00 00 00 00 00 00 00 00 
0x200000020:     00 00 00 00 00 00 00 00  - 00 00 00 00 00 00 00 00 
0x200000030:     00 00 00 00 00 00 00 00  - 00 00 00 00 00 00 00 00 
0x200000040:     00 00 00 00 00 00 00 00  - 00 00 00 00 00 00 00 00 
0x200000050:     00 00 00 00 00 00 00 00  - 00 00 00 00 00 00 00 00 
0x200000060:     00 00 00 00 00 00 00 00  - 00 00 00 00 00 00 00 00 
0x200000070:     00 00 00 00 00 00 00 00  - 00 00 00 00 00 00 00 00 
0x200000080:     00 00 00 00 00 00 00 00  - 00 00 00 00 00 00 00 00 
0x200000090:     00 00 00 00 00 00 00 00  - 00 00 00 00 00 00 00 00 
0x2000000a0:     00 00 00 00 00 00 00 00  - 00 00 00 00 00 00 00 00 
0x2000000b0:     00 00 00 00 00 00 00 00  - 00 00 00 00 00 00 00 00 
0x2000000c0:     00 00 00 00 00 00 00 00  - 00 00 00 00 00 00 00 00 
0x2000000d0:     00 00 00 00 00 00 00 00  - 00 00 00 00 00 00 00 00 
0x2000000e0:     00 00 00 00 00 00 00 00  - 00 00 00 00 00 00 00 00 
0x2000000f0:     00 00 00 00 00 00 00 00  - 00 00 00 00 00 00 00 00 
 dibus returned 256(0x100)
K421[1]>dibus 3
0x300000000:     fd 25 c0 df 04 fa 51 50  - 5f 03 fc 29 c0 df 02 03 
0x300000010:     56 40 9f 04 02 4e 40 5f  - 04 ff 29 a0 df 01 00 1e 
0x300000020:     e0 9f 04 fa 45 90 1f 03  - fd 25 d0 df 01 0b 2e 10 
0x300000030:     20 02 14 1e f0 9f 02 1a  - 3e 50 e0 04 08 56 e0 1f 
0x300000040:     04 ff 35 70 9f 04 ff 35  - a0 1f 02 00 16 00 a0 01 
0x300000050:     fb 41 90 1f 04 fc 31 80  - 5f 02 00 1a e0 5f 03 fc 
0x300000060:     41 e0 20 05 fb 45 c0 e1  - 04 fd 59 80 62 04 ff 21 
0x300000070:     a0 a0 02 fe 35 70 5f 03  - ff 21 a0 1f 02 ff 29 c0 
0x300000080:     1f 02 00 46 d0 5f 02 01  - 1a 10 e0 03 03 4e e0 1f 
0x300000090:     04 06 36 d0 5f 02 02 2a  - d0 9f 02 fd 1d 00 e0 01 
0x3000000a0:     ff 19 20 a0 01 05 1a e0  - 1f 01 03 12 e0 df 01 02 
0x3000000b0:     22 20 60 02 0d 22 10 a0  - 01 06 1a 10 a0 02 fe 31 
0x3000000c0:     c0 df 02 01 2a a0 9f 01  - ff 2d a0 df 04 fa 4d 40 
0x3000000d0:     5f 03 04 22 e0 df 01 03  - 1e 50 e0 01 00 1e 40 60 
0x3000000e0:     04 01 36 10 60 03 fc 51  - 30 df 03 fc 35 b0 df 03 
0x3000000f0:     00 56 00 9f 05 fe 51 20  - 1f 03 fb 29 d0 df 01 fc

In fact, while looking for existing XCM layer data it was on "2nd" IBus:

K421[1]>dryshDry[DivaPUX]> Dry[DivaPUX]> xd 0x22788900
           0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  0123456789abcdef
22788900: 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff  ................
22788910: 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff  ................
22788920: 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff  ................
22788930: 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff  ................
22788940: 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff  ................
22788950: 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff  ................
22788960: 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff  ................
22788970: 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff  ................
22788980: 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff  ................
22788990: 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff  ................
227889a0: 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff  ................
227889b0: 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff  ................
227889c0: 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff  ................
227889d0: 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff  ................
227889e0: 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff  ................
227889f0: 00 00 00 ff 00 00 00 ff 00 00 00 ff 00 00 00 ff  ................
K421[1]>dibus 2 0x22788900 
0x222788900:     00 00 00 ff 00 00 00 ff  - 00 00 00 ff 00 00 00 ff 
0x222788910:     00 00 00 ff 00 00 00 ff  - 00 00 00 ff 00 00 00 ff 
0x222788920:     00 00 00 ff 00 00 00 ff  - 00 00 00 ff 00 00 00 ff 
0x222788930:     00 00 00 ff 00 00 00 ff  - 00 00 00 ff 00 00 00 ff 
0x222788940:     00 00 00 ff 00 00 00 ff  - 00 00 00 ff 00 00 00 ff 
0x222788950:     00 00 00 ff 00 00 00 ff  - 00 00 00 ff 00 00 00 ff 
0x222788960:     00 00 00 ff 00 00 00 ff  - 00 00 00 ff 00 00 00 ff 
0x222788970:     00 00 00 ff 00 00 00 ff  - 00 00 00 ff 00 00 00 ff 
0x222788980:     00 00 00 ff 00 00 00 ff  - 00 00 00 ff 00 00 00 ff 
0x222788990:     00 00 00 ff 00 00 00 ff  - 00 00 00 ff 00 00 00 ff 
0x2227889a0:     00 00 00 ff 00 00 00 ff  - 00 00 00 ff 00 00 00 ff 
0x2227889b0:     00 00 00 ff 00 00 00 ff  - 00 00 00 ff 00 00 00 ff 
0x2227889c0:     00 00 00 ff 00 00 00 ff  - 00 00 00 ff 00 00 00 ff 
0x2227889d0:     00 00 00 ff 00 00 00 ff  - 00 00 00 ff 00 00 00 ff 
0x2227889e0:     00 00 00 ff 00 00 00 ff  - 00 00 00 ff 00 00 00 ff 
0x2227889f0:     00 00 00 ff 00 00 00 ff  - 00 00 00 ff 00 00 00 ff 

On older models there's a family of MEMIF functions. On R5 those are completely different when compared to any DIGIC 8 model + reference a lot of IBus addresses. Memif/MemifDynamicWindow.c, Peripheral::MemifDynamicWindow.c

When attempting to allocate own buffer for XCM, Assert went from MemifArbiter:

     4016:    962.031 Canon layer: 0x22ff8900
     4017:    962.036 Found 2 layers
     4018:    970.731 Our layer: 0x01ef7700
     4178:   1026.219 [DEVICE] ERROR MemifCheckPriority Invalid Priority!!
     4179:   1026.225 [DEVICE] ERROR pid(1) is not registered in DRAM-Ch1
     4180:   1026.243 [STARTUP] ERROR ASSERT : Peripheral::MemifArbiter.c
     4181:   1026.248 [STARTUP] ASSERT : Task = CtrlSrv
     4182:   1026.250 [STARTUP] ASSERT : Core 0
     4183:   1026.252 [STARTUP] ASSERT : Line 133
     4184:   1026.258 [STARTUP] < StackDump >