setup.c 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515
  1. /*
  2. * linux/arch/alpha/kernel/setup.c
  3. *
  4. * Copyright (C) 1995 Linus Torvalds
  5. */
  6. /* 2.3.x bootmem, 1999 Andrea Arcangeli <andrea@suse.de> */
  7. /*
  8. * Bootup setup stuff.
  9. */
  10. #include <linux/sched.h>
  11. #include <linux/kernel.h>
  12. #include <linux/mm.h>
  13. #include <linux/stddef.h>
  14. #include <linux/unistd.h>
  15. #include <linux/ptrace.h>
  16. #include <linux/slab.h>
  17. #include <linux/user.h>
  18. #include <linux/a.out.h>
  19. #include <linux/tty.h>
  20. #include <linux/delay.h>
  21. #include <linux/config.h> /* CONFIG_ALPHA_LCA etc */
  22. #include <linux/mc146818rtc.h>
  23. #include <linux/console.h>
  24. #include <linux/cpu.h>
  25. #include <linux/errno.h>
  26. #include <linux/init.h>
  27. #include <linux/string.h>
  28. #include <linux/ioport.h>
  29. #include <linux/platform_device.h>
  30. #include <linux/bootmem.h>
  31. #include <linux/pci.h>
  32. #include <linux/seq_file.h>
  33. #include <linux/root_dev.h>
  34. #include <linux/initrd.h>
  35. #include <linux/eisa.h>
  36. #include <linux/pfn.h>
  37. #ifdef CONFIG_MAGIC_SYSRQ
  38. #include <linux/sysrq.h>
  39. #include <linux/reboot.h>
  40. #endif
  41. #include <linux/notifier.h>
  42. #include <asm/setup.h>
  43. #include <asm/io.h>
  44. extern struct atomic_notifier_head panic_notifier_list;
  45. static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
  46. static struct notifier_block alpha_panic_block = {
  47. alpha_panic_event,
  48. NULL,
  49. INT_MAX /* try to do it first */
  50. };
  51. #include <asm/uaccess.h>
  52. #include <asm/pgtable.h>
  53. #include <asm/system.h>
  54. #include <asm/hwrpb.h>
  55. #include <asm/dma.h>
  56. #include <asm/io.h>
  57. #include <asm/mmu_context.h>
  58. #include <asm/console.h>
  59. #include "proto.h"
  60. #include "pci_impl.h"
  61. struct hwrpb_struct *hwrpb;
  62. unsigned long srm_hae;
  63. int alpha_l1i_cacheshape;
  64. int alpha_l1d_cacheshape;
  65. int alpha_l2_cacheshape;
  66. int alpha_l3_cacheshape;
  67. #ifdef CONFIG_VERBOSE_MCHECK
  68. /* 0=minimum, 1=verbose, 2=all */
  69. /* These can be overridden via the command line, ie "verbose_mcheck=2") */
  70. unsigned long alpha_verbose_mcheck = CONFIG_VERBOSE_MCHECK_ON;
  71. #endif
  72. /* Which processor we booted from. */
  73. int boot_cpuid;
  74. /*
  75. * Using SRM callbacks for initial console output. This works from
  76. * setup_arch() time through the end of time_init(), as those places
  77. * are under our (Alpha) control.
  78. * "srmcons" specified in the boot command arguments allows us to
  79. * see kernel messages during the period of time before the true
  80. * console device is "registered" during console_init().
  81. * As of this version (2.5.59), console_init() will call
  82. * disable_early_printk() as the last action before initializing
  83. * the console drivers. That's the last possible time srmcons can be
  84. * unregistered without interfering with console behavior.
  85. *
  86. * By default, OFF; set it with a bootcommand arg of "srmcons" or
  87. * "console=srm". The meaning of these two args is:
  88. * "srmcons" - early callback prints
  89. * "console=srm" - full callback based console, including early prints
  90. */
  91. int srmcons_output = 0;
  92. /* Enforce a memory size limit; useful for testing. By default, none. */
  93. unsigned long mem_size_limit = 0;
  94. /* Set AGP GART window size (0 means disabled). */
  95. unsigned long alpha_agpgart_size = DEFAULT_AGP_APER_SIZE;
  96. #ifdef CONFIG_ALPHA_GENERIC
  97. struct alpha_machine_vector alpha_mv;
  98. int alpha_using_srm;
  99. #endif
  100. #define N(a) (sizeof(a)/sizeof(a[0]))
  101. static struct alpha_machine_vector *get_sysvec(unsigned long, unsigned long,
  102. unsigned long);
  103. static struct alpha_machine_vector *get_sysvec_byname(const char *);
  104. static void get_sysnames(unsigned long, unsigned long, unsigned long,
  105. char **, char **);
  106. static void determine_cpu_caches (unsigned int);
  107. static char command_line[COMMAND_LINE_SIZE];
  108. /*
  109. * The format of "screen_info" is strange, and due to early
  110. * i386-setup code. This is just enough to make the console
  111. * code think we're on a VGA color display.
  112. */
  113. struct screen_info screen_info = {
  114. .orig_x = 0,
  115. .orig_y = 25,
  116. .orig_video_cols = 80,
  117. .orig_video_lines = 25,
  118. .orig_video_isVGA = 1,
  119. .orig_video_points = 16
  120. };
  121. /*
  122. * The direct map I/O window, if any. This should be the same
  123. * for all busses, since it's used by virt_to_bus.
  124. */
  125. unsigned long __direct_map_base;
  126. unsigned long __direct_map_size;
  127. /*
  128. * Declare all of the machine vectors.
  129. */
  130. /* GCC 2.7.2 (on alpha at least) is lame. It does not support either
  131. __attribute__((weak)) or #pragma weak. Bypass it and talk directly
  132. to the assembler. */
  133. #define WEAK(X) \
  134. extern struct alpha_machine_vector X; \
  135. asm(".weak "#X)
  136. WEAK(alcor_mv);
  137. WEAK(alphabook1_mv);
  138. WEAK(avanti_mv);
  139. WEAK(cabriolet_mv);
  140. WEAK(clipper_mv);
  141. WEAK(dp264_mv);
  142. WEAK(eb164_mv);
  143. WEAK(eb64p_mv);
  144. WEAK(eb66_mv);
  145. WEAK(eb66p_mv);
  146. WEAK(eiger_mv);
  147. WEAK(jensen_mv);
  148. WEAK(lx164_mv);
  149. WEAK(lynx_mv);
  150. WEAK(marvel_ev7_mv);
  151. WEAK(miata_mv);
  152. WEAK(mikasa_mv);
  153. WEAK(mikasa_primo_mv);
  154. WEAK(monet_mv);
  155. WEAK(nautilus_mv);
  156. WEAK(noname_mv);
  157. WEAK(noritake_mv);
  158. WEAK(noritake_primo_mv);
  159. WEAK(p2k_mv);
  160. WEAK(pc164_mv);
  161. WEAK(privateer_mv);
  162. WEAK(rawhide_mv);
  163. WEAK(ruffian_mv);
  164. WEAK(rx164_mv);
  165. WEAK(sable_mv);
  166. WEAK(sable_gamma_mv);
  167. WEAK(shark_mv);
  168. WEAK(sx164_mv);
  169. WEAK(takara_mv);
  170. WEAK(titan_mv);
  171. WEAK(webbrick_mv);
  172. WEAK(wildfire_mv);
  173. WEAK(xl_mv);
  174. WEAK(xlt_mv);
  175. #undef WEAK
  176. /*
  177. * I/O resources inherited from PeeCees. Except for perhaps the
  178. * turbochannel alphas, everyone has these on some sort of SuperIO chip.
  179. *
  180. * ??? If this becomes less standard, move the struct out into the
  181. * machine vector.
  182. */
  183. static void __init
  184. reserve_std_resources(void)
  185. {
  186. static struct resource standard_io_resources[] = {
  187. { .name = "rtc", .start = -1, .end = -1 },
  188. { .name = "dma1", .start = 0x00, .end = 0x1f },
  189. { .name = "pic1", .start = 0x20, .end = 0x3f },
  190. { .name = "timer", .start = 0x40, .end = 0x5f },
  191. { .name = "keyboard", .start = 0x60, .end = 0x6f },
  192. { .name = "dma page reg", .start = 0x80, .end = 0x8f },
  193. { .name = "pic2", .start = 0xa0, .end = 0xbf },
  194. { .name = "dma2", .start = 0xc0, .end = 0xdf },
  195. };
  196. struct resource *io = &ioport_resource;
  197. size_t i;
  198. if (hose_head) {
  199. struct pci_controller *hose;
  200. for (hose = hose_head; hose; hose = hose->next)
  201. if (hose->index == 0) {
  202. io = hose->io_space;
  203. break;
  204. }
  205. }
  206. /* Fix up for the Jensen's queer RTC placement. */
  207. standard_io_resources[0].start = RTC_PORT(0);
  208. standard_io_resources[0].end = RTC_PORT(0) + 0x10;
  209. for (i = 0; i < N(standard_io_resources); ++i)
  210. request_resource(io, standard_io_resources+i);
  211. }
  212. #define PFN_MAX PFN_DOWN(0x80000000)
  213. #define for_each_mem_cluster(memdesc, cluster, i) \
  214. for ((cluster) = (memdesc)->cluster, (i) = 0; \
  215. (i) < (memdesc)->numclusters; (i)++, (cluster)++)
  216. static unsigned long __init
  217. get_mem_size_limit(char *s)
  218. {
  219. unsigned long end = 0;
  220. char *from = s;
  221. end = simple_strtoul(from, &from, 0);
  222. if ( *from == 'K' || *from == 'k' ) {
  223. end = end << 10;
  224. from++;
  225. } else if ( *from == 'M' || *from == 'm' ) {
  226. end = end << 20;
  227. from++;
  228. } else if ( *from == 'G' || *from == 'g' ) {
  229. end = end << 30;
  230. from++;
  231. }
  232. return end >> PAGE_SHIFT; /* Return the PFN of the limit. */
  233. }
  234. #ifdef CONFIG_BLK_DEV_INITRD
  235. void * __init
  236. move_initrd(unsigned long mem_limit)
  237. {
  238. void *start;
  239. unsigned long size;
  240. size = initrd_end - initrd_start;
  241. start = __alloc_bootmem(PAGE_ALIGN(size), PAGE_SIZE, 0);
  242. if (!start || __pa(start) + size > mem_limit) {
  243. initrd_start = initrd_end = 0;
  244. return NULL;
  245. }
  246. memmove(start, (void *)initrd_start, size);
  247. initrd_start = (unsigned long)start;
  248. initrd_end = initrd_start + size;
  249. printk("initrd moved to %p\n", start);
  250. return start;
  251. }
  252. #endif
  253. #ifndef CONFIG_DISCONTIGMEM
  254. static void __init
  255. setup_memory(void *kernel_end)
  256. {
  257. struct memclust_struct * cluster;
  258. struct memdesc_struct * memdesc;
  259. unsigned long start_kernel_pfn, end_kernel_pfn;
  260. unsigned long bootmap_size, bootmap_pages, bootmap_start;
  261. unsigned long start, end;
  262. unsigned long i;
  263. /* Find free clusters, and init and free the bootmem accordingly. */
  264. memdesc = (struct memdesc_struct *)
  265. (hwrpb->mddt_offset + (unsigned long) hwrpb);
  266. for_each_mem_cluster(memdesc, cluster, i) {
  267. printk("memcluster %lu, usage %01lx, start %8lu, end %8lu\n",
  268. i, cluster->usage, cluster->start_pfn,
  269. cluster->start_pfn + cluster->numpages);
  270. /* Bit 0 is console/PALcode reserved. Bit 1 is
  271. non-volatile memory -- we might want to mark
  272. this for later. */
  273. if (cluster->usage & 3)
  274. continue;
  275. end = cluster->start_pfn + cluster->numpages;
  276. if (end > max_low_pfn)
  277. max_low_pfn = end;
  278. }
  279. /*
  280. * Except for the NUMA systems (wildfire, marvel) all of the
  281. * Alpha systems we run on support 32GB of memory or less.
  282. * Since the NUMA systems introduce large holes in memory addressing,
  283. * we can get into a situation where there is not enough contiguous
  284. * memory for the memory map.
  285. *
  286. * Limit memory to the first 32GB to limit the NUMA systems to
  287. * memory on their first node (wildfire) or 2 (marvel) to avoid
  288. * not being able to produce the memory map. In order to access
  289. * all of the memory on the NUMA systems, build with discontiguous
  290. * memory support.
  291. *
  292. * If the user specified a memory limit, let that memory limit stand.
  293. */
  294. if (!mem_size_limit)
  295. mem_size_limit = (32ul * 1024 * 1024 * 1024) >> PAGE_SHIFT;
  296. if (mem_size_limit && max_low_pfn >= mem_size_limit)
  297. {
  298. printk("setup: forcing memory size to %ldK (from %ldK).\n",
  299. mem_size_limit << (PAGE_SHIFT - 10),
  300. max_low_pfn << (PAGE_SHIFT - 10));
  301. max_low_pfn = mem_size_limit;
  302. }
  303. /* Find the bounds of kernel memory. */
  304. start_kernel_pfn = PFN_DOWN(KERNEL_START_PHYS);
  305. end_kernel_pfn = PFN_UP(virt_to_phys(kernel_end));
  306. bootmap_start = -1;
  307. try_again:
  308. if (max_low_pfn <= end_kernel_pfn)
  309. panic("not enough memory to boot");
  310. /* We need to know how many physically contiguous pages
  311. we'll need for the bootmap. */
  312. bootmap_pages = bootmem_bootmap_pages(max_low_pfn);
  313. /* Now find a good region where to allocate the bootmap. */
  314. for_each_mem_cluster(memdesc, cluster, i) {
  315. if (cluster->usage & 3)
  316. continue;
  317. start = cluster->start_pfn;
  318. end = start + cluster->numpages;
  319. if (start >= max_low_pfn)
  320. continue;
  321. if (end > max_low_pfn)
  322. end = max_low_pfn;
  323. if (start < start_kernel_pfn) {
  324. if (end > end_kernel_pfn
  325. && end - end_kernel_pfn >= bootmap_pages) {
  326. bootmap_start = end_kernel_pfn;
  327. break;
  328. } else if (end > start_kernel_pfn)
  329. end = start_kernel_pfn;
  330. } else if (start < end_kernel_pfn)
  331. start = end_kernel_pfn;
  332. if (end - start >= bootmap_pages) {
  333. bootmap_start = start;
  334. break;
  335. }
  336. }
  337. if (bootmap_start == ~0UL) {
  338. max_low_pfn >>= 1;
  339. goto try_again;
  340. }
  341. /* Allocate the bootmap and mark the whole MM as reserved. */
  342. bootmap_size = init_bootmem(bootmap_start, max_low_pfn);
  343. /* Mark the free regions. */
  344. for_each_mem_cluster(memdesc, cluster, i) {
  345. if (cluster->usage & 3)
  346. continue;
  347. start = cluster->start_pfn;
  348. end = cluster->start_pfn + cluster->numpages;
  349. if (start >= max_low_pfn)
  350. continue;
  351. if (end > max_low_pfn)
  352. end = max_low_pfn;
  353. if (start < start_kernel_pfn) {
  354. if (end > end_kernel_pfn) {
  355. free_bootmem(PFN_PHYS(start),
  356. (PFN_PHYS(start_kernel_pfn)
  357. - PFN_PHYS(start)));
  358. printk("freeing pages %ld:%ld\n",
  359. start, start_kernel_pfn);
  360. start = end_kernel_pfn;
  361. } else if (end > start_kernel_pfn)
  362. end = start_kernel_pfn;
  363. } else if (start < end_kernel_pfn)
  364. start = end_kernel_pfn;
  365. if (start >= end)
  366. continue;
  367. free_bootmem(PFN_PHYS(start), PFN_PHYS(end) - PFN_PHYS(start));
  368. printk("freeing pages %ld:%ld\n", start, end);
  369. }
  370. /* Reserve the bootmap memory. */
  371. reserve_bootmem(PFN_PHYS(bootmap_start), bootmap_size);
  372. printk("reserving pages %ld:%ld\n", bootmap_start, bootmap_start+PFN_UP(bootmap_size));
  373. #ifdef CONFIG_BLK_DEV_INITRD
  374. initrd_start = INITRD_START;
  375. if (initrd_start) {
  376. initrd_end = initrd_start+INITRD_SIZE;
  377. printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
  378. (void *) initrd_start, INITRD_SIZE);
  379. if ((void *)initrd_end > phys_to_virt(PFN_PHYS(max_low_pfn))) {
  380. if (!move_initrd(PFN_PHYS(max_low_pfn)))
  381. printk("initrd extends beyond end of memory "
  382. "(0x%08lx > 0x%p)\ndisabling initrd\n",
  383. initrd_end,
  384. phys_to_virt(PFN_PHYS(max_low_pfn)));
  385. } else {
  386. reserve_bootmem(virt_to_phys((void *)initrd_start),
  387. INITRD_SIZE);
  388. }
  389. }
  390. #endif /* CONFIG_BLK_DEV_INITRD */
  391. }
  392. #else
  393. extern void setup_memory(void *);
  394. #endif /* !CONFIG_DISCONTIGMEM */
  395. int __init
  396. page_is_ram(unsigned long pfn)
  397. {
  398. struct memclust_struct * cluster;
  399. struct memdesc_struct * memdesc;
  400. unsigned long i;
  401. memdesc = (struct memdesc_struct *)
  402. (hwrpb->mddt_offset + (unsigned long) hwrpb);
  403. for_each_mem_cluster(memdesc, cluster, i)
  404. {
  405. if (pfn >= cluster->start_pfn &&
  406. pfn < cluster->start_pfn + cluster->numpages) {
  407. return (cluster->usage & 3) ? 0 : 1;
  408. }
  409. }
  410. return 0;
  411. }
  412. static int __init
  413. register_cpus(void)
  414. {
  415. int i;
  416. for_each_possible_cpu(i) {
  417. struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
  418. if (!p)
  419. return -ENOMEM;
  420. register_cpu(p, i, NULL);
  421. }
  422. return 0;
  423. }
  424. arch_initcall(register_cpus);
  425. void __init
  426. setup_arch(char **cmdline_p)
  427. {
  428. extern char _end[];
  429. struct alpha_machine_vector *vec = NULL;
  430. struct percpu_struct *cpu;
  431. char *type_name, *var_name, *p;
  432. void *kernel_end = _end; /* end of kernel */
  433. char *args = command_line;
  434. hwrpb = (struct hwrpb_struct*) __va(INIT_HWRPB->phys_addr);
  435. boot_cpuid = hard_smp_processor_id();
  436. /*
  437. * Pre-process the system type to make sure it will be valid.
  438. *
  439. * This may restore real CABRIO and EB66+ family names, ie
  440. * EB64+ and EB66.
  441. *
  442. * Oh, and "white box" AS800 (aka DIGITAL Server 3000 series)
  443. * and AS1200 (DIGITAL Server 5000 series) have the type as
  444. * the negative of the real one.
  445. */
  446. if ((long)hwrpb->sys_type < 0) {
  447. hwrpb->sys_type = -((long)hwrpb->sys_type);
  448. hwrpb_update_checksum(hwrpb);
  449. }
  450. /* Register a call for panic conditions. */
  451. atomic_notifier_chain_register(&panic_notifier_list,
  452. &alpha_panic_block);
  453. #ifdef CONFIG_ALPHA_GENERIC
  454. /* Assume that we've booted from SRM if we haven't booted from MILO.
  455. Detect the later by looking for "MILO" in the system serial nr. */
  456. alpha_using_srm = strncmp((const char *)hwrpb->ssn, "MILO", 4) != 0;
  457. #endif
  458. /* If we are using SRM, we want to allow callbacks
  459. as early as possible, so do this NOW, and then
  460. they should work immediately thereafter.
  461. */
  462. kernel_end = callback_init(kernel_end);
  463. /*
  464. * Locate the command line.
  465. */
  466. /* Hack for Jensen... since we're restricted to 8 or 16 chars for
  467. boot flags depending on the boot mode, we need some shorthand.
  468. This should do for installation. */
  469. if (strcmp(COMMAND_LINE, "INSTALL") == 0) {
  470. strlcpy(command_line, "root=/dev/fd0 load_ramdisk=1", sizeof command_line);
  471. } else {
  472. strlcpy(command_line, COMMAND_LINE, sizeof command_line);
  473. }
  474. strcpy(saved_command_line, command_line);
  475. *cmdline_p = command_line;
  476. /*
  477. * Process command-line arguments.
  478. */
  479. while ((p = strsep(&args, " \t")) != NULL) {
  480. if (!*p) continue;
  481. if (strncmp(p, "alpha_mv=", 9) == 0) {
  482. vec = get_sysvec_byname(p+9);
  483. continue;
  484. }
  485. if (strncmp(p, "cycle=", 6) == 0) {
  486. est_cycle_freq = simple_strtol(p+6, NULL, 0);
  487. continue;
  488. }
  489. if (strncmp(p, "mem=", 4) == 0) {
  490. mem_size_limit = get_mem_size_limit(p+4);
  491. continue;
  492. }
  493. if (strncmp(p, "srmcons", 7) == 0) {
  494. srmcons_output |= 1;
  495. continue;
  496. }
  497. if (strncmp(p, "console=srm", 11) == 0) {
  498. srmcons_output |= 2;
  499. continue;
  500. }
  501. if (strncmp(p, "gartsize=", 9) == 0) {
  502. alpha_agpgart_size =
  503. get_mem_size_limit(p+9) << PAGE_SHIFT;
  504. continue;
  505. }
  506. #ifdef CONFIG_VERBOSE_MCHECK
  507. if (strncmp(p, "verbose_mcheck=", 15) == 0) {
  508. alpha_verbose_mcheck = simple_strtol(p+15, NULL, 0);
  509. continue;
  510. }
  511. #endif
  512. }
  513. /* Replace the command line, now that we've killed it with strsep. */
  514. strcpy(command_line, saved_command_line);
  515. /* If we want SRM console printk echoing early, do it now. */
  516. if (alpha_using_srm && srmcons_output) {
  517. register_srm_console();
  518. /*
  519. * If "console=srm" was specified, clear the srmcons_output
  520. * flag now so that time.c won't unregister_srm_console
  521. */
  522. if (srmcons_output & 2)
  523. srmcons_output = 0;
  524. }
  525. #ifdef CONFIG_MAGIC_SYSRQ
  526. /* If we're using SRM, make sysrq-b halt back to the prom,
  527. not auto-reboot. */
  528. if (alpha_using_srm) {
  529. struct sysrq_key_op *op = __sysrq_get_key_op('b');
  530. op->handler = (void *) machine_halt;
  531. }
  532. #endif
  533. /*
  534. * Identify and reconfigure for the current system.
  535. */
  536. cpu = (struct percpu_struct*)((char*)hwrpb + hwrpb->processor_offset);
  537. get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
  538. cpu->type, &type_name, &var_name);
  539. if (*var_name == '0')
  540. var_name = "";
  541. if (!vec) {
  542. vec = get_sysvec(hwrpb->sys_type, hwrpb->sys_variation,
  543. cpu->type);
  544. }
  545. if (!vec) {
  546. panic("Unsupported system type: %s%s%s (%ld %ld)\n",
  547. type_name, (*var_name ? " variation " : ""), var_name,
  548. hwrpb->sys_type, hwrpb->sys_variation);
  549. }
  550. if (vec != &alpha_mv) {
  551. alpha_mv = *vec;
  552. }
  553. printk("Booting "
  554. #ifdef CONFIG_ALPHA_GENERIC
  555. "GENERIC "
  556. #endif
  557. "on %s%s%s using machine vector %s from %s\n",
  558. type_name, (*var_name ? " variation " : ""),
  559. var_name, alpha_mv.vector_name,
  560. (alpha_using_srm ? "SRM" : "MILO"));
  561. printk("Major Options: "
  562. #ifdef CONFIG_SMP
  563. "SMP "
  564. #endif
  565. #ifdef CONFIG_ALPHA_EV56
  566. "EV56 "
  567. #endif
  568. #ifdef CONFIG_ALPHA_EV67
  569. "EV67 "
  570. #endif
  571. #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
  572. "LEGACY_START "
  573. #endif
  574. #ifdef CONFIG_VERBOSE_MCHECK
  575. "VERBOSE_MCHECK "
  576. #endif
  577. #ifdef CONFIG_DISCONTIGMEM
  578. "DISCONTIGMEM "
  579. #ifdef CONFIG_NUMA
  580. "NUMA "
  581. #endif
  582. #endif
  583. #ifdef CONFIG_DEBUG_SPINLOCK
  584. "DEBUG_SPINLOCK "
  585. #endif
  586. #ifdef CONFIG_MAGIC_SYSRQ
  587. "MAGIC_SYSRQ "
  588. #endif
  589. "\n");
  590. printk("Command line: %s\n", command_line);
  591. /*
  592. * Sync up the HAE.
  593. * Save the SRM's current value for restoration.
  594. */
  595. srm_hae = *alpha_mv.hae_register;
  596. __set_hae(alpha_mv.hae_cache);
  597. /* Reset enable correctable error reports. */
  598. wrmces(0x7);
  599. /* Find our memory. */
  600. setup_memory(kernel_end);
  601. /* First guess at cpu cache sizes. Do this before init_arch. */
  602. determine_cpu_caches(cpu->type);
  603. /* Initialize the machine. Usually has to do with setting up
  604. DMA windows and the like. */
  605. if (alpha_mv.init_arch)
  606. alpha_mv.init_arch();
  607. /* Reserve standard resources. */
  608. reserve_std_resources();
  609. /*
  610. * Give us a default console. TGA users will see nothing until
  611. * chr_dev_init is called, rather late in the boot sequence.
  612. */
  613. #ifdef CONFIG_VT
  614. #if defined(CONFIG_VGA_CONSOLE)
  615. conswitchp = &vga_con;
  616. #elif defined(CONFIG_DUMMY_CONSOLE)
  617. conswitchp = &dummy_con;
  618. #endif
  619. #endif
  620. /* Default root filesystem to sda2. */
  621. ROOT_DEV = Root_SDA2;
  622. #ifdef CONFIG_EISA
  623. /* FIXME: only set this when we actually have EISA in this box? */
  624. EISA_bus = 1;
  625. #endif
  626. /*
  627. * Check ASN in HWRPB for validity, report if bad.
  628. * FIXME: how was this failing? Should we trust it instead,
  629. * and copy the value into alpha_mv.max_asn?
  630. */
  631. if (hwrpb->max_asn != MAX_ASN) {
  632. printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb->max_asn);
  633. }
  634. /*
  635. * Identify the flock of penguins.
  636. */
  637. #ifdef CONFIG_SMP
  638. setup_smp();
  639. #endif
  640. paging_init();
  641. }
  642. void __init
  643. disable_early_printk(void)
  644. {
  645. if (alpha_using_srm && srmcons_output) {
  646. unregister_srm_console();
  647. srmcons_output = 0;
  648. }
  649. }
  650. static char sys_unknown[] = "Unknown";
  651. static char systype_names[][16] = {
  652. "0",
  653. "ADU", "Cobra", "Ruby", "Flamingo", "Mannequin", "Jensen",
  654. "Pelican", "Morgan", "Sable", "Medulla", "Noname",
  655. "Turbolaser", "Avanti", "Mustang", "Alcor", "Tradewind",
  656. "Mikasa", "EB64", "EB66", "EB64+", "AlphaBook1",
  657. "Rawhide", "K2", "Lynx", "XL", "EB164", "Noritake",
  658. "Cortex", "29", "Miata", "XXM", "Takara", "Yukon",
  659. "Tsunami", "Wildfire", "CUSCO", "Eiger", "Titan", "Marvel"
  660. };
  661. static char unofficial_names[][8] = {"100", "Ruffian"};
  662. static char api_names[][16] = {"200", "Nautilus"};
  663. static char eb164_names[][8] = {"EB164", "PC164", "LX164", "SX164", "RX164"};
  664. static int eb164_indices[] = {0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,4};
  665. static char alcor_names[][16] = {"Alcor", "Maverick", "Bret"};
  666. static int alcor_indices[] = {0,0,0,1,1,1,0,0,0,0,0,0,2,2,2,2,2,2};
  667. static char eb64p_names[][16] = {"EB64+", "Cabriolet", "AlphaPCI64"};
  668. static int eb64p_indices[] = {0,0,1,2};
  669. static char eb66_names[][8] = {"EB66", "EB66+"};
  670. static int eb66_indices[] = {0,0,1};
  671. static char marvel_names[][16] = {
  672. "Marvel/EV7"
  673. };
  674. static int marvel_indices[] = { 0 };
  675. static char rawhide_names[][16] = {
  676. "Dodge", "Wrangler", "Durango", "Tincup", "DaVinci"
  677. };
  678. static int rawhide_indices[] = {0,0,0,1,1,2,2,3,3,4,4};
  679. static char titan_names[][16] = {
  680. "DEFAULT", "Privateer", "Falcon", "Granite"
  681. };
  682. static int titan_indices[] = {0,1,2,2,3};
  683. static char tsunami_names[][16] = {
  684. "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper",
  685. "Goldrush", "Webbrick", "Catamaran", "Brisbane", "Melbourne",
  686. "Flying Clipper", "Shark"
  687. };
  688. static int tsunami_indices[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
  689. static struct alpha_machine_vector * __init
  690. get_sysvec(unsigned long type, unsigned long variation, unsigned long cpu)
  691. {
  692. static struct alpha_machine_vector *systype_vecs[] __initdata =
  693. {
  694. NULL, /* 0 */
  695. NULL, /* ADU */
  696. NULL, /* Cobra */
  697. NULL, /* Ruby */
  698. NULL, /* Flamingo */
  699. NULL, /* Mannequin */
  700. &jensen_mv,
  701. NULL, /* Pelican */
  702. NULL, /* Morgan */
  703. NULL, /* Sable -- see below. */
  704. NULL, /* Medulla */
  705. &noname_mv,
  706. NULL, /* Turbolaser */
  707. &avanti_mv,
  708. NULL, /* Mustang */
  709. NULL, /* Alcor, Bret, Maverick. HWRPB inaccurate? */
  710. NULL, /* Tradewind */
  711. NULL, /* Mikasa -- see below. */
  712. NULL, /* EB64 */
  713. NULL, /* EB66 -- see variation. */
  714. NULL, /* EB64+ -- see variation. */
  715. &alphabook1_mv,
  716. &rawhide_mv,
  717. NULL, /* K2 */
  718. &lynx_mv, /* Lynx */
  719. &xl_mv,
  720. NULL, /* EB164 -- see variation. */
  721. NULL, /* Noritake -- see below. */
  722. NULL, /* Cortex */
  723. NULL, /* 29 */
  724. &miata_mv,
  725. NULL, /* XXM */
  726. &takara_mv,
  727. NULL, /* Yukon */
  728. NULL, /* Tsunami -- see variation. */
  729. &wildfire_mv, /* Wildfire */
  730. NULL, /* CUSCO */
  731. &eiger_mv, /* Eiger */
  732. NULL, /* Titan */
  733. NULL, /* Marvel */
  734. };
  735. static struct alpha_machine_vector *unofficial_vecs[] __initdata =
  736. {
  737. NULL, /* 100 */
  738. &ruffian_mv,
  739. };
  740. static struct alpha_machine_vector *api_vecs[] __initdata =
  741. {
  742. NULL, /* 200 */
  743. &nautilus_mv,
  744. };
  745. static struct alpha_machine_vector *alcor_vecs[] __initdata =
  746. {
  747. &alcor_mv, &xlt_mv, &xlt_mv
  748. };
  749. static struct alpha_machine_vector *eb164_vecs[] __initdata =
  750. {
  751. &eb164_mv, &pc164_mv, &lx164_mv, &sx164_mv, &rx164_mv
  752. };
  753. static struct alpha_machine_vector *eb64p_vecs[] __initdata =
  754. {
  755. &eb64p_mv,
  756. &cabriolet_mv,
  757. &cabriolet_mv /* AlphaPCI64 */
  758. };
  759. static struct alpha_machine_vector *eb66_vecs[] __initdata =
  760. {
  761. &eb66_mv,
  762. &eb66p_mv
  763. };
  764. static struct alpha_machine_vector *marvel_vecs[] __initdata =
  765. {
  766. &marvel_ev7_mv,
  767. };
  768. static struct alpha_machine_vector *titan_vecs[] __initdata =
  769. {
  770. &titan_mv, /* default */
  771. &privateer_mv, /* privateer */
  772. &titan_mv, /* falcon */
  773. &privateer_mv, /* granite */
  774. };
  775. static struct alpha_machine_vector *tsunami_vecs[] __initdata =
  776. {
  777. NULL,
  778. &dp264_mv, /* dp264 */
  779. &dp264_mv, /* warhol */
  780. &dp264_mv, /* windjammer */
  781. &monet_mv, /* monet */
  782. &clipper_mv, /* clipper */
  783. &dp264_mv, /* goldrush */
  784. &webbrick_mv, /* webbrick */
  785. &dp264_mv, /* catamaran */
  786. NULL, /* brisbane? */
  787. NULL, /* melbourne? */
  788. NULL, /* flying clipper? */
  789. &shark_mv, /* shark */
  790. };
  791. /* ??? Do we need to distinguish between Rawhides? */
  792. struct alpha_machine_vector *vec;
  793. /* Search the system tables first... */
  794. vec = NULL;
  795. if (type < N(systype_vecs)) {
  796. vec = systype_vecs[type];
  797. } else if ((type > ST_API_BIAS) &&
  798. (type - ST_API_BIAS) < N(api_vecs)) {
  799. vec = api_vecs[type - ST_API_BIAS];
  800. } else if ((type > ST_UNOFFICIAL_BIAS) &&
  801. (type - ST_UNOFFICIAL_BIAS) < N(unofficial_vecs)) {
  802. vec = unofficial_vecs[type - ST_UNOFFICIAL_BIAS];
  803. }
  804. /* If we've not found one, try for a variation. */
  805. if (!vec) {
  806. /* Member ID is a bit-field. */
  807. unsigned long member = (variation >> 10) & 0x3f;
  808. cpu &= 0xffffffff; /* make it usable */
  809. switch (type) {
  810. case ST_DEC_ALCOR:
  811. if (member < N(alcor_indices))
  812. vec = alcor_vecs[alcor_indices[member]];
  813. break;
  814. case ST_DEC_EB164:
  815. if (member < N(eb164_indices))
  816. vec = eb164_vecs[eb164_indices[member]];
  817. /* PC164 may show as EB164 variation with EV56 CPU,
  818. but, since no true EB164 had anything but EV5... */
  819. if (vec == &eb164_mv && cpu == EV56_CPU)
  820. vec = &pc164_mv;
  821. break;
  822. case ST_DEC_EB64P:
  823. if (member < N(eb64p_indices))
  824. vec = eb64p_vecs[eb64p_indices[member]];
  825. break;
  826. case ST_DEC_EB66:
  827. if (member < N(eb66_indices))
  828. vec = eb66_vecs[eb66_indices[member]];
  829. break;
  830. case ST_DEC_MARVEL:
  831. if (member < N(marvel_indices))
  832. vec = marvel_vecs[marvel_indices[member]];
  833. break;
  834. case ST_DEC_TITAN:
  835. vec = titan_vecs[0]; /* default */
  836. if (member < N(titan_indices))
  837. vec = titan_vecs[titan_indices[member]];
  838. break;
  839. case ST_DEC_TSUNAMI:
  840. if (member < N(tsunami_indices))
  841. vec = tsunami_vecs[tsunami_indices[member]];
  842. break;
  843. case ST_DEC_1000:
  844. if (cpu == EV5_CPU || cpu == EV56_CPU)
  845. vec = &mikasa_primo_mv;
  846. else
  847. vec = &mikasa_mv;
  848. break;
  849. case ST_DEC_NORITAKE:
  850. if (cpu == EV5_CPU || cpu == EV56_CPU)
  851. vec = &noritake_primo_mv;
  852. else
  853. vec = &noritake_mv;
  854. break;
  855. case ST_DEC_2100_A500:
  856. if (cpu == EV5_CPU || cpu == EV56_CPU)
  857. vec = &sable_gamma_mv;
  858. else
  859. vec = &sable_mv;
  860. break;
  861. }
  862. }
  863. return vec;
  864. }
  865. static struct alpha_machine_vector * __init
  866. get_sysvec_byname(const char *name)
  867. {
  868. static struct alpha_machine_vector *all_vecs[] __initdata =
  869. {
  870. &alcor_mv,
  871. &alphabook1_mv,
  872. &avanti_mv,
  873. &cabriolet_mv,
  874. &clipper_mv,
  875. &dp264_mv,
  876. &eb164_mv,
  877. &eb64p_mv,
  878. &eb66_mv,
  879. &eb66p_mv,
  880. &eiger_mv,
  881. &jensen_mv,
  882. &lx164_mv,
  883. &lynx_mv,
  884. &miata_mv,
  885. &mikasa_mv,
  886. &mikasa_primo_mv,
  887. &monet_mv,
  888. &nautilus_mv,
  889. &noname_mv,
  890. &noritake_mv,
  891. &noritake_primo_mv,
  892. &p2k_mv,
  893. &pc164_mv,
  894. &privateer_mv,
  895. &rawhide_mv,
  896. &ruffian_mv,
  897. &rx164_mv,
  898. &sable_mv,
  899. &sable_gamma_mv,
  900. &shark_mv,
  901. &sx164_mv,
  902. &takara_mv,
  903. &webbrick_mv,
  904. &wildfire_mv,
  905. &xl_mv,
  906. &xlt_mv
  907. };
  908. size_t i;
  909. for (i = 0; i < N(all_vecs); ++i) {
  910. struct alpha_machine_vector *mv = all_vecs[i];
  911. if (strcasecmp(mv->vector_name, name) == 0)
  912. return mv;
  913. }
  914. return NULL;
  915. }
  916. static void
  917. get_sysnames(unsigned long type, unsigned long variation, unsigned long cpu,
  918. char **type_name, char **variation_name)
  919. {
  920. unsigned long member;
  921. /* If not in the tables, make it UNKNOWN,
  922. else set type name to family */
  923. if (type < N(systype_names)) {
  924. *type_name = systype_names[type];
  925. } else if ((type > ST_API_BIAS) &&
  926. (type - ST_API_BIAS) < N(api_names)) {
  927. *type_name = api_names[type - ST_API_BIAS];
  928. } else if ((type > ST_UNOFFICIAL_BIAS) &&
  929. (type - ST_UNOFFICIAL_BIAS) < N(unofficial_names)) {
  930. *type_name = unofficial_names[type - ST_UNOFFICIAL_BIAS];
  931. } else {
  932. *type_name = sys_unknown;
  933. *variation_name = sys_unknown;
  934. return;
  935. }
  936. /* Set variation to "0"; if variation is zero, done. */
  937. *variation_name = systype_names[0];
  938. if (variation == 0) {
  939. return;
  940. }
  941. member = (variation >> 10) & 0x3f; /* member ID is a bit-field */
  942. cpu &= 0xffffffff; /* make it usable */
  943. switch (type) { /* select by family */
  944. default: /* default to variation "0" for now */
  945. break;
  946. case ST_DEC_EB164:
  947. if (member < N(eb164_indices))
  948. *variation_name = eb164_names[eb164_indices[member]];
  949. /* PC164 may show as EB164 variation, but with EV56 CPU,
  950. so, since no true EB164 had anything but EV5... */
  951. if (eb164_indices[member] == 0 && cpu == EV56_CPU)
  952. *variation_name = eb164_names[1]; /* make it PC164 */
  953. break;
  954. case ST_DEC_ALCOR:
  955. if (member < N(alcor_indices))
  956. *variation_name = alcor_names[alcor_indices[member]];
  957. break;
  958. case ST_DEC_EB64P:
  959. if (member < N(eb64p_indices))
  960. *variation_name = eb64p_names[eb64p_indices[member]];
  961. break;
  962. case ST_DEC_EB66:
  963. if (member < N(eb66_indices))
  964. *variation_name = eb66_names[eb66_indices[member]];
  965. break;
  966. case ST_DEC_MARVEL:
  967. if (member < N(marvel_indices))
  968. *variation_name = marvel_names[marvel_indices[member]];
  969. break;
  970. case ST_DEC_RAWHIDE:
  971. if (member < N(rawhide_indices))
  972. *variation_name = rawhide_names[rawhide_indices[member]];
  973. break;
  974. case ST_DEC_TITAN:
  975. *variation_name = titan_names[0]; /* default */
  976. if (member < N(titan_indices))
  977. *variation_name = titan_names[titan_indices[member]];
  978. break;
  979. case ST_DEC_TSUNAMI:
  980. if (member < N(tsunami_indices))
  981. *variation_name = tsunami_names[tsunami_indices[member]];
  982. break;
  983. }
  984. }
  985. /*
  986. * A change was made to the HWRPB via an ECO and the following code
  987. * tracks a part of the ECO. In HWRPB versions less than 5, the ECO
  988. * was not implemented in the console firmware. If it's revision 5 or
  989. * greater we can get the name of the platform as an ASCII string from
  990. * the HWRPB. That's what this function does. It checks the revision
  991. * level and if the string is in the HWRPB it returns the address of
  992. * the string--a pointer to the name of the platform.
  993. *
  994. * Returns:
  995. * - Pointer to a ASCII string if it's in the HWRPB
  996. * - Pointer to a blank string if the data is not in the HWRPB.
  997. */
  998. static char *
  999. platform_string(void)
  1000. {
  1001. struct dsr_struct *dsr;
  1002. static char unk_system_string[] = "N/A";
  1003. /* Go to the console for the string pointer.
  1004. * If the rpb_vers is not 5 or greater the rpb
  1005. * is old and does not have this data in it.
  1006. */
  1007. if (hwrpb->revision < 5)
  1008. return (unk_system_string);
  1009. else {
  1010. /* The Dynamic System Recognition struct
  1011. * has the system platform name starting
  1012. * after the character count of the string.
  1013. */
  1014. dsr = ((struct dsr_struct *)
  1015. ((char *)hwrpb + hwrpb->dsr_offset));
  1016. return ((char *)dsr + (dsr->sysname_off +
  1017. sizeof(long)));
  1018. }
  1019. }
  1020. static int
  1021. get_nr_processors(struct percpu_struct *cpubase, unsigned long num)
  1022. {
  1023. struct percpu_struct *cpu;
  1024. unsigned long i;
  1025. int count = 0;
  1026. for (i = 0; i < num; i++) {
  1027. cpu = (struct percpu_struct *)
  1028. ((char *)cpubase + i*hwrpb->processor_size);
  1029. if ((cpu->flags & 0x1cc) == 0x1cc)
  1030. count++;
  1031. }
  1032. return count;
  1033. }
  1034. static void
  1035. show_cache_size (struct seq_file *f, const char *which, int shape)
  1036. {
  1037. if (shape == -1)
  1038. seq_printf (f, "%s\t\t: n/a\n", which);
  1039. else if (shape == 0)
  1040. seq_printf (f, "%s\t\t: unknown\n", which);
  1041. else
  1042. seq_printf (f, "%s\t\t: %dK, %d-way, %db line\n",
  1043. which, shape >> 10, shape & 15,
  1044. 1 << ((shape >> 4) & 15));
  1045. }
  1046. static int
  1047. show_cpuinfo(struct seq_file *f, void *slot)
  1048. {
  1049. extern struct unaligned_stat {
  1050. unsigned long count, va, pc;
  1051. } unaligned[2];
  1052. static char cpu_names[][8] = {
  1053. "EV3", "EV4", "Simulate", "LCA4", "EV5", "EV45", "EV56",
  1054. "EV6", "PCA56", "PCA57", "EV67", "EV68CB", "EV68AL",
  1055. "EV68CX", "EV7", "EV79", "EV69"
  1056. };
  1057. struct percpu_struct *cpu = slot;
  1058. unsigned int cpu_index;
  1059. char *cpu_name;
  1060. char *systype_name;
  1061. char *sysvariation_name;
  1062. int nr_processors;
  1063. cpu_index = (unsigned) (cpu->type - 1);
  1064. cpu_name = "Unknown";
  1065. if (cpu_index < N(cpu_names))
  1066. cpu_name = cpu_names[cpu_index];
  1067. get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
  1068. cpu->type, &systype_name, &sysvariation_name);
  1069. nr_processors = get_nr_processors(cpu, hwrpb->nr_processors);
  1070. seq_printf(f, "cpu\t\t\t: Alpha\n"
  1071. "cpu model\t\t: %s\n"
  1072. "cpu variation\t\t: %ld\n"
  1073. "cpu revision\t\t: %ld\n"
  1074. "cpu serial number\t: %s\n"
  1075. "system type\t\t: %s\n"
  1076. "system variation\t: %s\n"
  1077. "system revision\t\t: %ld\n"
  1078. "system serial number\t: %s\n"
  1079. "cycle frequency [Hz]\t: %lu %s\n"
  1080. "timer frequency [Hz]\t: %lu.%02lu\n"
  1081. "page size [bytes]\t: %ld\n"
  1082. "phys. address bits\t: %ld\n"
  1083. "max. addr. space #\t: %ld\n"
  1084. "BogoMIPS\t\t: %lu.%02lu\n"
  1085. "kernel unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
  1086. "user unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
  1087. "platform string\t\t: %s\n"
  1088. "cpus detected\t\t: %d\n",
  1089. cpu_name, cpu->variation, cpu->revision,
  1090. (char*)cpu->serial_no,
  1091. systype_name, sysvariation_name, hwrpb->sys_revision,
  1092. (char*)hwrpb->ssn,
  1093. est_cycle_freq ? : hwrpb->cycle_freq,
  1094. est_cycle_freq ? "est." : "",
  1095. hwrpb->intr_freq / 4096,
  1096. (100 * hwrpb->intr_freq / 4096) % 100,
  1097. hwrpb->pagesize,
  1098. hwrpb->pa_bits,
  1099. hwrpb->max_asn,
  1100. loops_per_jiffy / (500000/HZ),
  1101. (loops_per_jiffy / (5000/HZ)) % 100,
  1102. unaligned[0].count, unaligned[0].pc, unaligned[0].va,
  1103. unaligned[1].count, unaligned[1].pc, unaligned[1].va,
  1104. platform_string(), nr_processors);
  1105. #ifdef CONFIG_SMP
  1106. seq_printf(f, "cpus active\t\t: %d\n"
  1107. "cpu active mask\t\t: %016lx\n",
  1108. num_online_cpus(), cpus_addr(cpu_possible_map)[0]);
  1109. #endif
  1110. show_cache_size (f, "L1 Icache", alpha_l1i_cacheshape);
  1111. show_cache_size (f, "L1 Dcache", alpha_l1d_cacheshape);
  1112. show_cache_size (f, "L2 cache", alpha_l2_cacheshape);
  1113. show_cache_size (f, "L3 cache", alpha_l3_cacheshape);
  1114. return 0;
  1115. }
  1116. static int __init
  1117. read_mem_block(int *addr, int stride, int size)
  1118. {
  1119. long nloads = size / stride, cnt, tmp;
  1120. __asm__ __volatile__(
  1121. " rpcc %0\n"
  1122. "1: ldl %3,0(%2)\n"
  1123. " subq %1,1,%1\n"
  1124. /* Next two XORs introduce an explicit data dependency between
  1125. consecutive loads in the loop, which will give us true load
  1126. latency. */
  1127. " xor %3,%2,%2\n"
  1128. " xor %3,%2,%2\n"
  1129. " addq %2,%4,%2\n"
  1130. " bne %1,1b\n"
  1131. " rpcc %3\n"
  1132. " subl %3,%0,%0\n"
  1133. : "=&r" (cnt), "=&r" (nloads), "=&r" (addr), "=&r" (tmp)
  1134. : "r" (stride), "1" (nloads), "2" (addr));
  1135. return cnt / (size / stride);
  1136. }
  1137. #define CSHAPE(totalsize, linesize, assoc) \
  1138. ((totalsize & ~0xff) | (linesize << 4) | assoc)
  1139. /* ??? EV5 supports up to 64M, but did the systems with more than
  1140. 16M of BCACHE ever exist? */
  1141. #define MAX_BCACHE_SIZE 16*1024*1024
  1142. /* Note that the offchip caches are direct mapped on all Alphas. */
  1143. static int __init
  1144. external_cache_probe(int minsize, int width)
  1145. {
  1146. int cycles, prev_cycles = 1000000;
  1147. int stride = 1 << width;
  1148. long size = minsize, maxsize = MAX_BCACHE_SIZE * 2;
  1149. if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
  1150. maxsize = 1 << (floor_log2(max_low_pfn + 1) + PAGE_SHIFT);
  1151. /* Get the first block cached. */
  1152. read_mem_block(__va(0), stride, size);
  1153. while (size < maxsize) {
  1154. /* Get an average load latency in cycles. */
  1155. cycles = read_mem_block(__va(0), stride, size);
  1156. if (cycles > prev_cycles * 2) {
  1157. /* Fine, we exceed the cache. */
  1158. printk("%ldK Bcache detected; load hit latency %d "
  1159. "cycles, load miss latency %d cycles\n",
  1160. size >> 11, prev_cycles, cycles);
  1161. return CSHAPE(size >> 1, width, 1);
  1162. }
  1163. /* Try to get the next block cached. */
  1164. read_mem_block(__va(size), stride, size);
  1165. prev_cycles = cycles;
  1166. size <<= 1;
  1167. }
  1168. return -1; /* No BCACHE found. */
  1169. }
  1170. static void __init
  1171. determine_cpu_caches (unsigned int cpu_type)
  1172. {
  1173. int L1I, L1D, L2, L3;
  1174. switch (cpu_type) {
  1175. case EV4_CPU:
  1176. case EV45_CPU:
  1177. {
  1178. if (cpu_type == EV4_CPU)
  1179. L1I = CSHAPE(8*1024, 5, 1);
  1180. else
  1181. L1I = CSHAPE(16*1024, 5, 1);
  1182. L1D = L1I;
  1183. L3 = -1;
  1184. /* BIU_CTL is a write-only Abox register. PALcode has a
  1185. shadow copy, and may be available from some versions
  1186. of the CSERVE PALcall. If we can get it, then
  1187. unsigned long biu_ctl, size;
  1188. size = 128*1024 * (1 << ((biu_ctl >> 28) & 7));
  1189. L2 = CSHAPE (size, 5, 1);
  1190. Unfortunately, we can't rely on that.
  1191. */
  1192. L2 = external_cache_probe(128*1024, 5);
  1193. break;
  1194. }
  1195. case LCA4_CPU:
  1196. {
  1197. unsigned long car, size;
  1198. L1I = L1D = CSHAPE(8*1024, 5, 1);
  1199. L3 = -1;
  1200. car = *(vuip) phys_to_virt (0x120000078UL);
  1201. size = 64*1024 * (1 << ((car >> 5) & 7));
  1202. /* No typo -- 8 byte cacheline size. Whodathunk. */
  1203. L2 = (car & 1 ? CSHAPE (size, 3, 1) : -1);
  1204. break;
  1205. }
  1206. case EV5_CPU:
  1207. case EV56_CPU:
  1208. {
  1209. unsigned long sc_ctl, width;
  1210. L1I = L1D = CSHAPE(8*1024, 5, 1);
  1211. /* Check the line size of the Scache. */
  1212. sc_ctl = *(vulp) phys_to_virt (0xfffff000a8UL);
  1213. width = sc_ctl & 0x1000 ? 6 : 5;
  1214. L2 = CSHAPE (96*1024, width, 3);
  1215. /* BC_CONTROL and BC_CONFIG are write-only IPRs. PALcode
  1216. has a shadow copy, and may be available from some versions
  1217. of the CSERVE PALcall. If we can get it, then
  1218. unsigned long bc_control, bc_config, size;
  1219. size = 1024*1024 * (1 << ((bc_config & 7) - 1));
  1220. L3 = (bc_control & 1 ? CSHAPE (size, width, 1) : -1);
  1221. Unfortunately, we can't rely on that.
  1222. */
  1223. L3 = external_cache_probe(1024*1024, width);
  1224. break;
  1225. }
  1226. case PCA56_CPU:
  1227. case PCA57_CPU:
  1228. {
  1229. unsigned long cbox_config, size;
  1230. if (cpu_type == PCA56_CPU) {
  1231. L1I = CSHAPE(16*1024, 6, 1);
  1232. L1D = CSHAPE(8*1024, 5, 1);
  1233. } else {
  1234. L1I = CSHAPE(32*1024, 6, 2);
  1235. L1D = CSHAPE(16*1024, 5, 1);
  1236. }
  1237. L3 = -1;
  1238. cbox_config = *(vulp) phys_to_virt (0xfffff00008UL);
  1239. size = 512*1024 * (1 << ((cbox_config >> 12) & 3));
  1240. #if 0
  1241. L2 = ((cbox_config >> 31) & 1 ? CSHAPE (size, 6, 1) : -1);
  1242. #else
  1243. L2 = external_cache_probe(512*1024, 6);
  1244. #endif
  1245. break;
  1246. }
  1247. case EV6_CPU:
  1248. case EV67_CPU:
  1249. case EV68CB_CPU:
  1250. case EV68AL_CPU:
  1251. case EV68CX_CPU:
  1252. case EV69_CPU:
  1253. L1I = L1D = CSHAPE(64*1024, 6, 2);
  1254. L2 = external_cache_probe(1024*1024, 6);
  1255. L3 = -1;
  1256. break;
  1257. case EV7_CPU:
  1258. case EV79_CPU:
  1259. L1I = L1D = CSHAPE(64*1024, 6, 2);
  1260. L2 = CSHAPE(7*1024*1024/4, 6, 7);
  1261. L3 = -1;
  1262. break;
  1263. default:
  1264. /* Nothing known about this cpu type. */
  1265. L1I = L1D = L2 = L3 = 0;
  1266. break;
  1267. }
  1268. alpha_l1i_cacheshape = L1I;
  1269. alpha_l1d_cacheshape = L1D;
  1270. alpha_l2_cacheshape = L2;
  1271. alpha_l3_cacheshape = L3;
  1272. }
  1273. /*
  1274. * We show only CPU #0 info.
  1275. */
  1276. static void *
  1277. c_start(struct seq_file *f, loff_t *pos)
  1278. {
  1279. return *pos ? NULL : (char *)hwrpb + hwrpb->processor_offset;
  1280. }
  1281. static void *
  1282. c_next(struct seq_file *f, void *v, loff_t *pos)
  1283. {
  1284. return NULL;
  1285. }
  1286. static void
  1287. c_stop(struct seq_file *f, void *v)
  1288. {
  1289. }
  1290. struct seq_operations cpuinfo_op = {
  1291. .start = c_start,
  1292. .next = c_next,
  1293. .stop = c_stop,
  1294. .show = show_cpuinfo,
  1295. };
  1296. static int
  1297. alpha_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
  1298. {
  1299. #if 1
  1300. /* FIXME FIXME FIXME */
  1301. /* If we are using SRM and serial console, just hard halt here. */
  1302. if (alpha_using_srm && srmcons_output)
  1303. __halt();
  1304. #endif
  1305. return NOTIFY_DONE;
  1306. }
  1307. static __init int add_pcspkr(void)
  1308. {
  1309. struct platform_device *pd;
  1310. int ret;
  1311. pd = platform_device_alloc("pcspkr", -1);
  1312. if (!pd)
  1313. return -ENOMEM;
  1314. ret = platform_device_add(pd);
  1315. if (ret)
  1316. platform_device_put(pd);
  1317. return ret;
  1318. }
  1319. device_initcall(add_pcspkr);