compat.c 5.2 KB

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