diff options
author | Ferass El Hafidi <vitali64pmemail@protonmail.com> | 2023-06-25 16:27:49 +0200 |
---|---|---|
committer | Ferass El Hafidi <vitali64pmemail@protonmail.com> | 2023-06-25 16:27:49 +0200 |
commit | 489f94df3aa2dd303300dd82b5700d3679d67b42 (patch) | |
tree | 28c31877e7d681a77b8d26a33bd7d4945aa87e6d /parse.c | |
parent | 72bb9d25c60d99badd23697700205e218759dd0c (diff) | |
download | acsbaby-master.tar.gz |
Also fixes a major bug where some struct members
would have incorrect values
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
Diffstat (limited to 'parse.c')
-rw-r--r-- | parse.c | 260 |
1 files changed, 3 insertions, 257 deletions
@@ -83,12 +83,6 @@ acs_t parse_acs_footer(const int fildes, const uint16_t acs_offset) { return acs_footer; } -/* - * TODO - * All functions above should be improved. There's a lot of duplication and - * the code doesn't look pretty overall. - */ - ddrs_t parse_ddrs(const int fildes, const acs_t acs_footer, const uint16_t diff_offset) { uint16_t offset = acs_footer.ddrs.address - diff_offset; @@ -99,160 +93,7 @@ ddrs_t parse_ddrs(const int fildes, const acs_t acs_footer, err(errno, "%s", "can't seek to ddrs_ structure"); /* Read */ - read(fildes, &ddr_settings.ddr_channel_set, - sizeof(ddr_settings.ddr_channel_set)); - read(fildes, &ddr_settings.ddr_type, - sizeof(ddr_settings.ddr_type)); - read(fildes, &ddr_settings.ddr_2t_mode, - sizeof(ddr_settings.ddr_2t_mode)); - read(fildes, &ddr_settings.ddr_full_test, - sizeof(ddr_settings.ddr_full_test)); - - read(fildes, &ddr_settings.ddr_full_test, - sizeof(ddr_settings.ddr_full_test)); - read(fildes, &ddr_settings.ddr_size_detect, - sizeof(ddr_settings.ddr_size_detect)); - read(fildes, &ddr_settings.ddr_drv, - sizeof(ddr_settings.ddr_drv)); - read(fildes, &ddr_settings.ddr_odt, - sizeof(ddr_settings.ddr_odt)); - read(fildes, &ddr_settings.ddr_timing_ind, - sizeof(ddr_settings.ddr_timing_ind)); - read(fildes, &ddr_settings.ddr_size, - sizeof(ddr_settings.ddr_size)); - read(fildes, &ddr_settings.ddr_clk, - sizeof(ddr_settings.ddr_clk)); - read(fildes, &ddr_settings.ddr_base_addr, - sizeof(ddr_settings.ddr_base_addr)); - read(fildes, &ddr_settings.ddr_start_offset, - sizeof(ddr_settings.ddr_start_offset)); - read(fildes, &ddr_settings.ddr_pll_ctrl, - sizeof(ddr_settings.ddr_pll_ctrl)); - read(fildes, &ddr_settings.ddr_dmc_ctrl, - sizeof(ddr_settings.ddr_dmc_ctrl)); - read(fildes, &ddr_settings.ddr0_addrmap, - sizeof(ddr_settings.ddr0_addrmap)); - read(fildes, &ddr_settings.ddr1_addrmap, - sizeof(ddr_settings.ddr1_addrmap)); - - read(fildes, &ddr_settings.t_pub_ptr, - sizeof(ddr_settings.t_pub_ptr)); - read(fildes, &ddr_settings.t_pub_mr, - sizeof(ddr_settings.t_pub_mr)); - read(fildes, &ddr_settings.t_pub_odtcr, - sizeof(ddr_settings.t_pub_odtcr)); - read(fildes, &ddr_settings.t_pub_dtpr, - sizeof(ddr_settings.t_pub_dtpr)); - read(fildes, &ddr_settings.t_pub_pgcr0, - sizeof(ddr_settings.t_pub_pgcr0)); - read(fildes, &ddr_settings.t_pub_pgcr1, - sizeof(ddr_settings.t_pub_pgcr1)); - read(fildes, &ddr_settings.t_pub_pgcr2, - sizeof(ddr_settings.t_pub_pgcr2)); - read(fildes, &ddr_settings.t_pub_pgcr3, - sizeof(ddr_settings.t_pub_pgcr3)); - read(fildes, &ddr_settings.t_pub_dxccr, - sizeof(ddr_settings.t_pub_dxccr)); - read(fildes, &ddr_settings.t_pub_dtcr, - sizeof(ddr_settings.t_pub_dtcr)); - read(fildes, &ddr_settings.t_pub_aciocr, - sizeof(ddr_settings.t_pub_aciocr)); - read(fildes, &ddr_settings.t_pub_dx0gcr, - sizeof(ddr_settings.t_pub_dx0gcr)); - read(fildes, &ddr_settings.t_pub_dx1gcr, - sizeof(ddr_settings.t_pub_dx1gcr)); - read(fildes, &ddr_settings.t_pub_dx2gcr, - sizeof(ddr_settings.t_pub_dx2gcr)); - read(fildes, &ddr_settings.t_pub_dx3gcr, - sizeof(ddr_settings.t_pub_dx3gcr)); - read(fildes, &ddr_settings.t_pub_dcr, - sizeof(ddr_settings.t_pub_dcr)); - read(fildes, &ddr_settings.t_pub_dtar, - sizeof(ddr_settings.t_pub_dtar)); - read(fildes, &ddr_settings.t_pub_dsgcr, - sizeof(ddr_settings.t_pub_dsgcr)); - read(fildes, &ddr_settings.t_pub_zq0pr, - sizeof(ddr_settings.t_pub_zq0pr)); - read(fildes, &ddr_settings.t_pub_zq1pr, - sizeof(ddr_settings.t_pub_zq1pr)); - read(fildes, &ddr_settings.t_pub_zq2pr, - sizeof(ddr_settings.t_pub_zq2pr)); - read(fildes, &ddr_settings.t_pub_zq3pr, - sizeof(ddr_settings.t_pub_zq3pr)); - - read(fildes, &ddr_settings.t_pctl0_1us_pck, - sizeof(ddr_settings.t_pctl0_1us_pck)); - read(fildes, &ddr_settings.t_pctl0_100ns_pck, - sizeof(ddr_settings.t_pctl0_100ns_pck)); - read(fildes, &ddr_settings.t_pctl0_init_us, - sizeof(ddr_settings.t_pctl0_init_us)); - read(fildes, &ddr_settings.t_pctl0_rsth_us, - sizeof(ddr_settings.t_pctl0_rsth_us)); - read(fildes, &ddr_settings.t_pctl0_mcfg, - sizeof(ddr_settings.t_pctl0_mcfg)); - read(fildes, &ddr_settings.t_pctl0_mcfg1, - sizeof(ddr_settings.t_pctl0_mcfg1)); - read(fildes, &ddr_settings.t_pctl0_scfg, - sizeof(ddr_settings.t_pctl0_scfg)); - read(fildes, &ddr_settings.t_pctl0_sctl, - sizeof(ddr_settings.t_pctl0_sctl)); - read(fildes, &ddr_settings.t_pctl0_ppcfg, - sizeof(ddr_settings.t_pctl0_ppcfg)); - read(fildes, &ddr_settings.t_pctl0_dfistcfg0, - sizeof(ddr_settings.t_pctl0_dfistcfg0)); - read(fildes, &ddr_settings.t_pctl0_dfistcfg1, - sizeof(ddr_settings.t_pctl0_dfistcfg1)); - read(fildes, &ddr_settings.t_pctl0_dfitctrldelay, - sizeof(ddr_settings.t_pctl0_dfitctrldelay)); - read(fildes, &ddr_settings.t_pctl0_dfitphywrdata, - sizeof(ddr_settings.t_pctl0_dfitphywrdata)); - read(fildes, &ddr_settings.t_pctl0_dfitphywrlta, - sizeof(ddr_settings.t_pctl0_dfitphywrlta)); - read(fildes, &ddr_settings.t_pctl0_dfitrddataen, - sizeof(ddr_settings.t_pctl0_dfitrddataen)); - read(fildes, &ddr_settings.t_pctl0_dfitphyrdlat, - sizeof(ddr_settings.t_pctl0_dfitphyrdlat)); - read(fildes, &ddr_settings.t_pctl0_dfitdramclkdis, - sizeof(ddr_settings.t_pctl0_dfitdramclkdis)); - read(fildes, &ddr_settings.t_pctl0_dfitdramclken, - sizeof(ddr_settings.t_pctl0_dfitdramclken)); - read(fildes, &ddr_settings.t_pctl0_dfitphyupdtype1, - sizeof(ddr_settings.t_pctl0_dfitphyupdtype1)); - read(fildes, &ddr_settings.t_pctl0_dfitctrlupdmin, - sizeof(ddr_settings.t_pctl0_dfitctrlupdmin)); - read(fildes, &ddr_settings.t_pctl0_cmdtstaten, - sizeof(ddr_settings.t_pctl0_cmdtstaten)); - read(fildes, &ddr_settings.t_pctl0_dfiodtcfg, - sizeof(ddr_settings.t_pctl0_dfiodtcfg)); - read(fildes, &ddr_settings.t_pctl0_dfiodtcfg1, - sizeof(ddr_settings.t_pctl0_dfiodtcfg1)); - read(fildes, &ddr_settings.t_pctl0_dfilpcfg0, - sizeof(ddr_settings.t_pctl0_dfilpcfg0)); - - read(fildes, &ddr_settings.t_pub_acbdlr0, - sizeof(ddr_settings.t_pub_acbdlr0)); - - read(fildes, &ddr_settings.ddr_func, - sizeof(ddr_settings.ddr_func)); - read(fildes, &ddr_settings.wr_adj_per, - sizeof(ddr_settings.wr_adj_per)); - read(fildes, &ddr_settings.rd_adj_per, - sizeof(ddr_settings.rd_adj_per)); - - read(fildes, &ddr_settings.t_pub_mr11, - sizeof(ddr_settings.t_pub_mr11)); - read(fildes, &ddr_settings.t_lpddr3_ca0, - sizeof(ddr_settings.t_lpddr3_ca0)); - read(fildes, &ddr_settings.t_lpddr3_ca1, - sizeof(ddr_settings.t_lpddr3_ca1)); - read(fildes, &ddr_settings.t_lpddr3_remap, - sizeof(ddr_settings.t_lpddr3_remap)); - read(fildes, &ddr_settings.t_lpddr3_wl, - sizeof(ddr_settings.t_lpddr3_wl)); - read(fildes, &ddr_settings.rsv1, - sizeof(ddr_settings.rsv1)); - read(fildes, &ddr_settings.rsv2, - sizeof(ddr_settings.rsv2)); + read(fildes, &ddr_settings, acs_footer.ddrs.size); return ddr_settings; } @@ -267,95 +108,7 @@ void parse_ddrt(const int fildes, const acs_t acs_footer, /* Read */ for (int i = 0; i < 7; i++) { - read(fildes, &ddr_timings[i].identifier, - sizeof(ddr_timings[i].identifier)); - - read(fildes, &ddr_timings[i].cfg_ddr_rtp, - sizeof(ddr_timings[i].cfg_ddr_rtp)); - read(fildes, &ddr_timings[i].cfg_ddr_wtr, - sizeof(ddr_timings[i].cfg_ddr_wtr)); - read(fildes, &ddr_timings[i].cfg_ddr_rp, - sizeof(ddr_timings[i].cfg_ddr_rp)); - read(fildes, &ddr_timings[i].cfg_ddr_rcd, - sizeof(ddr_timings[i].cfg_ddr_rcd)); - read(fildes, &ddr_timings[i].cfg_ddr_ras, - sizeof(ddr_timings[i].cfg_ddr_ras)); - read(fildes, &ddr_timings[i].cfg_ddr_rrd, - sizeof(ddr_timings[i].cfg_ddr_rrd)); - read(fildes, &ddr_timings[i].cfg_ddr_rc, - sizeof(ddr_timings[i].cfg_ddr_rc)); - - read(fildes, &ddr_timings[i].cfg_ddr_mrd, - sizeof(ddr_timings[i].cfg_ddr_mrd)); - read(fildes, &ddr_timings[i].cfg_ddr_mod, - sizeof(ddr_timings[i].cfg_ddr_mod)); - read(fildes, &ddr_timings[i].cfg_ddr_faw, - sizeof(ddr_timings[i].cfg_ddr_faw)); - read(fildes, &ddr_timings[i].cfg_ddr_wlmrd, - sizeof(ddr_timings[i].cfg_ddr_wlmrd)); - read(fildes, &ddr_timings[i].cfg_ddr_wlo, - sizeof(ddr_timings[i].cfg_ddr_wlo)); - - read(fildes, &ddr_timings[i].cfg_ddr_xp, - sizeof(ddr_timings[i].cfg_ddr_xp)); - - read(fildes, &ddr_timings[i].cfg_ddr_rfc, - sizeof(ddr_timings[i].cfg_ddr_rfc)); - - read(fildes, &ddr_timings[i].cfg_ddr_xs, - sizeof(ddr_timings[i].cfg_ddr_xs)); - read(fildes, &ddr_timings[i].cfg_ddr_dllk, - sizeof(ddr_timings[i].cfg_ddr_dllk)); - read(fildes, &ddr_timings[i].cfg_ddr_cke, - sizeof(ddr_timings[i].cfg_ddr_cke)); - read(fildes, &ddr_timings[i].cfg_ddr_rtodt, - sizeof(ddr_timings[i].cfg_ddr_rtodt)); - read(fildes, &ddr_timings[i].cfg_ddr_rtw, - sizeof(ddr_timings[i].cfg_ddr_rtw)); - - read(fildes, &ddr_timings[i].cfg_ddr_refi, - sizeof(ddr_timings[i].cfg_ddr_refi)); - read(fildes, &ddr_timings[i].cfg_ddr_refi_mddr3, - sizeof(ddr_timings[i].cfg_ddr_refi_mddr3)); - read(fildes, &ddr_timings[i].cfg_ddr_cl, - sizeof(ddr_timings[i].cfg_ddr_cl)); - read(fildes, &ddr_timings[i].cfg_ddr_wr, - sizeof(ddr_timings[i].cfg_ddr_wr)); - read(fildes, &ddr_timings[i].cfg_ddr_cwl, - sizeof(ddr_timings[i].cfg_ddr_cwl)); - read(fildes, &ddr_timings[i].cfg_ddr_al, - sizeof(ddr_timings[i].cfg_ddr_al)); - read(fildes, &ddr_timings[i].cfg_ddr_dqs, - sizeof(ddr_timings[i].cfg_ddr_dqs)); - read(fildes, &ddr_timings[i].cfg_ddr_cksre, - sizeof(ddr_timings[i].cfg_ddr_cksre)); - read(fildes, &ddr_timings[i].cfg_ddr_cksrx, - sizeof(ddr_timings[i].cfg_ddr_cksrx)); - read(fildes, &ddr_timings[i].cfg_ddr_zqcs, - sizeof(ddr_timings[i].cfg_ddr_zqcs)); - read(fildes, &ddr_timings[i].cfg_ddr_xpdll, - sizeof(ddr_timings[i].cfg_ddr_xpdll)); - read(fildes, &ddr_timings[i].cfg_ddr_exsr, - sizeof(ddr_timings[i].cfg_ddr_exsr)); - read(fildes, &ddr_timings[i].cfg_ddr_zqcl, - sizeof(ddr_timings[i].cfg_ddr_zqcl)); - read(fildes, &ddr_timings[i].cfg_ddr_zqcsi, - sizeof(ddr_timings[i].cfg_ddr_zqcsi)); - - read(fildes, &ddr_timings[i].cfg_ddr_rpab, - sizeof(ddr_timings[i].cfg_ddr_rpab)); - read(fildes, &ddr_timings[i].cfg_ddr_rppb, - sizeof(ddr_timings[i].cfg_ddr_rppb)); - read(fildes, &ddr_timings[i].cfg_ddr_tdqsck, - sizeof(ddr_timings[i].cfg_ddr_tdqsck)); - read(fildes, &ddr_timings[i].cfg_ddr_tdqsckmax, - sizeof(ddr_timings[i].cfg_ddr_tdqsckmax)); - read(fildes, &ddr_timings[i].cfg_ddr_tckesr, - sizeof(ddr_timings[i].cfg_ddr_tckesr)); - read(fildes, &ddr_timings[i].cfg_ddr_tdpd, - sizeof(ddr_timings[i].cfg_ddr_tdpd)); - read(fildes, &ddr_timings[i].cfg_ddr_taond_aofd, - sizeof(ddr_timings[i].cfg_ddr_taond_aofd)); + read(fildes, &ddr_timings[i], acs_footer.ddrt.size / 7); } } @@ -368,14 +121,7 @@ pll_t parse_pll(const int fildes, const acs_t acs_footer, if (lseek(fildes, offset, SEEK_SET) == -1) err(errno, "%s", "can't seek to pll__ structure"); - read(fildes, &pll_settings.cpu_clk, sizeof(pll_settings.cpu_clk)); - read(fildes, &pll_settings.pxp, sizeof(pll_settings.pxp)); - read(fildes, &pll_settings.spi_ctrl, sizeof(pll_settings.spi_ctrl)); - read(fildes, &pll_settings.vddee, sizeof(pll_settings.vddee)); - read(fildes, &pll_settings.vcck, sizeof(pll_settings.vcck)); - read(fildes, &pll_settings.szPad, sizeof(pll_settings.szPad)); - read(fildes, &pll_settings.customer_id, - sizeof(pll_settings.customer_id)); + read(fildes, &pll_settings, acs_footer.pll.size); return pll_settings; } |