···2526menu "General machine setup"2728-config VT29- bool30- select INPUT31- default y32- ---help---33- If you say Y here, you will get support for terminal devices with34- display and keyboard devices. These are called "virtual" because you35- can run several virtual terminals (also called virtual consoles) on36- one physical terminal. This is rather useful, for example one37- virtual terminal can collect system messages and warnings, another38- one can be used for a text-mode user session, and a third could run39- an X session, all in parallel. Switching between virtual terminals40- is done with certain key combinations, usually Alt-<function key>.41-42- The setterm command ("man setterm") can be used to change the43- properties (such as colors or beeping) of a virtual terminal. The44- man page console_codes(4) ("man console_codes") contains the special45- character sequences that can be used to change those properties46- directly. The fonts used on virtual terminals can be changed with47- the setfont ("man setfont") command and the key bindings are defined48- with the loadkeys ("man loadkeys") command.49-50- You need at least one virtual terminal device in order to make use51- of your keyboard and monitor. Therefore, only people configuring an52- embedded system would want to say N here in order to save some53- memory; the only way to log into such a system is then via a serial54- or network connection.55-56- If unsure, say Y, or else you won't be able to do much with your new57- shiny Linux system :-)58-59-config VT_CONSOLE60- bool61- default y62- ---help---63- The system console is the device which receives all kernel messages64- and warnings and which allows logins in single user mode. If you65- answer Y here, a virtual terminal (the device used to interact with66- a physical terminal) can be used as system console. This is the most67- common mode of operations, so you should say Y here unless you want68- the kernel messages be output only to a serial port (in which case69- you should say Y to "Console on serial port", below).70-71- If you do say Y here, by default the currently visible virtual72- terminal (/dev/tty0) will be used as system console. You can change73- that with a kernel command line option such as "console=tty3" which74- would use the third virtual terminal as system console. (Try "man75- bootparam" or see the documentation of your boot loader (lilo or76- loadlin) about how to pass options to the kernel at boot time.)77-78- If unsure, say Y.79-80-config HW_CONSOLE81- bool82- default y83-84config SMP85 bool "Symmetric multi-processing support (does not work on sun4/sun4c)"86 depends on BROKEN
···2526menu "General machine setup"270000000000000000000000000000000000000000000000000000000028config SMP29 bool "Symmetric multi-processing support (does not work on sun4/sun4c)"30 depends on BROKEN
···133134struct page *mem_map_zero __read_mostly;135000000136int bigkernel = 0;137138/* XXX Tune this... */···368 unsigned long data;369};370static struct linux_prom_translation prom_trans[512] __initdata;0371372extern unsigned long prom_boot_page;373extern void prom_remap(unsigned long physpage, unsigned long virtpage, int mmu_ihandle);···382unsigned long prom_pmd_phys __read_mostly;383unsigned int swapper_pgd_zero __read_mostly;384385-/* Allocate power-of-2 aligned chunks from the end of the386- * kernel image. Return physical address.387- */388-static inline unsigned long early_alloc_phys(unsigned long size)389-{390- unsigned long base;391-392- BUILD_BUG_ON(size & (size - 1));393-394- kern_size = (kern_size + (size - 1)) & ~(size - 1);395- base = kern_base + kern_size;396- kern_size += size;397-398- return base;399-}400-401-static inline unsigned long load_phys32(unsigned long pa)402-{403- unsigned long val;404-405- __asm__ __volatile__("lduwa [%1] %2, %0"406- : "=&r" (val)407- : "r" (pa), "i" (ASI_PHYS_USE_EC));408-409- return val;410-}411-412-static inline unsigned long load_phys64(unsigned long pa)413-{414- unsigned long val;415-416- __asm__ __volatile__("ldxa [%1] %2, %0"417- : "=&r" (val)418- : "r" (pa), "i" (ASI_PHYS_USE_EC));419-420- return val;421-}422-423-static inline void store_phys32(unsigned long pa, unsigned long val)424-{425- __asm__ __volatile__("stwa %0, [%1] %2"426- : /* no outputs */427- : "r" (val), "r" (pa), "i" (ASI_PHYS_USE_EC));428-}429-430-static inline void store_phys64(unsigned long pa, unsigned long val)431-{432- __asm__ __volatile__("stxa %0, [%1] %2"433- : /* no outputs */434- : "r" (val), "r" (pa), "i" (ASI_PHYS_USE_EC));435-}436437#define BASE_PAGE_SIZE 8192438···392 */393unsigned long prom_virt_to_phys(unsigned long promva, int *error)394{395- unsigned long pmd_phys = (prom_pmd_phys +396- ((promva >> 23) & 0x7ff) * sizeof(pmd_t));397- unsigned long pte_phys;398- pmd_t pmd_ent;399- pte_t pte_ent;400 unsigned long base;401402- pmd_val(pmd_ent) = load_phys32(pmd_phys);403- if (pmd_none(pmd_ent)) {404 if (error)405 *error = 1;406 return 0;407 }408-409- pte_phys = (unsigned long)pmd_val(pmd_ent) << 11UL;410- pte_phys += ((promva >> 13) & 0x3ff) * sizeof(pte_t);411- pte_val(pte_ent) = load_phys64(pte_phys);412- if (!pte_present(pte_ent)) {413 if (error)414 *error = 1;415 return 0;416 }417 if (error) {418 *error = 0;419- return pte_val(pte_ent);420 }421- base = pte_val(pte_ent) & _PAGE_PADDR;422- return (base + (promva & (BASE_PAGE_SIZE - 1)));0423}424425/* The obp translations are saved based on 8k pagesize, since obp can···426 unsigned long vaddr;427428 for (vaddr = start; vaddr < end; vaddr += BASE_PAGE_SIZE) {429- unsigned long val, pte_phys, pmd_phys;430- pmd_t pmd_ent;431- int i;432433- pmd_phys = (prom_pmd_phys +434- (((vaddr >> 23) & 0x7ff) * sizeof(pmd_t)));435- pmd_val(pmd_ent) = load_phys32(pmd_phys);436- if (pmd_none(pmd_ent)) {437- pte_phys = early_alloc_phys(BASE_PAGE_SIZE);438-439- for (i = 0; i < BASE_PAGE_SIZE / sizeof(pte_t); i++)440- store_phys64(pte_phys+i*sizeof(pte_t),0);441-442- pmd_val(pmd_ent) = pte_phys >> 11UL;443- store_phys32(pmd_phys, pmd_val(pmd_ent));444 }445-446- pte_phys = (unsigned long)pmd_val(pmd_ent) << 11UL;447- pte_phys += (((vaddr >> 13) & 0x3ff) * sizeof(pte_t));448449 val = data;450···447 if (tlb_type == spitfire)448 val &= ~0x0003fe0000000000UL;449450- store_phys64(pte_phys, val | _PAGE_MODIFIED);0451452 data += BASE_PAGE_SIZE;453 }···461}462463#define OBP_PMD_SIZE 2048464-static void __init build_obp_pgtable(int prom_trans_ents)465{466 unsigned long i;467468- prom_pmd_phys = early_alloc_phys(OBP_PMD_SIZE);469- for (i = 0; i < OBP_PMD_SIZE; i += 4)470- store_phys32(prom_pmd_phys + i, 0);0000471472 for (i = 0; i < prom_trans_ents; i++) {473 unsigned long start, end;···491/* Read OBP translations property into 'prom_trans[]'.492 * Return the number of entries.493 */494-static int __init read_obp_translations(void)495{496 int n, node;497···512 prom_printf("prom_mappings: Couldn't get property.\n");513 prom_halt();514 }0515 n = n / sizeof(struct linux_prom_translation);516- return n;0517}518519static void __init remap_kernel(void)···535 prom_dtlb_load(tlb_ent, tte_data, tte_vaddr);536 prom_itlb_load(tlb_ent, tte_data, tte_vaddr);537 if (bigkernel) {538- prom_dtlb_load(tlb_ent - 1,0539 tte_data + 0x400000, 540 tte_vaddr + 0x400000);541- prom_itlb_load(tlb_ent - 1,542 tte_data + 0x400000, 543 tte_vaddr + 0x400000);544 }0000000545}546547-static void __init inherit_prom_mappings(void)548-{549- int n;550551- n = read_obp_translations();552- build_obp_pgtable(n);0553554 /* Now fixup OBP's idea about where we really are mapped. */555 prom_printf("Remapping the kernel... ");556 remap_kernel();557558 prom_printf("done.\n");0559000560 register_prom_callbacks();561}562···751 }752 }753 if (tlb_type == spitfire) {754- int high = SPITFIRE_HIGHEST_LOCKED_TLBENT - bigkernel;755- for (i = 0; i < high; i++) {756 unsigned long data;757758 /* Spitfire Errata #32 workaround */···840 }841 }842 } else if (tlb_type == cheetah || tlb_type == cheetah_plus) {843- int high = CHEETAH_HIGHEST_LOCKED_TLBENT - bigkernel;844845- for (i = 0; i < high; i++) {846 unsigned long data;847848 data = cheetah_get_ldtlb_data(i);···15191520 swapper_pgd_zero = pgd_val(swapper_pg_dir[0]);15211522- /* Inherit non-locked OBP mappings. */1523- inherit_prom_mappings();15241525 /* Ok, we can use our TLB miss and window trap handlers safely.1526 * We need to do a quick peek here to see if we are on StarFire···1530 extern void setup_tba(int);1531 setup_tba(this_is_starfire);1532 }1533-1534- inherit_locked_prom_mappings(1);1535-1536 __flush_tlb_all();000000015371538 /* Setup bootmem... */1539 pages_avail = 0;1540 last_valid_pfn = end_pfn = bootmem_init(&pages_avail);000015411542#ifdef CONFIG_DEBUG_PAGEALLOC1543 kernel_physical_mapping_init();
···133134struct page *mem_map_zero __read_mostly;135136+unsigned int sparc64_highest_unlocked_tlb_ent __read_mostly;137+138+unsigned long sparc64_kern_pri_context __read_mostly;139+unsigned long sparc64_kern_pri_nuc_bits __read_mostly;140+unsigned long sparc64_kern_sec_context __read_mostly;141+142int bigkernel = 0;143144/* XXX Tune this... */···362 unsigned long data;363};364static struct linux_prom_translation prom_trans[512] __initdata;365+static unsigned int prom_trans_ents __initdata;366367extern unsigned long prom_boot_page;368extern void prom_remap(unsigned long physpage, unsigned long virtpage, int mmu_ihandle);···375unsigned long prom_pmd_phys __read_mostly;376unsigned int swapper_pgd_zero __read_mostly;377378+static pmd_t *prompmd __read_mostly;00000000000000000000000000000000000000000000000000379380#define BASE_PAGE_SIZE 8192381···435 */436unsigned long prom_virt_to_phys(unsigned long promva, int *error)437{438+ pmd_t *pmdp = prompmd + ((promva >> 23) & 0x7ff);439+ pte_t *ptep;000440 unsigned long base;441442+ if (pmd_none(*pmdp)) {0443 if (error)444 *error = 1;445 return 0;446 }447+ ptep = (pte_t *)__pmd_page(*pmdp) + ((promva >> 13) & 0x3ff);448+ if (!pte_present(*ptep)) {000449 if (error)450 *error = 1;451 return 0;452 }453 if (error) {454 *error = 0;455+ return pte_val(*ptep);456 }457+ base = pte_val(*ptep) & _PAGE_PADDR;458+459+ return base + (promva & (BASE_PAGE_SIZE - 1));460}461462/* The obp translations are saved based on 8k pagesize, since obp can···475 unsigned long vaddr;476477 for (vaddr = start; vaddr < end; vaddr += BASE_PAGE_SIZE) {478+ unsigned long val;479+ pmd_t *pmd;480+ pte_t *pte;481482+ pmd = prompmd + ((vaddr >> 23) & 0x7ff);483+ if (pmd_none(*pmd)) {484+ pte = __alloc_bootmem(BASE_PAGE_SIZE, BASE_PAGE_SIZE,485+ PAGE_SIZE);486+ if (!pte)487+ prom_halt();488+ memset(pte, 0, BASE_PAGE_SIZE);489+ pmd_set(pmd, pte);000490 }491+ pte = (pte_t *) __pmd_page(*pmd) + ((vaddr >> 13) & 0x3ff);00492493 val = data;494···501 if (tlb_type == spitfire)502 val &= ~0x0003fe0000000000UL;503504+ set_pte_at(&init_mm, vaddr, pte,505+ __pte(val | _PAGE_MODIFIED));506507 data += BASE_PAGE_SIZE;508 }···514}515516#define OBP_PMD_SIZE 2048517+static void __init build_obp_pgtable(void)518{519 unsigned long i;520521+ prompmd = __alloc_bootmem(OBP_PMD_SIZE, OBP_PMD_SIZE, PAGE_SIZE);522+ if (!prompmd)523+ prom_halt();524+525+ memset(prompmd, 0, OBP_PMD_SIZE);526+527+ prom_pmd_phys = __pa(prompmd);528529 for (i = 0; i < prom_trans_ents; i++) {530 unsigned long start, end;···540/* Read OBP translations property into 'prom_trans[]'.541 * Return the number of entries.542 */543+static void __init read_obp_translations(void)544{545 int n, node;546···561 prom_printf("prom_mappings: Couldn't get property.\n");562 prom_halt();563 }564+565 n = n / sizeof(struct linux_prom_translation);566+567+ prom_trans_ents = n;568}569570static void __init remap_kernel(void)···582 prom_dtlb_load(tlb_ent, tte_data, tte_vaddr);583 prom_itlb_load(tlb_ent, tte_data, tte_vaddr);584 if (bigkernel) {585+ tlb_ent -= 1;586+ prom_dtlb_load(tlb_ent,587 tte_data + 0x400000, 588 tte_vaddr + 0x400000);589+ prom_itlb_load(tlb_ent,590 tte_data + 0x400000, 591 tte_vaddr + 0x400000);592 }593+ sparc64_highest_unlocked_tlb_ent = tlb_ent - 1;594+ if (tlb_type == cheetah_plus) {595+ sparc64_kern_pri_context = (CTX_CHEETAH_PLUS_CTX0 |596+ CTX_CHEETAH_PLUS_NUC);597+ sparc64_kern_pri_nuc_bits = CTX_CHEETAH_PLUS_NUC;598+ sparc64_kern_sec_context = CTX_CHEETAH_PLUS_CTX0;599+ }600}601000602603+static void __init inherit_prom_mappings_pre(void)604+{605+ read_obp_translations();606607 /* Now fixup OBP's idea about where we really are mapped. */608 prom_printf("Remapping the kernel... ");609 remap_kernel();610611 prom_printf("done.\n");612+}613614+static void __init inherit_prom_mappings_post(void)615+{616+ build_obp_pgtable();617 register_prom_callbacks();618}619···788 }789 }790 if (tlb_type == spitfire) {791+ int high = sparc64_highest_unlocked_tlb_ent;792+ for (i = 0; i <= high; i++) {793 unsigned long data;794795 /* Spitfire Errata #32 workaround */···877 }878 }879 } else if (tlb_type == cheetah || tlb_type == cheetah_plus) {880+ int high = sparc64_highest_unlocked_tlb_ent;881882+ for (i = 0; i <= high; i++) {883 unsigned long data;884885 data = cheetah_get_ldtlb_data(i);···15561557 swapper_pgd_zero = pgd_val(swapper_pg_dir[0]);15581559+ inherit_prom_mappings_pre();015601561 /* Ok, we can use our TLB miss and window trap handlers safely.1562 * We need to do a quick peek here to see if we are on StarFire···1568 extern void setup_tba(int);1569 setup_tba(this_is_starfire);1570 }0001571 __flush_tlb_all();1572+1573+ /* Everything from this point forward, until we are done with1574+ * inherit_prom_mappings_post(), must complete successfully1575+ * without calling into the firmware. The firwmare page tables1576+ * have not been built, but we are running on the Linux kernel's1577+ * trap table.1578+ */15791580 /* Setup bootmem... */1581 pages_avail = 0;1582 last_valid_pfn = end_pfn = bootmem_init(&pages_avail);1583+1584+ inherit_prom_mappings_post();1585+1586+ inherit_locked_prom_mappings(1);15871588#ifdef CONFIG_DEBUG_PAGEALLOC1589 kernel_physical_mapping_init();