1 #include <linux/slab.h>
2 #include <linux/proc_fs.h>
11 static struct buffer tags_buffer
;
14 read_buffer(char* page
, char** start
, off_t off
, int count
,
17 struct buffer
*buffer
= (struct buffer
*)data
;
19 if (off
>= buffer
->size
) {
24 count
= min((int) (buffer
->size
- off
), count
);
26 memcpy(page
, &buffer
->data
[off
], count
);
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
);
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)
61 printk(KERN_WARNING
"Exporting ATAGs: No saved tags found\n");
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
)
72 memcpy(tags_buffer
.data
, atags_copy
, tags_buffer
.size
);
74 error
= create_proc_entries();
76 printk(KERN_ERR
"Exporting ATAGs: not enough memory\n");
77 kfree(tags_buffer
.data
);
79 tags_buffer
.data
= NULL
;
85 arch_initcall(init_atags_procfs
);