1 #include <linux/slab.h>
2 #include <linux/kexec.h>
3 #include <linux/proc_fs.h>
12 static struct buffer tags_buffer
;
15 read_buffer(char* page
, char** start
, off_t off
, int count
,
18 struct buffer
*buffer
= (struct buffer
*)data
;
20 if (off
>= buffer
->size
) {
25 count
= min((int) (buffer
->size
- off
), count
);
27 memcpy(page
, &buffer
->data
[off
], count
);
34 create_proc_entries(void)
36 struct proc_dir_entry
* tags_entry
;
38 tags_entry
= create_proc_read_entry("atags", 0400, &proc_root
, read_buffer
, &tags_buffer
);
46 static char __initdata atags_copy_buf
[KEXEC_BOOT_PARAMS_SIZE
];
47 static char __initdata
*atags_copy
;
49 void __init
save_atags(const struct tag
*tags
)
51 atags_copy
= atags_copy_buf
;
52 memcpy(atags_copy
, tags
, KEXEC_BOOT_PARAMS_SIZE
);
56 static int __init
init_atags_procfs(void)
62 printk(KERN_WARNING
"Exporting ATAGs: No saved tags found\n");
66 for (tag
= (struct tag
*) atags_copy
; tag
->hdr
.size
; tag
= tag_next(tag
))
69 tags_buffer
.size
= ((char *) tag
- atags_copy
) + sizeof(tag
->hdr
);
70 tags_buffer
.data
= kmalloc(tags_buffer
.size
, GFP_KERNEL
);
71 if (tags_buffer
.data
== NULL
)
73 memcpy(tags_buffer
.data
, atags_copy
, tags_buffer
.size
);
75 error
= create_proc_entries();
77 printk(KERN_ERR
"Exporting ATAGs: not enough memory\n");
78 kfree(tags_buffer
.data
);
80 tags_buffer
.data
= NULL
;
86 arch_initcall(init_atags_procfs
);