• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/staging/tidspbridge/dynload/

Lines Matching refs:dlthis

25 static void dload_symbols(struct dload_state *dlthis);
26 static void dload_data(struct dload_state *dlthis);
27 static void allocate_sections(struct dload_state *dlthis);
28 static void string_table_free(struct dload_state *dlthis);
29 static void symbol_table_free(struct dload_state *dlthis);
30 static void section_table_free(struct dload_state *dlthis);
31 static void init_module_handle(struct dload_state *dlthis);
33 static char *unpack_name(struct dload_state *dlthis, u32 soffset);
61 void dload_error(struct dload_state *dlthis, const char *errtxt, ...)
66 dlthis->mysym->error_report(dlthis->mysym, errtxt, args);
68 dlthis->dload_errcount += 1;
72 #define DL_ERROR(zza, zzb) dload_error(dlthis, zza, zzb)
319 void dload_headers(struct dload_state *dlthis)
325 if (dlthis->strm->read_buffer(dlthis->strm, &dlthis->dfile_hdr,
335 map = REORDER_MAP(dlthis->dfile_hdr.df_byte_reshuffle);
339 dload_reorder(&dlthis->dfile_hdr, COMBINED_HEADER_SIZE,
342 if (dlthis->dfile_hdr.df_byte_reshuffle !=
345 dload_error(dlthis,
347 dlthis->dfile_hdr.df_byte_reshuffle);
350 dlthis->reorder_map = map; /* keep map for future use */
356 if (~dload_checksum(&dlthis->dfile_hdr,
358 ~dload_checksum(&dlthis->verify,
364 dlthis->dfile_hdr.df_byte_reshuffle = map; /* put back for later */
368 if ((dlthis->dfile_hdr.df_target_id != TARGET_ID) &&
369 -(dlthis->dfile_hdr.df_target_id != TMS470_ID)) {
370 dload_error(dlthis, "Bad target ID 0x%x and TARGET_ID 0x%x",
371 dlthis->dfile_hdr.df_target_id, TARGET_ID);
375 if ((dlthis->dfile_hdr.df_doff_version != DOFF0)) {
376 dload_error(dlthis, "Bad DOFF version 0x%x",
377 dlthis->dfile_hdr.df_doff_version);
384 if (dlthis->dfile_hdr.df_strtab_size > MAX_REASONABLE_STRINGTAB) {
385 dload_error(dlthis, "Excessive string table size " FMT_UI32,
386 dlthis->dfile_hdr.df_strtab_size);
389 if (dlthis->dfile_hdr.df_no_scns > MAX_REASONABLE_SECTIONS) {
390 dload_error(dlthis, "Excessive section count 0x%x",
391 dlthis->dfile_hdr.df_no_scns);
398 if ((dlthis->dfile_hdr.df_flags >> ALIGN_COFF_ENDIANNESS) &
399 dlthis->myoptions & ENDIANNESS_MASK) {
400 dload_error(dlthis,
404 dlthis->big_e_target = dlthis->dfile_hdr.df_flags & DF_BIG;
426 void dload_sections(struct dload_state *dlthis)
430 unsigned nsecs = dlthis->dfile_hdr.df_no_scns;
435 (struct doff_scnhdr_t *)dlthis->mysym->dload_allocate(dlthis->mysym,
441 dlthis->sect_hdrs = shp;
444 if (dlthis->strm->read_buffer(dlthis->strm, shp, siz) != siz) {
450 if (dlthis->reorder_map)
451 dload_reorder(shp, siz, dlthis->reorder_map);
454 if (~dload_checksum(dlthis->sect_hdrs, siz) !=
455 dlthis->verify.dv_scn_rec_checksum) {
471 static void allocate_sections(struct dload_state *dlthis)
477 nsecs = dlthis->dfile_hdr.df_no_scns;
480 if ((dlthis->myalloc == NULL) &&
481 (dlthis->dfile_hdr.df_target_scns > 0)) {
490 siz = (dlthis->dfile_hdr.df_target_scns + 1) *
494 (struct my_handle *)dlthis->mysym->dload_allocate(dlthis->mysym,
504 dlthis->myhandle = hndl; /* save away for return */
506 dlthis->ldr_sections = asecs = hndl->secns;
509 shp = dlthis->sect_hdrs;
514 if (soffset < dlthis->dfile_hdr.df_strtab_size)
516 dlthis->str_head + soffset;
518 dload_error(dlthis, "Bad name offset in section %d",
528 asecs->name = unpack_name(dlthis, soffset);
529 dlthis->debug_string_size = soffset + dlthis->temp_len;
531 dlthis->debug_string_size = soffset;
533 if (dlthis->myalloc != NULL) {
534 if (!dlthis->myalloc->
535 dload_allocate(dlthis->myalloc, asecs,
537 dload_error(dlthis, tgtalloc,
545 dlthis->allocated_secn_count += 1;
551 dlthis->debug_string_size +=
552 strlen(dlthis->str_head + dlthis->debug_string_size) + 1;
568 static void section_table_free(struct dload_state *dlthis)
572 shp = dlthis->sect_hdrs;
574 dlthis->mysym->dload_deallocate(dlthis->mysym, shp);
591 void dload_strings(struct dload_state *dlthis, bool sec_names_only)
598 (dlthis->dfile_hdr.df_scn_name_size));
601 (dlthis->dfile_hdr.df_strtab_size));
608 strbuf = (char *)dlthis->mysym->dload_allocate(dlthis->mysym, ssiz +
609 dlthis->dfile_hdr.
612 strbuf = (char *)dlthis->mysym->dload_allocate(dlthis->mysym, ssiz);
618 dlthis->str_head = strbuf;
620 dlthis->str_temp = strbuf + ssiz;
623 if ((unsigned)(dlthis->strm->read_buffer(dlthis->strm, strbuf,
629 if (dlthis->reorder_map)
630 dload_reorder(strbuf, ssiz, dlthis->reorder_map);
633 dlthis->verify.dv_str_tab_checksum)) {
637 if (dlthis->dfile_hdr.df_byte_reshuffle !=
641 HOST_BYTE_ORDER(dlthis->
645 dlthis->verify.dv_str_tab_checksum)) {
663 static void string_table_free(struct dload_state *dlthis)
665 if (dlthis->str_head)
666 dlthis->mysym->dload_deallocate(dlthis->mysym,
667 dlthis->str_head);
702 static void dload_symbols(struct dload_state *dlthis)
710 sym_count = dlthis->dfile_hdr.df_no_syms;
726 (sizeof(struct dll_sect) * dlthis->allocated_secn_count) +
727 BYTE_TO_HOST_ROUND(dlthis->debug_string_size + 1);
730 sp = (struct local_symbol *)dlthis->mysym->dload_allocate(dlthis->mysym,
736 dlthis->local_symtab = sp;
740 checks = dlthis->verify.dv_sym_tab_checksum;
753 if (dlthis->strm->read_buffer(dlthis->strm, input_sym, siz) !=
758 if (dlthis->reorder_map)
759 dload_reorder(input_sym, siz, dlthis->reorder_map);
769 dlthis->dfile_hdr.df_strtab_size)
770 sname = dlthis->str_head +
773 dload_error(dlthis,
777 sname = unpack_name(dlthis,
794 symp = dlthis->mysym->find_matching_symbol
795 (dlthis->mysym, sname);
804 dload_syms_error(dlthis->mysym,
815 dlthis->allocated_secn_count) {
818 &dlthis->sect_hdrs[sp->secnn - 1];
838 dlthis->mysym->find_matching_symbol(dlthis->
873 newsym = dlthis->mysym->add_to_symbol_table
874 (dlthis->mysym, sname,
875 (unsigned)dlthis->myhandle);
888 dload_error(dlthis, "Checksum of symbols failed");
904 static void symbol_table_free(struct dload_state *dlthis)
906 if (dlthis->local_symtab) {
907 if (dlthis->dload_errcount) { /* blow off our symbols */
908 dlthis->mysym->purge_symbol_table(dlthis->mysym,
910 dlthis->myhandle);
912 dlthis->mysym->dload_deallocate(dlthis->mysym,
913 dlthis->local_symtab);
943 static void cload_cinit(struct dload_state *dlthis,
960 switch (dlthis->cinit_state) {
964 temp = dload_unpack(dlthis, (tgt_au_t *) pktp,
970 dlthis->cinit_state = CI_DONE;
973 dlthis->cinit_count = temp;
974 dlthis->cinit_state = CI_ADDRESS;
980 *(uint16_t *) pktp = dlthis->cinit_addr;
988 dlthis->cinit_addr = *(uint16_t *) pktp;
990 dlthis->cinit_state = CI_PARTADDRESS;
996 atmp = dload_unpack(dlthis, (tgt_au_t *) pktp,
1001 dlthis->cinit_page = atmp &
1005 dlthis->cinit_page = CINIT_DEFAULT_PAGE;
1007 dlthis->cinit_addr = atmp;
1008 dlthis->cinit_state = CI_COPY;
1012 if (init_count > dlthis->cinit_count)
1013 init_count = dlthis->cinit_count;
1017 cinit_info.page = dlthis->cinit_page;
1018 if (!dlthis->myio->writemem(dlthis->myio, pktp,
1020 (dlthis->cinit_addr),
1023 dload_error(dlthis, initfail, "write",
1024 dlthis->cinit_addr);
1026 dlthis->cinit_count -= init_count;
1027 if (dlthis->cinit_count <= 0) {
1028 dlthis->cinit_state = CI_COUNT;
1034 dlthis->cinit_addr += init_count;
1043 dload_error(dlthis, "%d bytes left over in cinit packet", left);
1044 dlthis->cinit_state = CI_DONE; /* left over bytes are bad */
1069 static int relocate_packet(struct dload_state *dlthis,
1084 if (dlthis->strm->read_buffer(dlthis->strm, rp, siz) != siz) {
1089 if (dlthis->reorder_map)
1090 dload_reorder(rp, siz, dlthis->reorder_map);
1095 dload_relocate(dlthis, (tgt_au_t *) ipacket->img_data,
1105 dload_tramp_pkt_udpate(dlthis,
1106 (dlthis->image_secn -
1107 dlthis->ldr_sections),
1108 dlthis->image_offset, ipacket);
1129 static void dload_data(struct dload_state *dlthis)
1132 struct doff_scnhdr_t *sptr = dlthis->sect_hdrs;
1133 struct ldr_section_info *lptr = dlthis->ldr_sections;
1149 for (curr_sect = 0; curr_sect < dlthis->dfile_hdr.df_no_scns;
1155 if (curr_sect < dlthis->allocated_secn_count)
1156 dlthis->delta_runaddr = sptr->ds_paddr;
1159 dlthis->delta_runaddr = 0;
1161 dlthis->image_secn = lptr;
1163 lptr->name = unpack_name(dlthis, sptr->ds_offset);
1173 if (dlthis->strm->read_buffer(dlthis->strm,
1181 if (dlthis->reorder_map) {
1183 dlthis->reorder_map);
1198 dlthis->myio->writemem(dlthis->myio,
1208 if (dlthis->strm->read_buffer(dlthis->strm,
1219 if (dlthis->reorder_map) {
1221 dlthis->reorder_map);
1225 if (dlthis->dfile_hdr.df_byte_reshuffle !=
1232 (dlthis->dfile_hdr.
1246 dlthis->image_offset = image_offset;
1247 if (!relocate_packet(dlthis,
1265 cload_cinit(dlthis,
1272 if (!dlthis->myio->
1273 writemem(dlthis->
1304 if (!(dlthis->myoptions & DLOAD_INITBSS))
1317 dlthis->myio->fillmem(dlthis->myio,
1328 if (!(dlthis->myoptions & DLOAD_INITBSS))
1331 if (curr_sect >= dlthis->allocated_secn_count)
1342 dlthis->myio->fillmem(dlthis->myio,
1352 if (dload_tramp_finalize(dlthis) == 0) {
1354 ") failed", dlthis->tramp.tramp_sect_next_addr);
1589 static void init_module_handle(struct dload_state *dlthis)
1601 hndl = dlthis->myhandle;
1606 hndl->secn_count = dlthis->allocated_secn_count;
1609 if (dlthis->tramp.tramp_sect_next_addr != 0)
1614 hndl->secn_count = dlthis->allocated_secn_count << 1;
1616 if (dlthis->big_e_target)
1619 if (dlthis->dload_errcount)
1627 debug_mirror_sym = dlthis->mysym->find_matching_symbol(dlthis->mysym,
1635 dlmodsym = dlthis->mysym->find_matching_symbol(dlthis->mysym,
1641 dlthis->mysym->dload_allocate(dlthis->mysym,
1653 debug_mirror_sym = dlthis->mysym->add_to_symbol_table
1654 (dlthis->mysym, loader_dllview_root,
1655 (unsigned)dlthis->myhandle);
1658 dlthis->mysym->dload_deallocate(dlthis->mysym, mlst);
1674 if (!dlthis->allocated_secn_count)
1677 dbmod = (struct dll_module *)dlthis->local_symtab;
1679 dbmod->num_sects = dlthis->allocated_secn_count;
1680 dbmod->timestamp = dlthis->verify.dv_timdat;
1683 asecs = dlthis->ldr_sections;
1685 for (curr_sect = dlthis->allocated_secn_count;
1694 if (dlthis->tramp.tramp_sect_next_addr != 0) {
1703 cp = copy_tgt_strings(dbsec, dlthis->str_head,
1704 dlthis->debug_string_size);
1708 if (dlthis->tramp.tramp_sect_next_addr != 0) {
1710 dlthis->tramp.final_string_table,
1711 strlen(dlthis->tramp.final_string_table) +
1732 if (!dlthis->myalloc)
1734 if (!dlthis->myalloc->dload_allocate(dlthis->myalloc, &dllview_info,
1750 if (!dlthis->myio->writemem(dlthis->myio, dbmod,
1764 if (!dlthis->myio->writemem(dlthis->myio, &mhdr, mlist->dbthis,
1927 static char *unpack_name(struct dload_state *dlthis, u32 soffset)
1932 if (soffset >= dlthis->dfile_hdr.df_strtab_size) {
1933 dload_error(dlthis, "Bad string table offset " FMT_UI32,
1937 src = (uint_least8_t *) dlthis->str_head +
1939 dst = dlthis->str_temp;
1948 dlthis->temp_len = dst - dlthis->str_temp;
1950 return dlthis->str_temp;