summaryrefslogtreecommitdiffstats
path: root/firmware/target/mips/ingenic_x1000/installer-x1000.h
blob: 9b0f1e4bd6f8d0c17eaff8aa2769f461676c5fd3 (plain)
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
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2021 Aidan MacDonald
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/

#ifndef __INSTALLER_X1000_H__
#define __INSTALLER_X1000_H__

/* This API is for the bootloader recovery menu and Rockbox utility to handle
 * bootloader installation, backup, and restore.
 *
 * Currently the installer can only handle NAND flash, although the X1000 can
 * boot from NOR flash or SD/MMC. Support for other storage media can be added
 * when there is a target that needs it.
 *
 * Bootloader updates are tarballs, and they can "monkey patch" the flash in
 * a customizable way (but fixed at compile time).
 *
 * Backup and restore simply takes the range of eraseblocks touched by the
 * monkey patch and copies them to or from a regular file.
 */

enum {
    IERR_SUCCESS = 0,
    IERR_OUT_OF_MEMORY,
    IERR_FILE_NOT_FOUND,
    IERR_FILE_IO,
    IERR_BAD_FORMAT,
    IERR_NAND_OPEN,
    IERR_NAND_READ,
    IERR_NAND_WRITE,
    IERR_CORRUPTED_BACKUP,
};

extern int install_bootloader(const char* filename);
extern int backup_bootloader(const char* filename);
extern int restore_bootloader(const char* filename);
extern const char* installer_strerror(int rc);

#endif /* __INSTALLER_X1000_H__ */