/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef TEST
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#endif
#ifndef STANDALONE
#include <assert.h>
#endif
#ifndef STANDALONE
#ifdef TEST
typedef unsigned int grub_size_t;
typedef unsigned char grub_uint8_t;
#else
#include <grub/reed_solomon.h>
#endif
#endif
#ifdef STANDALONE
#ifdef TEST
typedef unsigned int grub_size_t;
typedef unsigned char grub_uint8_t;
#else
#endif
void
#endif
#if defined (STANDALONE) && !defined (TEST)
#else
#if defined (STANDALONE)
static char *scratch;
#endif
#endif
static gf_single_t
{
if (a == 0 || b == 0)
return 0;
}
static inline gf_single_t
{
}
static void
init_powx (void)
{
int i;
gf_powx_inv[0] = 0;
for (i = 0; i < 255; i++)
{
gf_powx_inv[cur] = i;
else
cur <<= 1;
}
}
static gf_single_t
{
int i;
gf_single_t s = 0;
if (x == 0)
return pol[0];
log_x = gf_powx_inv[x];
for (i = degree; i >= 0; i--)
{
if (pol[i])
}
return s;
}
#if !defined (STANDALONE)
static void
{
int i, j;
gf_single_t *m;
/* Multiply with X - a^r */
for (j = 0; j < rs; j++)
{
for (i = 0; i < rs; i++)
if (rs_polynomial[i])
else
if (rs_polynomial[rs])
}
for (j = 0; j < s; j++)
if (m[j])
{
gf_single_t f = m[j];
for (i = 0; i <= rs; i++)
m[i+j] ^= gf_mul (rs_polynomial[i], f);
}
free (m);
}
#endif
static void
{
unsigned i;
for (i = 1; i < rs; i++)
{
{
xn <<= 1;
xn ^= GF_POLYNOMIAL;
}
else
xn <<= 1;
}
}
static void
{
int i, j;
for (i = 0 ; i < n; i++)
{
int nzidx;
int k;
gf_single_t r;
nzidx++);
if (nzidx == m)
continue;
for (j = 0; j < m + 1; j++)
for (j = i + 1; j < n; j++)
{
for (k = 0; k < m + 1; k++)
}
}
}
static void
{
int *chosen;
int i, j;
#ifndef STANDALONE
#else
scratch += n * sizeof (int);
#endif
for (i = 0; i < n; i++)
chosen[i] = -1;
for (i = 0; i < m; i++)
sol[i] = 0;
for (i = n - 1; i >= 0; i--)
{
gf_single_t s = 0;
if (chosen[i] == -1)
continue;
for (j = 0; j < m; j++)
s ^= eq[i * (m + 1) + m];
}
#ifndef STANDALONE
#else
scratch -= n * sizeof (int);
#endif
}
static void
{
int *errpos;
int errnum = 0;
int i, j;
#ifndef STANDALONE
#else
#endif
for (i = 0; i < (int) rs; i++)
if (sy[i] != 0)
break;
/* No error detected. */
if (i == (int) rs)
{
#ifndef STANDALONE
#else
#endif
return;
}
{
#ifndef STANDALONE
#else
#endif
for (i = 0; i < (int) rs2; i++)
for (j = 0; j < (int) rs2 + 1; j++)
for (i = 0; i < (int) rs2; i++)
sigma[i] = 0;
#ifndef STANDALONE
#else
#endif
}
{
for (i = 0; i < (int) (rs + s); i++)
{
if (ev == 0)
{
}
}
}
{
#ifndef STANDALONE
#else
#endif
for (j = 0; j < errnum; j++)
eq[j] = 1;
for (i = 1; i < (int) rs; i++)
{
for (j = 0; j < (int) errnum; j++)
}
for (i = 0; i < (int) errnum; i++)
#ifndef STANDALONE
#else
#endif
}
#ifndef STANDALONE
#else
#endif
}
static void
{
int i, j;
for (i = 0; i < SECTOR_SIZE; i++)
{
gf_single_t *m;
/* Nothing to do. */
continue;
#ifndef STANDALONE
#else
m = (gf_single_t *) scratch;
#endif
for (j = 0; j < (int) ds; j++)
m[j] = ptr[SECTOR_SIZE * j + i];
for (j = 0; j < (int) rr; j++)
for (j = 0; j < (int) ds; j++)
ptr[SECTOR_SIZE * j + i] = m[j];
#ifndef STANDALONE
free (m);
#else
#endif
}
}
#if !defined (STANDALONE)
static void
{
int i, j;
for (i = 0; i < SECTOR_SIZE; i++)
{
gf_single_t *m;
continue;
for (j = 0; j < ds; j++)
m[j] = ptr[SECTOR_SIZE * j + i];
for (j = 0; j < rr; j++)
free (m);
}
}
#endif
#if !defined (STANDALONE)
void
{
grub_size_t s = data_size;
void *tmp;
/* Nothing to do. */
if (!rs)
return;
init_powx ();
while (s > 0)
{
cs = s;
if (tt > MAX_BLOCK_SIZE)
{
}
s -= cs;
}
}
#endif
void
{
/* Nothing to do. */
if (!rs)
return;
init_powx ();
while (s > 0)
{
cs = s;
if (tt > MAX_BLOCK_SIZE)
{
}
s -= cs;
}
}
#ifdef TEST
int
{
char *buf;
#ifdef STANDALONE
#endif
#ifndef STANDALONE
init_powx ();
#endif
if (!in)
return 1;
rs = 0x7007;
#if 1
#endif
return 0;
}
#endif