17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*ae115bc7Smrj * Common Development and Distribution License (the "License"). 6*ae115bc7Smrj * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*ae115bc7Smrj * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <sys/types.h> 297c478bd9Sstevel@tonic-gate #include <sys/cpr.h> 307c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 317c478bd9Sstevel@tonic-gate #include "cprboot.h" 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate /* 357c478bd9Sstevel@tonic-gate * check if any cpd_t pages clash with the statefile buffer and shuffle 367c478bd9Sstevel@tonic-gate * buf pages to free space; since kpages are saved in ascending order, 377c478bd9Sstevel@tonic-gate * any buf pages preceding the current statefile buffer offset can be 387c478bd9Sstevel@tonic-gate * written because those pages have already been read and restored 397c478bd9Sstevel@tonic-gate */ 407c478bd9Sstevel@tonic-gate static void 417c478bd9Sstevel@tonic-gate shuffle_pages(cpd_t *descp) 427c478bd9Sstevel@tonic-gate { 437c478bd9Sstevel@tonic-gate pfn_t low_src_ppn, dst_ppn, tail_ppn, new_ppn; 447c478bd9Sstevel@tonic-gate size_t dst_off; 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* 477c478bd9Sstevel@tonic-gate * set the lowest source buf ppn for the (precede) comparison 487c478bd9Sstevel@tonic-gate * below; the ORIG macro is used for the case where the src buf 497c478bd9Sstevel@tonic-gate * page had already been moved - and would confuse the compare 507c478bd9Sstevel@tonic-gate */ 517c478bd9Sstevel@tonic-gate low_src_ppn = SF_ORIG_PPN(sfile.buf_offset); 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate tail_ppn = descp->cpd_pfn + descp->cpd_pages; 547c478bd9Sstevel@tonic-gate for (dst_ppn = descp->cpd_pfn; dst_ppn < tail_ppn; dst_ppn++) { 557c478bd9Sstevel@tonic-gate /* 567c478bd9Sstevel@tonic-gate * if the dst page is outside the range of statefile 577c478bd9Sstevel@tonic-gate * buffer phys pages, it's OK to write that page; 587c478bd9Sstevel@tonic-gate * buf pages may have been moved outside the range, 597c478bd9Sstevel@tonic-gate * but only to locations isolated from any dst page 607c478bd9Sstevel@tonic-gate */ 617c478bd9Sstevel@tonic-gate if (dst_ppn < sfile.low_ppn || dst_ppn > sfile.high_ppn) { 627c478bd9Sstevel@tonic-gate SF_STAT_INC(outside); 637c478bd9Sstevel@tonic-gate continue; 647c478bd9Sstevel@tonic-gate } 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate /* 677c478bd9Sstevel@tonic-gate * the dst page is inside the range of buf ppns; 687c478bd9Sstevel@tonic-gate * dont need to move the buf page if the dst page 697c478bd9Sstevel@tonic-gate * precedes the lowest src buf page 707c478bd9Sstevel@tonic-gate */ 717c478bd9Sstevel@tonic-gate if (dst_ppn < low_src_ppn) { 727c478bd9Sstevel@tonic-gate SF_STAT_INC(precede); 737c478bd9Sstevel@tonic-gate continue; 747c478bd9Sstevel@tonic-gate } 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate /* 777c478bd9Sstevel@tonic-gate * the dst page clashes with the statefile buffer; 787c478bd9Sstevel@tonic-gate * move the buf page to a free location and update 797c478bd9Sstevel@tonic-gate * the buffer map 807c478bd9Sstevel@tonic-gate */ 817c478bd9Sstevel@tonic-gate new_ppn = find_apage(); 827c478bd9Sstevel@tonic-gate phys_xcopy(PN_TO_ADDR(dst_ppn), PN_TO_ADDR(new_ppn), 837c478bd9Sstevel@tonic-gate MMU_PAGESIZE); 847c478bd9Sstevel@tonic-gate dst_off = mmu_ptob(dst_ppn - sfile.low_ppn); 857c478bd9Sstevel@tonic-gate SF_BUF_PPN(dst_off) = new_ppn; 867c478bd9Sstevel@tonic-gate SF_STAT_INC(move); 877c478bd9Sstevel@tonic-gate } 887c478bd9Sstevel@tonic-gate } 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate * map-in source statefile buffer pages (read-only) at CB_SRC_VIRT; 937c478bd9Sstevel@tonic-gate * sets the starting source vaddr with correct page offset 947c478bd9Sstevel@tonic-gate */ 957c478bd9Sstevel@tonic-gate static void 967c478bd9Sstevel@tonic-gate mapin_buf_pages(size_t datalen, caddr_t *srcp) 977c478bd9Sstevel@tonic-gate { 987c478bd9Sstevel@tonic-gate int dtlb_index, pg_off; 997c478bd9Sstevel@tonic-gate caddr_t vaddr, tail; 1007c478bd9Sstevel@tonic-gate size_t off, bytes; 1017c478bd9Sstevel@tonic-gate pfn_t src_ppn; 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate dtlb_index = cb_dents - CB_MAX_KPAGES - 1; 1047c478bd9Sstevel@tonic-gate off = sfile.buf_offset; 1057c478bd9Sstevel@tonic-gate pg_off = off & MMU_PAGEOFFSET; 1067c478bd9Sstevel@tonic-gate bytes = PAGE_ROUNDUP(pg_off + datalen); 1077c478bd9Sstevel@tonic-gate vaddr = (caddr_t)CB_SRC_VIRT; 1087c478bd9Sstevel@tonic-gate *srcp = vaddr + pg_off; 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate for (tail = vaddr + bytes; vaddr < tail; vaddr += MMU_PAGESIZE) { 1117c478bd9Sstevel@tonic-gate src_ppn = SF_BUF_PPN(off); 1127c478bd9Sstevel@tonic-gate cb_mapin(vaddr, src_ppn, TTE8K, 0, dtlb_index); 1137c478bd9Sstevel@tonic-gate dtlb_index--; 1147c478bd9Sstevel@tonic-gate off += MMU_PAGESIZE; 1157c478bd9Sstevel@tonic-gate } 1167c478bd9Sstevel@tonic-gate } 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate /* 1207c478bd9Sstevel@tonic-gate * map-in destination kernel pages (read/write) at CB_DST_VIRT 1217c478bd9Sstevel@tonic-gate */ 1227c478bd9Sstevel@tonic-gate static void 1237c478bd9Sstevel@tonic-gate mapin_dst_pages(cpd_t *descp) 1247c478bd9Sstevel@tonic-gate { 1257c478bd9Sstevel@tonic-gate int dtlb_index, pages; 1267c478bd9Sstevel@tonic-gate caddr_t vaddr; 1277c478bd9Sstevel@tonic-gate pfn_t dst_ppn; 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate dtlb_index = cb_dents - 1; 1307c478bd9Sstevel@tonic-gate vaddr = (caddr_t)CB_DST_VIRT; 1317c478bd9Sstevel@tonic-gate dst_ppn = descp->cpd_pfn; 1327c478bd9Sstevel@tonic-gate for (pages = 0; pages < descp->cpd_pages; pages++) { 1337c478bd9Sstevel@tonic-gate cb_mapin(vaddr, dst_ppn, TTE8K, TTE_HWWR_INT, dtlb_index); 1347c478bd9Sstevel@tonic-gate dtlb_index--; 1357c478bd9Sstevel@tonic-gate vaddr += MMU_PAGESIZE; 1367c478bd9Sstevel@tonic-gate dst_ppn++; 1377c478bd9Sstevel@tonic-gate } 1387c478bd9Sstevel@tonic-gate } 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate /* 1427c478bd9Sstevel@tonic-gate * run a checksum on un/compressed data when flag is set 1437c478bd9Sstevel@tonic-gate */ 1447c478bd9Sstevel@tonic-gate static int 1457c478bd9Sstevel@tonic-gate kdata_cksum(void *data, cpd_t *descp, uint_t flag) 1467c478bd9Sstevel@tonic-gate { 1477c478bd9Sstevel@tonic-gate uint_t sum, expect; 1487c478bd9Sstevel@tonic-gate size_t len; 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate if ((descp->cpd_flag & flag) == 0) 1517c478bd9Sstevel@tonic-gate return (0); 1527c478bd9Sstevel@tonic-gate else if (flag == CPD_CSUM) { 1537c478bd9Sstevel@tonic-gate expect = descp->cpd_csum; 1547c478bd9Sstevel@tonic-gate len = descp->cpd_length; 1557c478bd9Sstevel@tonic-gate } else { 1567c478bd9Sstevel@tonic-gate expect = descp->cpd_usum; 1577c478bd9Sstevel@tonic-gate len = mmu_ptob(descp->cpd_pages); 1587c478bd9Sstevel@tonic-gate } 1597c478bd9Sstevel@tonic-gate sum = checksum32(data, len); 1607c478bd9Sstevel@tonic-gate if (sum != expect) { 1617c478bd9Sstevel@tonic-gate prom_printf("\n%scompressed data checksum error, " 1627c478bd9Sstevel@tonic-gate "expect 0x%x, got 0x%x\n", (flag == CPD_USUM) ? "un" : "", 1637c478bd9Sstevel@tonic-gate expect, sum); 1647c478bd9Sstevel@tonic-gate return (ERR); 1657c478bd9Sstevel@tonic-gate } 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate return (0); 1687c478bd9Sstevel@tonic-gate } 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate /* 1727c478bd9Sstevel@tonic-gate * primary kpage restoration routine 1737c478bd9Sstevel@tonic-gate */ 1747c478bd9Sstevel@tonic-gate static int 1757c478bd9Sstevel@tonic-gate restore_page_group(cpd_t *descp) 1767c478bd9Sstevel@tonic-gate { 1777c478bd9Sstevel@tonic-gate caddr_t dst, datap; 1787c478bd9Sstevel@tonic-gate size_t size, len; 1797c478bd9Sstevel@tonic-gate caddr_t src; 1807c478bd9Sstevel@tonic-gate int raw; 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate #if defined(lint) 1837c478bd9Sstevel@tonic-gate (void) compress(0, 0, 0); 1847c478bd9Sstevel@tonic-gate #endif 1857c478bd9Sstevel@tonic-gate 1867c478bd9Sstevel@tonic-gate /* 1877c478bd9Sstevel@tonic-gate * move any source buf pages that clash with dst kernel pages; 1887c478bd9Sstevel@tonic-gate * create tlb entries for the orig/new source buf pages and 1897c478bd9Sstevel@tonic-gate * the dst kpages 1907c478bd9Sstevel@tonic-gate */ 1917c478bd9Sstevel@tonic-gate shuffle_pages(descp); 1927c478bd9Sstevel@tonic-gate mapin_buf_pages(descp->cpd_length, &src); 1937c478bd9Sstevel@tonic-gate mapin_dst_pages(descp); 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate /* 1967c478bd9Sstevel@tonic-gate * for compressed pages, run a checksum at the src vaddr and 1977c478bd9Sstevel@tonic-gate * decompress to the mapped-in dst kpages; for uncompressed pages, 1987c478bd9Sstevel@tonic-gate * just copy direct; uncompressed checksums are used for either 1997c478bd9Sstevel@tonic-gate * uncompressed src data or decompressed result data 2007c478bd9Sstevel@tonic-gate */ 2017c478bd9Sstevel@tonic-gate dst = (caddr_t)CB_DST_VIRT; 2027c478bd9Sstevel@tonic-gate if (descp->cpd_flag & CPD_COMPRESS) { 2037c478bd9Sstevel@tonic-gate if (kdata_cksum(src, descp, CPD_CSUM)) 2047c478bd9Sstevel@tonic-gate return (ERR); 2057c478bd9Sstevel@tonic-gate size = mmu_ptob(descp->cpd_pages); 2067c478bd9Sstevel@tonic-gate len = decompress(src, dst, descp->cpd_length, size); 2077c478bd9Sstevel@tonic-gate if (len != size) { 20853391bafSeota prom_printf("\nbad decompressed len %lu, size %lu\n", 2097c478bd9Sstevel@tonic-gate len, size); 2107c478bd9Sstevel@tonic-gate return (ERR); 2117c478bd9Sstevel@tonic-gate } 2127c478bd9Sstevel@tonic-gate raw = 0; 2137c478bd9Sstevel@tonic-gate datap = dst; 2147c478bd9Sstevel@tonic-gate } else { 2157c478bd9Sstevel@tonic-gate raw = 1; 2167c478bd9Sstevel@tonic-gate datap = src; 2177c478bd9Sstevel@tonic-gate } 2187c478bd9Sstevel@tonic-gate if (kdata_cksum(datap, descp, CPD_USUM)) 2197c478bd9Sstevel@tonic-gate return (ERR); 2207c478bd9Sstevel@tonic-gate if (raw) 2217c478bd9Sstevel@tonic-gate bcopy(src, dst, descp->cpd_length); 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate /* 2247c478bd9Sstevel@tonic-gate * advance past the kdata for this cpd_t 2257c478bd9Sstevel@tonic-gate */ 2267c478bd9Sstevel@tonic-gate SF_ADV(descp->cpd_length); 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate return (0); 2297c478bd9Sstevel@tonic-gate } 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate 2327c478bd9Sstevel@tonic-gate /* 2337c478bd9Sstevel@tonic-gate * mapin part of the statefile buffer, copy to the virt destination, 2347c478bd9Sstevel@tonic-gate * and advance the statefile buffer offset. this is used primarily 2357c478bd9Sstevel@tonic-gate * to copy thousands of tiny cpd_t into aligned struct space. 2367c478bd9Sstevel@tonic-gate */ 2377c478bd9Sstevel@tonic-gate static void 2387c478bd9Sstevel@tonic-gate get_phys_data(void *vdst, size_t size) 2397c478bd9Sstevel@tonic-gate { 2407c478bd9Sstevel@tonic-gate caddr_t src; 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate mapin_buf_pages(size, &src); 2437c478bd9Sstevel@tonic-gate bcopy(src, vdst, size); 2447c478bd9Sstevel@tonic-gate SF_ADV(size); 2457c478bd9Sstevel@tonic-gate } 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate 2487c478bd9Sstevel@tonic-gate /* 2497c478bd9Sstevel@tonic-gate * clear leftover locked dtlb entries 2507c478bd9Sstevel@tonic-gate */ 2517c478bd9Sstevel@tonic-gate static void 2527c478bd9Sstevel@tonic-gate dtlb_cleanup(void) 2537c478bd9Sstevel@tonic-gate { 2547c478bd9Sstevel@tonic-gate int dtlb_index; 2557c478bd9Sstevel@tonic-gate caddr_t vaddr; 2567c478bd9Sstevel@tonic-gate tte_t tte; 2577c478bd9Sstevel@tonic-gate 2587c478bd9Sstevel@tonic-gate CB_VENTRY(dtlb_cleanup); 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate dtlb_index = cb_dents - CB_MAX_KPAGES - CB_MAX_BPAGES - 1; 2617c478bd9Sstevel@tonic-gate for (; dtlb_index < cb_dents; dtlb_index++) { 2627c478bd9Sstevel@tonic-gate get_dtlb_entry(dtlb_index, &vaddr, &tte); 2637c478bd9Sstevel@tonic-gate if (TTE_IS_LOCKED(&tte)) { 2647c478bd9Sstevel@tonic-gate tte.ll = 0; 2657c478bd9Sstevel@tonic-gate set_dtlb_entry(dtlb_index, (caddr_t)0, &tte); 2667c478bd9Sstevel@tonic-gate CB_VPRINTF((" cleared dtlb entry %x\n", dtlb_index)); 2677c478bd9Sstevel@tonic-gate } 2687c478bd9Sstevel@tonic-gate } 2697c478bd9Sstevel@tonic-gate } 2707c478bd9Sstevel@tonic-gate 2717c478bd9Sstevel@tonic-gate 2727c478bd9Sstevel@tonic-gate /* 2737c478bd9Sstevel@tonic-gate * before calling this routine, all cprboot phys pages 2747c478bd9Sstevel@tonic-gate * are isolated from kernel pages; now we can restore 2757c478bd9Sstevel@tonic-gate * kpages from the statefile buffer 2767c478bd9Sstevel@tonic-gate */ 2777c478bd9Sstevel@tonic-gate int 2787c478bd9Sstevel@tonic-gate cb_restore_kpages(void) 2797c478bd9Sstevel@tonic-gate { 2807c478bd9Sstevel@tonic-gate int npages, compressed, regular; 2817c478bd9Sstevel@tonic-gate cpd_t desc; 2827c478bd9Sstevel@tonic-gate char *str; 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate str = "cb_restore_kpages"; 2857c478bd9Sstevel@tonic-gate CB_VPRINTF((ent_fmt, str, entry)); 2867c478bd9Sstevel@tonic-gate 287*ae115bc7Smrj CPR_DEBUG(CPR_DEBUG1, "%s: restoring kpages... ", prog); 2887c478bd9Sstevel@tonic-gate npages = compressed = regular = 0; 2897c478bd9Sstevel@tonic-gate while (npages < sfile.kpages) { 2907c478bd9Sstevel@tonic-gate get_phys_data(&desc, sizeof (desc)); 2917c478bd9Sstevel@tonic-gate if (desc.cpd_magic != CPR_PAGE_MAGIC) { 2927c478bd9Sstevel@tonic-gate prom_printf("\nbad page magic 0x%x, expect 0x%x\n", 2937c478bd9Sstevel@tonic-gate desc.cpd_magic, CPR_PAGE_MAGIC); 2947c478bd9Sstevel@tonic-gate return (ERR); 2957c478bd9Sstevel@tonic-gate } 2967c478bd9Sstevel@tonic-gate if (restore_page_group(&desc)) 2977c478bd9Sstevel@tonic-gate return (ERR); 2987c478bd9Sstevel@tonic-gate npages += desc.cpd_pages; 2997c478bd9Sstevel@tonic-gate 3007c478bd9Sstevel@tonic-gate if (desc.cpd_flag & CPD_COMPRESS) 3017c478bd9Sstevel@tonic-gate compressed += desc.cpd_pages; 3027c478bd9Sstevel@tonic-gate else 3037c478bd9Sstevel@tonic-gate regular += desc.cpd_pages; 3047c478bd9Sstevel@tonic-gate 3057c478bd9Sstevel@tonic-gate /* 3067c478bd9Sstevel@tonic-gate * display a spin char for every 32 page groups 3077c478bd9Sstevel@tonic-gate * (a full spin <= each MB restored) 3087c478bd9Sstevel@tonic-gate */ 3097c478bd9Sstevel@tonic-gate if ((sfile.ngroups++ & 0x1f) == 0) 3107c478bd9Sstevel@tonic-gate cb_spin(); 3117c478bd9Sstevel@tonic-gate } 312*ae115bc7Smrj CPR_DEBUG(CPR_DEBUG1, " \b\n"); 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate dtlb_cleanup(); 3157c478bd9Sstevel@tonic-gate 3167c478bd9Sstevel@tonic-gate if (verbose) { 3177c478bd9Sstevel@tonic-gate prom_printf("\npage stats: total %d, outside %d, " 3187c478bd9Sstevel@tonic-gate "move %d, precede %d\n", sfile.kpages, sfile.outside, 3197c478bd9Sstevel@tonic-gate sfile.move, sfile.precede); 3207c478bd9Sstevel@tonic-gate prom_printf("page stats: ngroups %d, recycle %d\n", 3217c478bd9Sstevel@tonic-gate sfile.ngroups, sfile.recycle); 3227c478bd9Sstevel@tonic-gate } 3237c478bd9Sstevel@tonic-gate 324*ae115bc7Smrj CPR_DEBUG(CPR_DEBUG4, 3257c478bd9Sstevel@tonic-gate "%s: total=%d, npages=%d, compressed=%d, regular=%d\n", 326*ae115bc7Smrj str, sfile.kpages, npages, compressed, regular); 3277c478bd9Sstevel@tonic-gate 3287c478bd9Sstevel@tonic-gate /* 3297c478bd9Sstevel@tonic-gate * sanity check 3307c478bd9Sstevel@tonic-gate */ 3317c478bd9Sstevel@tonic-gate if (npages != sfile.kpages) { 3327c478bd9Sstevel@tonic-gate prom_printf("\n%s: page count mismatch, expect %d, got %d\n", 3337c478bd9Sstevel@tonic-gate str, sfile.kpages, npages); 3347c478bd9Sstevel@tonic-gate return (ERR); 3357c478bd9Sstevel@tonic-gate } 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate return (0); 3387c478bd9Sstevel@tonic-gate } 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate 3417c478bd9Sstevel@tonic-gate /* 3427c478bd9Sstevel@tonic-gate * check and update the statefile terminator; 3437c478bd9Sstevel@tonic-gate * on exit there will be a leftover tlb entry, 3447c478bd9Sstevel@tonic-gate * but it will soon get replaced by restore_tlb() 3457c478bd9Sstevel@tonic-gate */ 3467c478bd9Sstevel@tonic-gate int 3477c478bd9Sstevel@tonic-gate cb_terminator(void) 3487c478bd9Sstevel@tonic-gate { 3497c478bd9Sstevel@tonic-gate ctrm_t cterm; 3507c478bd9Sstevel@tonic-gate 3517c478bd9Sstevel@tonic-gate CB_VENTRY(cb_terminator); 3527c478bd9Sstevel@tonic-gate get_phys_data(&cterm, sizeof (cterm)); 3537c478bd9Sstevel@tonic-gate if (cterm.magic != CPR_TERM_MAGIC) { 3547c478bd9Sstevel@tonic-gate prom_printf("\nbad term magic 0x%x, expect 0x%x\n", 3557c478bd9Sstevel@tonic-gate cterm.magic, CPR_TERM_MAGIC); 3567c478bd9Sstevel@tonic-gate return (ERR); 3577c478bd9Sstevel@tonic-gate } 3587c478bd9Sstevel@tonic-gate cterm.tm_cprboot_start.tv_sec = cb_msec / 1000; 3597c478bd9Sstevel@tonic-gate cb_mapin((caddr_t)CB_DST_VIRT, cterm.pfn, 3607c478bd9Sstevel@tonic-gate TTE8K, TTE_HWWR_INT, cb_dents - 1); 3617c478bd9Sstevel@tonic-gate cpr_update_terminator(&cterm, (caddr_t)CB_DST_VIRT); 3627c478bd9Sstevel@tonic-gate return (0); 3637c478bd9Sstevel@tonic-gate } 364