static void print_section_info(struct section *s) { printf("section: "); printf_bin(s->name, SECTION_NAME_MAXLEN); printf("\n"); printf("Mem addr: 0x%.8x\n", ntohl(s->memaddr)); printf("Index: 0x%.8x\n", ntohl(s->index)); printf("Base addr: 0x%.8x\n", ntohl(s->baseaddr)); printf("Entry addr: 0x%.8x\n", ntohl(s->entryaddr)); printf("Data size: %u bytes (KB = %.1f) (MB = %.1f)\n", ntohl(s->data_size), (float)TO_KB(ntohl(s->data_size)), (float)TO_MB(ntohl(s->data_size))); printf("Part size: %u bytes (KB = %.1f) (MB = %.1f)\n", ntohl(s->part_size), (float)TO_KB(ntohl(s->part_size)), (float)TO_MB(ntohl(s->part_size))); }
/* * Read the Cache Build Confuration Registers, Decode them and save into * the cpuinfo structure for later use. * No Validation done here, simply read/convert the BCRs */ void read_decode_cache_bcr(void) { struct cpuinfo_arc_cache *p_ic, *p_dc; unsigned int cpu = smp_processor_id(); struct bcr_cache { #ifdef CONFIG_CPU_BIG_ENDIAN unsigned int pad:12, line_len:4, sz:4, config:4, ver:8; #else unsigned int ver:8, config:4, sz:4, line_len:4, pad:12; #endif } ibcr, dbcr; p_ic = &cpuinfo_arc700[cpu].icache; READ_BCR(ARC_REG_IC_BCR, ibcr); if (!ibcr.ver) goto dc_chk; BUG_ON(ibcr.config != 3); p_ic->assoc = 2; /* Fixed to 2w set assoc */ p_ic->line_len = 8 << ibcr.line_len; p_ic->sz_k = 1 << (ibcr.sz - 1); p_ic->ver = ibcr.ver; p_ic->vipt = 1; p_ic->alias = p_ic->sz_k/p_ic->assoc/TO_KB(PAGE_SIZE) > 1; dc_chk: p_dc = &cpuinfo_arc700[cpu].dcache; READ_BCR(ARC_REG_DC_BCR, dbcr); if (!dbcr.ver) return; BUG_ON(dbcr.config != 2); p_dc->assoc = 4; /* Fixed to 4w set assoc */ p_dc->line_len = 16 << dbcr.line_len; p_dc->sz_k = 1 << (dbcr.sz - 1); p_dc->ver = dbcr.ver; p_dc->vipt = 1; p_dc->alias = p_dc->sz_k/p_dc->assoc/TO_KB(PAGE_SIZE) > 1; }
/* * mem_init - initializes memory * * Frees up bootmem * Calculates and displays memory available/used */ void __init mem_init(void) { int codesize, datasize, initsize, reserved_pages, free_pages; int tmp; high_memory = (void *)(CONFIG_LINUX_LINK_BASE + arc_mem_sz); free_all_bootmem(); /* count all reserved pages [kernel code/data/mem_map..] */ reserved_pages = 0; for (tmp = 0; tmp < max_mapnr; tmp++) if (PageReserved(mem_map + tmp)) reserved_pages++; /* XXX: nr_free_pages() is equivalent */ free_pages = max_mapnr - reserved_pages; /* * For the purpose of display below, split the "reserve mem" * kernel code/data is already shown explicitly, * Show any other reservations (mem_map[ ] et al) */ reserved_pages -= (((unsigned int)_end - CONFIG_LINUX_LINK_BASE) >> PAGE_SHIFT); codesize = _etext - _text; datasize = _end - _etext; initsize = __init_end - __init_begin; pr_info("Memory Available: %dM / %ldM (%dK code, %dK data, %dK init, %dK reserv)\n", PAGES_TO_MB(free_pages), TO_MB(arc_mem_sz), TO_KB(codesize), TO_KB(datasize), TO_KB(initsize), PAGES_TO_KB(reserved_pages)); }
char *arc_mmu_mumbojumbo(int cpu_id, char *buf, int len) { int n = 0; struct cpuinfo_arc_mmu *p_mmu = &cpuinfo_arc700[cpu_id].mmu; n += scnprintf(buf + n, len - n, "ARC700 MMU [v%x]\t: %dk PAGE, ", p_mmu->ver, TO_KB(p_mmu->pg_sz)); n += scnprintf(buf + n, len - n, "J-TLB %d (%dx%d), uDTLB %d, uITLB %d, %s\n", p_mmu->num_tlb, p_mmu->sets, p_mmu->ways, p_mmu->u_dtlb, p_mmu->u_itlb, IS_ENABLED(CONFIG_ARC_MMU_SASID) ? "SASID" : ""); return buf; }
static void server_loop(int serv_sock) { char buffer[MAX_BUFF_SIZE]; struct sockaddr_in cli_addr = {0}; socklen_t cli_addr_len = sizeof cli_addr; struct timeval tv; time_t cur_time, prev_time; int bytes_read, curr_bytes = 0; printf("== Entering receive loop ==\n"); gettimeofday(&tv, NULL); prev_time = tv.tv_sec; while(1) { // printf("===============================================\n"); memset(buffer, 0, MAX_BUFF_SIZE); if ((bytes_read = recvfrom(serv_sock, &buffer, MAX_BUFF_SIZE, 0, (struct sockaddr*) &cli_addr, &cli_addr_len)) == -1) error("Error on recv"); curr_bytes += bytes_read; //printf("%s", buffer); gettimeofday(&tv, NULL); cur_time = tv.tv_sec; if (cur_time - prev_time > 1) { printf("--------------------------\n"); printf("Transfer rate(KB/s): %d\n", TO_KB(curr_bytes) ); curr_bytes = 0; prev_time = cur_time; } } printf("== Exit from receive loop ==\n"); }
char *arc_extn_mumbojumbo(int cpu_id, char *buf, int len) { int n = 0; struct cpuinfo_arc *cpu = &cpuinfo_arc700[cpu_id]; FIX_PTR(cpu); #define IS_AVAIL1(var, str) ((var) ? str : "") #define IS_AVAIL2(var, str) ((var == 0x2) ? str : "") #define IS_USED(cfg) (IS_ENABLED(cfg) ? "(in-use)" : "(not used)") n += scnprintf(buf + n, len - n, "Extn [700-Base]\t: %s %s %s %s %s %s\n", IS_AVAIL2(cpu->extn.norm, "norm,"), IS_AVAIL2(cpu->extn.barrel, "barrel-shift,"), IS_AVAIL1(cpu->extn.swap, "swap,"), IS_AVAIL2(cpu->extn.minmax, "minmax,"), IS_AVAIL1(cpu->extn.crc, "crc,"), IS_AVAIL2(cpu->extn.ext_arith, "ext-arith")); n += scnprintf(buf + n, len - n, "Extn [700-MPY]\t: %s", mul_type_nm[cpu->extn.mul].str); n += scnprintf(buf + n, len - n, " MAC MPY: %s\n", mac_mul_nm[cpu->extn_mac_mul.type].str); if (cpu->core.family == 0x34) { n += scnprintf(buf + n, len - n, "Extn [700-4.10]\t: LLOCK/SCOND %s, SWAPE %s, RTSC %s\n", IS_USED(CONFIG_ARC_HAS_LLSC), IS_USED(CONFIG_ARC_HAS_SWAPE), IS_USED(CONFIG_ARC_HAS_RTSC)); } n += scnprintf(buf + n, len - n, "Extn [CCM]\t: %s", !(cpu->dccm.sz || cpu->iccm.sz) ? "N/A" : ""); if (cpu->dccm.sz) n += scnprintf(buf + n, len - n, "DCCM: @ %x, %d KB ", cpu->dccm.base_addr, TO_KB(cpu->dccm.sz)); if (cpu->iccm.sz) n += scnprintf(buf + n, len - n, "ICCM: @ %x, %d KB", cpu->iccm.base_addr, TO_KB(cpu->iccm.sz)); n += scnprintf(buf + n, len - n, "\nExtn [FPU]\t: %s", !(cpu->fp.ver || cpu->dpfp.ver) ? "N/A" : ""); if (cpu->fp.ver) n += scnprintf(buf + n, len - n, "SP [v%d] %s", cpu->fp.ver, cpu->fp.fast ? "(fast)" : ""); if (cpu->dpfp.ver) n += scnprintf(buf + n, len - n, "DP [v%d] %s", cpu->dpfp.ver, cpu->dpfp.fast ? "(fast)" : ""); n += scnprintf(buf + n, len - n, "\n"); n += scnprintf(buf + n, len - n, "OS ABI [v3]\t: no-legacy-syscalls\n"); return buf; }
/* * Read the Cache Build Confuration Registers, Decode them and save into * the cpuinfo structure for later use. * No Validation done here, simply read/convert the BCRs */ void read_decode_cache_bcr(void) { struct cpuinfo_arc_cache *p_ic, *p_dc, *p_slc; unsigned int cpu = smp_processor_id(); struct bcr_cache { #ifdef CONFIG_CPU_BIG_ENDIAN unsigned int pad:12, line_len:4, sz:4, config:4, ver:8; #else unsigned int ver:8, config:4, sz:4, line_len:4, pad:12; #endif } ibcr, dbcr; struct bcr_generic sbcr; struct bcr_slc_cfg { #ifdef CONFIG_CPU_BIG_ENDIAN unsigned int pad:24, way:2, lsz:2, sz:4; #else unsigned int sz:4, lsz:2, way:2, pad:24; #endif } slc_cfg; p_ic = &cpuinfo_arc700[cpu].icache; READ_BCR(ARC_REG_IC_BCR, ibcr); if (!ibcr.ver) goto dc_chk; if (ibcr.ver <= 3) { BUG_ON(ibcr.config != 3); p_ic->assoc = 2; /* Fixed to 2w set assoc */ } else if (ibcr.ver >= 4) { p_ic->assoc = 1 << ibcr.config; /* 1,2,4,8 */ } p_ic->line_len = 8 << ibcr.line_len; p_ic->sz_k = 1 << (ibcr.sz - 1); p_ic->ver = ibcr.ver; p_ic->vipt = 1; p_ic->alias = p_ic->sz_k/p_ic->assoc/TO_KB(PAGE_SIZE) > 1; dc_chk: p_dc = &cpuinfo_arc700[cpu].dcache; READ_BCR(ARC_REG_DC_BCR, dbcr); if (!dbcr.ver) goto slc_chk; if (dbcr.ver <= 3) { BUG_ON(dbcr.config != 2); p_dc->assoc = 4; /* Fixed to 4w set assoc */ p_dc->vipt = 1; p_dc->alias = p_dc->sz_k/p_dc->assoc/TO_KB(PAGE_SIZE) > 1; } else if (dbcr.ver >= 4) { p_dc->assoc = 1 << dbcr.config; /* 1,2,4,8 */ p_dc->vipt = 0; p_dc->alias = 0; /* PIPT so can't VIPT alias */ } p_dc->line_len = 16 << dbcr.line_len; p_dc->sz_k = 1 << (dbcr.sz - 1); p_dc->ver = dbcr.ver; slc_chk: if (!is_isa_arcv2()) return; p_slc = &cpuinfo_arc700[cpu].slc; READ_BCR(ARC_REG_SLC_BCR, sbcr); if (sbcr.ver) { READ_BCR(ARC_REG_SLC_CFG, slc_cfg); p_slc->ver = sbcr.ver; p_slc->sz_k = 128 << slc_cfg.sz; l2_line_sz = p_slc->line_len = (slc_cfg.lsz == 0) ? 128 : 64; } }
int main() { int afVMCI; int sockfd, newfd; char buffer[BUFF_SIZE]; struct sockaddr_vm my_addr = {0}, their_addr = {0}; socklen_t their_addr_len = sizeof their_addr; struct timeval tv; time_t cur_time, prev_time; int total_bytes, bytes_read; int curr_bytes = 0; int total_time = 0; /*Obtain VMCI address family*/ afVMCI = VMCISock_GetAFValue(); init_sockaddr(afVMCI, &my_addr); printf("Creating socket...\n"); /*Create a socket*/ if ((sockfd = socket(afVMCI, SOCK_STREAM, 0)) == -1) error("socket"); printf("Binding...\n"); /*Bind*/ if (bind(sockfd, (struct sockaddr *) &my_addr, sizeof my_addr) == -1) error("bind"); printf("Listening for connections...\n"); /*Listen*/ if (listen(sockfd,BACKLOG) == -1) error("listen"); /*Measure the time before the transfer*/ gettimeofday(&tv, NULL); prev_time = tv.tv_sec; /*Accept a connection and don't make recv*/ /*Checking the buffer size*/ while (total_bytes < TRANSFER_SIZE) { /*Accept*/ if ((newfd = accept(sockfd, (struct sockaddr*) &their_addr, &their_addr_len)) == -1) error("accept"); if ((bytes_read = recv(newfd, buffer, BUFF_SIZE,0)) == -1) error("recv"); curr_bytes += bytes_read; total_bytes += bytes_read; close(newfd); gettimeofday(&tv, NULL); cur_time = tv.tv_sec; if (cur_time - prev_time > 1) { printf("--------------------------\n"); printf("Transfer rate(KB/s): %d\n", TO_KB(curr_bytes) ); printf("Transferred %d/%d\n", TO_KB(total_bytes), TO_KB(TRANSFER_SIZE) ); curr_bytes = 0; ++total_time; prev_time = cur_time; } close(newfd); } /*Calculate total transfer time*/ printf("--------------------------\n"); printf("Total time(s) :%d\n", total_time); printf("Average transfer rate(KB/s): %d\n", TO_KB(total_bytes) / total_time); close(sockfd); return 0; }