There is no need to have BOOT_PARAMS_SIZE known outside of atags.c
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / kernel / atags.c
blob56fef9a055042166d35a291ca7b3b08b4d8780b2
1 #include <linux/slab.h>
2 #include <linux/proc_fs.h>
3 #include <asm/setup.h>
4 #include <asm/types.h>
5 #include <asm/page.h>
7 struct buffer {
8 size_t size;
9 char *data;
11 static struct buffer tags_buffer;
13 static int
14 read_buffer(char* page, char** start, off_t off, int count,
15 int* eof, void* data)
17 struct buffer *buffer = (struct buffer *)data;
19 if (off >= buffer->size) {
20 *eof = 1;
21 return 0;
24 count = min((int) (buffer->size - off), count);
26 memcpy(page, &buffer->data[off], count);
28 return count;
32 static int
33 create_proc_entries(void)
35 struct proc_dir_entry* tags_entry;
37 tags_entry = create_proc_read_entry("atags", 0400, NULL, read_buffer, &tags_buffer);
38 if (!tags_entry)
39 return -ENOMEM;
41 return 0;
44 #define BOOT_PARAMS_SIZE 1536
45 static char __initdata atags_copy_buf[BOOT_PARAMS_SIZE];
46 static char __initdata *atags_copy;
48 void __init save_atags(const struct tag *tags)
50 atags_copy = atags_copy_buf;
51 memcpy(atags_copy, tags, sizeof(atags_copy_buf));
55 static int __init init_atags_procfs(void)
57 struct tag *tag;
58 int error;
60 if (!atags_copy) {
61 printk(KERN_WARNING "Exporting ATAGs: No saved tags found\n");
62 return -EIO;
65 for (tag = (struct tag *) atags_copy; tag->hdr.size; tag = tag_next(tag))
68 tags_buffer.size = ((char *) tag - atags_copy) + sizeof(tag->hdr);
69 tags_buffer.data = kmalloc(tags_buffer.size, GFP_KERNEL);
70 if (tags_buffer.data == NULL)
71 return -ENOMEM;
72 memcpy(tags_buffer.data, atags_copy, tags_buffer.size);
74 error = create_proc_entries();
75 if (error) {
76 printk(KERN_ERR "Exporting ATAGs: not enough memory\n");
77 kfree(tags_buffer.data);
78 tags_buffer.size = 0;
79 tags_buffer.data = NULL;
82 return error;
85 arch_initcall(init_atags_procfs);