Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.22-rc4 68 lines 1.6 kB view raw
1/* 2 * General bootinfo record utilities 3 * Author: Randy Vinson <rvinson@mvista.com> 4 * 5 * 2002 (c) MontaVista Software, Inc. This file is licensed under the terms 6 * of the GNU General Public License version 2. This program is licensed 7 * "as is" without any warranty of any kind, whether express or implied. 8 */ 9 10#include <linux/types.h> 11#include <linux/string.h> 12#include <asm/bootinfo.h> 13 14#include "nonstdio.h" 15 16static struct bi_record * birec = NULL; 17 18static struct bi_record * 19__bootinfo_build(struct bi_record *rec, unsigned long tag, unsigned long size, 20 void *data) 21{ 22 /* set the tag */ 23 rec->tag = tag; 24 25 /* if the caller has any data, copy it */ 26 if (size) 27 memcpy(rec->data, (char *)data, size); 28 29 /* set the record size */ 30 rec->size = sizeof(struct bi_record) + size; 31 32 /* advance to the next available space */ 33 rec = (struct bi_record *)((unsigned long)rec + rec->size); 34 35 return rec; 36} 37 38void 39bootinfo_init(struct bi_record *rec) 40{ 41 42 /* save start of birec area */ 43 birec = rec; 44 45 /* create an empty list */ 46 rec = __bootinfo_build(rec, BI_FIRST, 0, NULL); 47 (void) __bootinfo_build(rec, BI_LAST, 0, NULL); 48 49} 50 51void 52bootinfo_append(unsigned long tag, unsigned long size, void * data) 53{ 54 55 struct bi_record *rec = birec; 56 57 /* paranoia */ 58 if ((rec == NULL) || (rec->tag != BI_FIRST)) 59 return; 60 61 /* find the last entry in the list */ 62 while (rec->tag != BI_LAST) 63 rec = (struct bi_record *)((ulong)rec + rec->size); 64 65 /* overlay BI_LAST record with new one and tag on a new BI_LAST */ 66 rec = __bootinfo_build(rec, tag, size, data); 67 (void) __bootinfo_build(rec, BI_LAST, 0, NULL); 68}