aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm26/boot/compressed/hw-bse.c
blob: 3e8f07f8e08a578972d38af19ae3b601cc68785d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * Bright Star Engineering Inc.
 *
 * code for readng parameters from the
 * parameter blocks of the boot block
 * flash memory
 *
 */

static int strcmp(const char *s1, const char *s2)
{
  while (*s1 != '\0' && *s1 == *s2)
    {
      s1++;
      s2++;
    }

  return (*(unsigned char *) s1) - (*(unsigned char *) s2);
}

struct pblk_t {
  char type;
  unsigned short size;
};

static char *bse_getflashparam(char *name) {
  unsigned int esize;
  char *q,*r;
  unsigned char *p,*e;
  struct pblk_t *thepb = (struct pblk_t *) 0x00004000;
  struct pblk_t *altpb = (struct pblk_t *) 0x00006000;  
  if (thepb->type&1) {
    if (altpb->type&1) {
      /* no valid param block */ 
      return (char*)0;
    } else {
      /* altpb is valid */
      struct pblk_t *tmp;
      tmp = thepb;
      thepb = altpb;
      altpb = tmp;
    }
  }
  p = (char*)thepb + sizeof(struct pblk_t);
  e = p + thepb->size; 
  while (p < e) {
    q = p;
    esize = *p;
    if (esize == 0xFF) break;
    if (esize == 0) break;
    if (esize > 127) {
      esize = (esize&0x7F)<<8 | p[1];
      q++;
    }
    q++;
    r=q;
    if (*r && ((name == 0) || (!strcmp(name,r)))) {
      while (*q++) ;
      return q;
    }
    p+=esize;
  }
  return (char*)0;
}

void bse_setup(void) {
  /* extract the linux cmdline from flash */
  char *name=bse_getflashparam("linuxboot");
  char *x = (char *)0xc0000100;
  if (name) { 
    while (*name) *x++=*name++;
  }
  *x=0;
}