/* * FTP - local ==> remote * send local file to remote host * terminate transmission with pseudo EOF sequence */ void sendfile(char cc) { FILE *fd; char *fnamex; char *expand(); putchar(cc); /* * get file name */ if (prompt("Local file name? ", fname, sizeof(fname))) return; /* * look up file */ fnamex = expand(fname); if ((fd = fopen(fnamex, "r")) == NULL) { printf("%s: cannot open\r\n", fname); return; } transmit(fd, value(EOFWRITE), NULL); if (!boolean(value(ECHOCHECK))) { flush_remote (); } }
SYSCALL_DEFINE3(cacheflush, unsigned long, addr, unsigned long, len, unsigned long, flags) { if (flags & DCACHE) homecache_evict(cpumask_of(smp_processor_id())); if (flags & ICACHE) flush_remote(0, HV_FLUSH_EVICT_L1I, mm_cpumask(current->mm), 0, 0, 0, NULL, NULL, 0); return 0; }
/* Flush a page out of whatever cache(s) it is in. */ void homecache_flush_cache(struct page *page, int order) { int pages = 1 << order; int length = cache_flush_length(pages * PAGE_SIZE); unsigned long pfn = page_to_pfn(page); struct cpumask home_mask; homecache_mask(page, pages, &home_mask); flush_remote(pfn, length, &home_mask, 0, 0, 0, NULL, NULL, 0); sim_validate_lines_evicted(PFN_PHYS(pfn), pages * PAGE_SIZE); }
/* * Rather than trying to do sophisticated TLB-management games like * the pkmap code, we just do a global flush when we unmap. * The assumption is that huge pages are acquired long-term by * kernel drivers like the gbe and xgbe. */ void huge_vunmap(void *addr) { int i; unsigned long flags; BUG_ON((unsigned long) addr & (HPAGE_SIZE-1)); i = ((unsigned long) addr - HUGE_VMAP_BASE) >> HPAGE_SHIFT; BUG_ON(i >= CONFIG_NR_HUGE_VMAPS); spin_lock_irqsave(&map_lock, flags); map[i] = NULL; spin_unlock_irqrestore(&map_lock, flags); flush_remote(0, 0, NULL, (HV_VirtAddr) addr, HPAGE_SIZE, HPAGE_SIZE, cpu_online_mask, NULL, 0); }
void homecache_change_page_home(struct page *page, int order, int home) { int i, pages = (1 << order); unsigned long kva; BUG_ON(PageHighMem(page)); BUG_ON(page_count(page) > 1); BUG_ON(page_mapcount(page) != 0); kva = (unsigned long) page_address(page); flush_remote(0, HV_FLUSH_EVICT_L2, &cpu_cacheable_map, kva, pages * PAGE_SIZE, PAGE_SIZE, cpu_online_mask, NULL, 0); for (i = 0; i < pages; ++i, kva += PAGE_SIZE) { pte_t *ptep = virt_to_pte(NULL, kva); pte_t pteval = *ptep; BUG_ON(!pte_present(pteval) || pte_huge(pteval)); *ptep = pte_set_home(pteval, home); } }
void homecache_evict(const struct cpumask *mask) { flush_remote(0, HV_FLUSH_EVICT_L2, mask, 0, 0, 0, NULL, NULL, 0); }
/* * Bulk transfer routine to remote host -- * used by sendfile() and cu_put() */ static void transmit(FILE *fd, char *eofchars, char *command) { char *pc, lastc; int c, ccount, lcount; time_t start_t, stop_t; sig_t f; kill(pid, SIGIOT); /* put TIPOUT into a wait state */ stop = 0; f = signal(SIGINT, stopsnd); usedefchars (); read(repdes[0], (char *)&ccc, 1); if (command != NULL) { for (pc = command; *pc; pc++) send(*pc); if (boolean(value(ECHOCHECK))) read(FD, (char *)&c, 1); /* trailing \n */ else { flush_remote (); sleep(5); /* wait for remote stty to take effect */ } } lcount = 0; lastc = '\0'; start_t = time(0); while (1) { ccount = 0; do { c = getc(fd); if (stop) goto out; if (c == EOF) goto out; if (c == 0177 && !boolean(value(RAWFTP))) continue; lastc = c; if (c < 040) { if (c == '\n') { if (!boolean(value(RAWFTP))) c = '\r'; } else if (c == '\t') { if (!boolean(value(RAWFTP))) { if (boolean(value(TABEXPAND))) { send(' '); while ((++ccount % 8) != 0) send(' '); continue; } } } else if (!boolean(value(RAWFTP))) continue; } send(c); } while (c != '\r' && !boolean(value(RAWFTP))); if (boolean(value(VERBOSE))) printf("\r%d", ++lcount); if (boolean(value(ECHOCHECK))) { timedout = 0; alarm(number(value(ETIMEOUT))); do { /* wait for prompt */ read(FD, (char *)&c, 1); if (timedout || stop) { if (timedout) printf("\r\ntimed out at eol\r\n"); alarm(0); goto out; } } while ((c&0177) != character(value(PROMPT))); alarm(0); } } out: if (lastc != '\n' && !boolean(value(RAWFTP))) send('\r'); for (pc = eofchars; pc && *pc; pc++) send(*pc); stop_t = time(0); fclose(fd); signal(SIGINT, f); if (boolean(value(VERBOSE))) if (boolean(value(RAWFTP))) prtime(" chars transferred in ", stop_t-start_t); else prtime(" lines transferred in ", stop_t-start_t); write(fildes[1], (char *)&ccc, 1); usetchars (); }