OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.target/] [powerpc/] [pr51623.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 691 jeremybenn
/* PR target/51623 */
2
/* { dg-do compile { target { { powerpc*-*-linux* && ilp32 } || { powerpc-*-eabi* } } } } */
3
/* { dg-options "-mrelocatable -ffreestanding" } */
4
 
5
/* This generated an error, since the compiler was calling
6
   unlikely_text_section_p in a context where it wasn't valid.  */
7
 
8
typedef long long loff_t;
9
typedef unsigned size_t;
10
 
11
 
12
struct mtd_info {
13
  unsigned writesize;
14
  unsigned oobsize;
15
  const char *name;
16
};
17
 
18
extern int strcmp(const char *,const char *);
19
extern char * strchr(const char *,int);
20
 
21
struct cmd_tbl_s {
22
  char *name;
23
};
24
 
25
 
26
int printf(const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2)));
27
void* malloc(size_t);
28
void free(void*);
29
 
30
 
31
extern int nand_curr_device;
32
extern struct mtd_info nand_info[];
33
 
34
static int nand_dump(struct mtd_info *nand, unsigned long off, int only_oob)
35
{
36
  int i;
37
  unsigned char *datbuf, *oobbuf, *p;
38
 
39
  datbuf = malloc(nand->writesize + nand->oobsize);
40
  oobbuf = malloc(nand->oobsize);
41
  off &= ~(nand->writesize - 1);
42
 
43
  printf("Page %08lx dump:\n", off);
44
  i = nand->writesize >> 4;
45
  p = datbuf;
46
 
47
  while (i--) {
48
    if (!only_oob)
49
      printf("\t%02x %02x %02x %02x %02x %02x %02x %02x"
50
             "  %02x %02x %02x %02x %02x %02x %02x %02x\n",
51
             p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
52
             p[8], p[9], p[10], p[11], p[12], p[13], p[14],
53
             p[15]);
54
    p += 16;
55
  }
56
 
57
  i = nand->oobsize >> 3;
58
  free(datbuf);
59
  free(oobbuf);
60
 
61
  return 0;
62
}
63
 
64
int do_nand(struct cmd_tbl_s * cmdtp, int flag, int argc, char *argv[])
65
{
66
  int dev;
67
  unsigned long  off;
68
  char *cmd, *s;
69
  struct mtd_info *nand;
70
 
71
  if (argc < 2)
72
    goto usage;
73
 
74
  cmd = argv[1];
75
 
76
  if (strcmp(cmd, "info") == 0) {
77
    putc('\n');
78
    return 0;
79
  }
80
 
81
  if (strcmp(cmd, "device") == 0) {
82
    if (argc < 3) {
83
      putc('\n');
84
    }
85
    dev = (int)simple_strtoul(argv[2], ((void *)0), 10);
86
    nand_curr_device = dev;
87
    return 0;
88
  }
89
 
90
  if (strcmp(cmd, "bad") != 0 && strcmp(cmd, "erase") != 0  )
91
    goto usage;
92
 
93
  if (nand_curr_device < 0 ) {
94
    return 1;
95
  }
96
  nand = &nand_info[nand_curr_device];
97
 
98
  if (strcmp(cmd, "erase") == 0 || strcmp(cmd, "scrub") == 0) {
99
    int clean = argc > 2 && !strcmp("clean", argv[2]);
100
    int scrub = !strcmp(cmd, "scrub");
101
    return 0;
102
  }
103
 
104
  if (strncmp(cmd, "dump", 4) == 0) {
105
    if (argc < 3)
106
      goto usage;
107
 
108
    s = strchr(cmd, '.');
109
    off = (int)simple_strtoul(argv[2], ((void *)0), 16);
110
 
111
    if (s != ((void *)0) && strcmp(s, ".oob") == 0)
112
      nand_dump(nand, off, 1);
113
    else
114
      nand_dump(nand, off, 0);
115
 
116
    return 0;
117
  }
118
usage:
119
  cmd_usage(cmdtp);
120
  return 1;
121
}
122
 
123
void *ptr = do_nand;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.