[PATCH] s390: diag 0x308 reipl
[usb.git] / arch / arm26 / boot / compressed / hw-bse.c
blob3e8f07f8e08a578972d38af19ae3b601cc68785d
1 /*
2 * Bright Star Engineering Inc.
4 * code for readng parameters from the
5 * parameter blocks of the boot block
6 * flash memory
8 */
10 static int strcmp(const char *s1, const char *s2)
12 while (*s1 != '\0' && *s1 == *s2)
14 s1++;
15 s2++;
18 return (*(unsigned char *) s1) - (*(unsigned char *) s2);
21 struct pblk_t {
22 char type;
23 unsigned short size;
26 static char *bse_getflashparam(char *name) {
27 unsigned int esize;
28 char *q,*r;
29 unsigned char *p,*e;
30 struct pblk_t *thepb = (struct pblk_t *) 0x00004000;
31 struct pblk_t *altpb = (struct pblk_t *) 0x00006000;
32 if (thepb->type&1) {
33 if (altpb->type&1) {
34 /* no valid param block */
35 return (char*)0;
36 } else {
37 /* altpb is valid */
38 struct pblk_t *tmp;
39 tmp = thepb;
40 thepb = altpb;
41 altpb = tmp;
44 p = (char*)thepb + sizeof(struct pblk_t);
45 e = p + thepb->size;
46 while (p < e) {
47 q = p;
48 esize = *p;
49 if (esize == 0xFF) break;
50 if (esize == 0) break;
51 if (esize > 127) {
52 esize = (esize&0x7F)<<8 | p[1];
53 q++;
55 q++;
56 r=q;
57 if (*r && ((name == 0) || (!strcmp(name,r)))) {
58 while (*q++) ;
59 return q;
61 p+=esize;
63 return (char*)0;
66 void bse_setup(void) {
67 /* extract the linux cmdline from flash */
68 char *name=bse_getflashparam("linuxboot");
69 char *x = (char *)0xc0000100;
70 if (name) {
71 while (*name) *x++=*name++;
73 *x=0;