Mercurial > ecos
annotate packages/redboot/current/src/cksum.c @ 3292:7f8e529b4d82 default tip
Fix FREESCALE_EDMA_NBYTES_MLOFFYES_MLOFF() so it works with negative offsets.
| author | vae |
|---|---|
| date | Wed, 29 Apr 2015 23:31:48 +0000 |
| parents | 74dbf4c3f2e1 |
| children |
| rev | line source |
|---|---|
|
264
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
1 //========================================================================== |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
2 // |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
3 // cksum.c |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
4 // |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
5 // RedBoot POSIX CRC calculation/command |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
6 // |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
7 //========================================================================== |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
8 // ####ECOSGPLCOPYRIGHTBEGIN#### |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
9 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
10 // This file is part of eCos, the Embedded Configurable Operating System. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
|
264
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
12 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
13 // eCos is free software; you can redistribute it and/or modify it under |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
14 // the terms of the GNU General Public License as published by the Free |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
15 // Software Foundation; either version 2 or (at your option) any later |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
16 // version. |
|
264
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
17 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
18 // eCos is distributed in the hope that it will be useful, but WITHOUT |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
21 // for more details. |
|
264
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
22 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
23 // You should have received a copy of the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
24 // along with eCos; if not, write to the Free Software Foundation, Inc., |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
264
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
26 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
27 // As a special exception, if other files instantiate templates or use |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
28 // macros or inline functions from this file, or you compile this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
29 // and link it with other works to produce a work based on this file, |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
30 // this file does not by itself cause the resulting work to be covered by |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
31 // the GNU General Public License. However the source code for this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
32 // must still be made available in accordance with section (3) of the GNU |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
33 // General Public License v2. |
|
264
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
34 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
35 // This exception does not invalidate any other reasons why a work based |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
36 // on this file might be covered by the GNU General Public License. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
37 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1954
diff
changeset
|
38 // ####ECOSGPLCOPYRIGHTEND#### |
|
264
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
39 //========================================================================== |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
40 //#####DESCRIPTIONBEGIN#### |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
41 // |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
42 // Author(s): gthomas |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
43 // Contributors: gthomas |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
44 // Date: 2001-01-31 |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
45 // Purpose: |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
46 // Description: |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
47 // |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
48 // This code is part of RedBoot (tm). |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
49 // |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
50 //####DESCRIPTIONEND#### |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
51 // |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
52 //========================================================================== |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
53 |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
54 #include <redboot.h> |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
55 |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
56 // Compute a CRC, using the POSIX 1003 definition |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
57 |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
58 RedBoot_cmd("cksum", |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
59 "Compute a 32bit checksum [POSIX algorithm] for a range of memory", |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
60 "-b <location> -l <length>", |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
61 do_cksum |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
62 ); |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
63 |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
64 void |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
65 do_cksum(int argc, char *argv[]) |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
66 { |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
67 struct option_info opts[2]; |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
68 unsigned long base, len, crc; |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
69 bool base_set, len_set; |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
70 |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
71 init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM, |
| 1513 | 72 (void *)&base, (bool *)&base_set, "base address"); |
|
264
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
73 init_opts(&opts[1], 'l', true, OPTION_ARG_TYPE_NUM, |
| 1513 | 74 (void *)&len, (bool *)&len_set, "length"); |
|
264
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
75 if (!scan_opts(argc, argv, 1, opts, 2, 0, 0, "")) { |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
76 return; |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
77 } |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
78 if (!base_set || !len_set) { |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
79 if (load_address >= (CYG_ADDRESS)ram_start && |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
80 load_address_end < (CYG_ADDRESS)ram_end && |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
81 load_address < load_address_end) { |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
82 base = load_address; |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
83 len = load_address_end - load_address; |
|
1954
6beba10c1713
* src/net/net_io.c (net_init): Don't initialize the network if we
asl
parents:
1513
diff
changeset
|
84 diag_printf("Computing cksum for area %lx-%lx\n", |
|
264
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
85 base, load_address_end); |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
86 } else { |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
87 diag_printf("usage: cksum -b <addr> -l <length>\n"); |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
88 return; |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
89 } |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
90 } |
| 284 | 91 crc = cyg_posix_crc32((unsigned char *)base, len); |
|
264
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
92 diag_printf("POSIX cksum = %lu %lu (0x%08lx 0x%08lx)\n", crc, len, crc, len); |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
93 } |
|
57f3c72256bb
Reorg CLI functions into separate files. Update CDL. Fix macros in scripts.
gthomas
parents:
diff
changeset
|
94 |
