compat.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /*
  2. * linux/arch/arm/kernel/compat.c
  3. *
  4. * Copyright (C) 2001 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * We keep the old params compatibility cruft in one place (here)
  11. * so we don't end up with lots of mess around other places.
  12. *
  13. * NOTE:
  14. * The old struct param_struct is deprecated, but it will be kept in
  15. * the kernel for 5 years from now (2001). This will allow boot loaders
  16. * to convert to the new struct tag way.
  17. */
  18. #include <linux/types.h>
  19. #include <linux/kernel.h>
  20. #include <linux/string.h>
  21. #include <linux/init.h>
  22. #include <asm/setup.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/page.h>
  25. #include <asm/mach/arch.h>
  26. #include "compat.h"
  27. /*
  28. * Usage:
  29. * - do not go blindly adding fields, add them at the end
  30. * - when adding fields, don't rely on the address until
  31. * a patch from me has been released
  32. * - unused fields should be zero (for future expansion)
  33. * - this structure is relatively short-lived - only
  34. * guaranteed to contain useful data in setup_arch()
  35. *
  36. * This is the old deprecated way to pass parameters to the kernel
  37. */
  38. struct param_struct {
  39. union {
  40. struct {
  41. unsigned long page_size; /* 0 */
  42. unsigned long nr_pages; /* 4 */
  43. unsigned long ramdisk_size; /* 8 */
  44. unsigned long flags; /* 12 */
  45. #define FLAG_READONLY 1
  46. #define FLAG_RDLOAD 4
  47. #define FLAG_RDPROMPT 8
  48. unsigned long rootdev; /* 16 */
  49. unsigned long video_num_cols; /* 20 */
  50. unsigned long video_num_rows; /* 24 */
  51. unsigned long video_x; /* 28 */
  52. unsigned long video_y; /* 32 */
  53. unsigned long memc_control_reg; /* 36 */
  54. unsigned char sounddefault; /* 40 */
  55. unsigned char adfsdrives; /* 41 */
  56. unsigned char bytes_per_char_h; /* 42 */
  57. unsigned char bytes_per_char_v; /* 43 */
  58. unsigned long pages_in_bank[4]; /* 44 */
  59. unsigned long pages_in_vram; /* 60 */
  60. unsigned long initrd_start; /* 64 */
  61. unsigned long initrd_size; /* 68 */
  62. unsigned long rd_start; /* 72 */
  63. unsigned long system_rev; /* 76 */
  64. unsigned long system_serial_low; /* 80 */
  65. unsigned long system_serial_high; /* 84 */
  66. unsigned long mem_fclk_21285; /* 88 */
  67. } s;
  68. char unused[256];
  69. } u1;
  70. union {
  71. char paths[8][128];
  72. struct {
  73. unsigned long magic;
  74. char n[1024 - sizeof(unsigned long)];
  75. } s;
  76. } u2;
  77. char commandline[COMMAND_LINE_SIZE];
  78. };
  79. static struct tag * __init memtag(struct tag *tag, unsigned long start, unsigned long size)
  80. {
  81. tag = tag_next(tag);
  82. tag->hdr.tag = ATAG_MEM;
  83. tag->hdr.size = tag_size(tag_mem32);
  84. tag->u.mem.size = size;
  85. tag->u.mem.start = start;
  86. return tag;
  87. }
  88. static void __init build_tag_list(struct param_struct *params, void *taglist)
  89. {
  90. struct tag *tag = taglist;
  91. if (params->u1.s.page_size != PAGE_SIZE) {
  92. printk(KERN_WARNING "Warning: bad configuration page, "
  93. "trying to continue\n");
  94. return;
  95. }
  96. printk(KERN_DEBUG "Converting old-style param struct to taglist\n");
  97. #ifdef CONFIG_ARCH_NETWINDER
  98. if (params->u1.s.nr_pages != 0x02000 &&
  99. params->u1.s.nr_pages != 0x04000 &&
  100. params->u1.s.nr_pages != 0x08000 &&
  101. params->u1.s.nr_pages != 0x10000) {
  102. printk(KERN_WARNING "Warning: bad NeTTrom parameters "
  103. "detected, using defaults\n");
  104. params->u1.s.nr_pages = 0x1000; /* 16MB */
  105. params->u1.s.ramdisk_size = 0;
  106. params->u1.s.flags = FLAG_READONLY;
  107. params->u1.s.initrd_start = 0;
  108. params->u1.s.initrd_size = 0;
  109. params->u1.s.rd_start = 0;
  110. }
  111. #endif
  112. tag->hdr.tag = ATAG_CORE;
  113. tag->hdr.size = tag_size(tag_core);
  114. tag->u.core.flags = params->u1.s.flags & FLAG_READONLY;
  115. tag->u.core.pagesize = params->u1.s.page_size;
  116. tag->u.core.rootdev = params->u1.s.rootdev;
  117. tag = tag_next(tag);
  118. tag->hdr.tag = ATAG_RAMDISK;
  119. tag->hdr.size = tag_size(tag_ramdisk);
  120. tag->u.ramdisk.flags = (params->u1.s.flags & FLAG_RDLOAD ? 1 : 0) |
  121. (params->u1.s.flags & FLAG_RDPROMPT ? 2 : 0);
  122. tag->u.ramdisk.size = params->u1.s.ramdisk_size;
  123. tag->u.ramdisk.start = params->u1.s.rd_start;
  124. tag = tag_next(tag);
  125. tag->hdr.tag = ATAG_INITRD;
  126. tag->hdr.size = tag_size(tag_initrd);
  127. tag->u.initrd.start = params->u1.s.initrd_start;
  128. tag->u.initrd.size = params->u1.s.initrd_size;
  129. tag = tag_next(tag);
  130. tag->hdr.tag = ATAG_SERIAL;
  131. tag->hdr.size = tag_size(tag_serialnr);
  132. tag->u.serialnr.low = params->u1.s.system_serial_low;
  133. tag->u.serialnr.high = params->u1.s.system_serial_high;
  134. tag = tag_next(tag);
  135. tag->hdr.tag = ATAG_REVISION;
  136. tag->hdr.size = tag_size(tag_revision);
  137. tag->u.revision.rev = params->u1.s.system_rev;
  138. #ifdef CONFIG_ARCH_ACORN
  139. if (machine_is_riscpc()) {
  140. int i;
  141. for (i = 0; i < 4; i++)
  142. tag = memtag(tag, PHYS_OFFSET + (i << 26),
  143. params->u1.s.pages_in_bank[i] * PAGE_SIZE);
  144. } else
  145. #endif
  146. tag = memtag(tag, PHYS_OFFSET, params->u1.s.nr_pages * PAGE_SIZE);
  147. #ifdef CONFIG_FOOTBRIDGE
  148. if (params->u1.s.mem_fclk_21285) {
  149. tag = tag_next(tag);
  150. tag->hdr.tag = ATAG_MEMCLK;
  151. tag->hdr.size = tag_size(tag_memclk);
  152. tag->u.memclk.fmemclk = params->u1.s.mem_fclk_21285;
  153. }
  154. #endif
  155. #ifdef CONFIG_ARCH_EBSA285
  156. if (machine_is_ebsa285()) {
  157. tag = tag_next(tag);
  158. tag->hdr.tag = ATAG_VIDEOTEXT;
  159. tag->hdr.size = tag_size(tag_videotext);
  160. tag->u.videotext.x = params->u1.s.video_x;
  161. tag->u.videotext.y = params->u1.s.video_y;
  162. tag->u.videotext.video_page = 0;
  163. tag->u.videotext.video_mode = 0;
  164. tag->u.videotext.video_cols = params->u1.s.video_num_cols;
  165. tag->u.videotext.video_ega_bx = 0;
  166. tag->u.videotext.video_lines = params->u1.s.video_num_rows;
  167. tag->u.videotext.video_isvga = 1;
  168. tag->u.videotext.video_points = 8;
  169. }
  170. #endif
  171. #ifdef CONFIG_ARCH_ACORN
  172. tag = tag_next(tag);
  173. tag->hdr.tag = ATAG_ACORN;
  174. tag->hdr.size = tag_size(tag_acorn);
  175. tag->u.acorn.memc_control_reg = params->u1.s.memc_control_reg;
  176. tag->u.acorn.vram_pages = params->u1.s.pages_in_vram;
  177. tag->u.acorn.sounddefault = params->u1.s.sounddefault;
  178. tag->u.acorn.adfsdrives = params->u1.s.adfsdrives;
  179. #endif
  180. tag = tag_next(tag);
  181. tag->hdr.tag = ATAG_CMDLINE;
  182. tag->hdr.size = (strlen(params->commandline) + 3 +
  183. sizeof(struct tag_header)) >> 2;
  184. strcpy(tag->u.cmdline.cmdline, params->commandline);
  185. tag = tag_next(tag);
  186. tag->hdr.tag = ATAG_NONE;
  187. tag->hdr.size = 0;
  188. memmove(params, taglist, ((int)tag) - ((int)taglist) +
  189. sizeof(struct tag_header));
  190. }
  191. void __init convert_to_tag_list(struct tag *tags)
  192. {
  193. struct param_struct *params = (struct param_struct *)tags;
  194. build_tag_list(params, &params->u2);
  195. }