blob: 15e0a5c997f4779ff441239449c94aeb25390d92 [file] [log] [blame]
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _RECOVERY_BOOTLOADER_H
18#define _RECOVERY_BOOTLOADER_H
19
Doug Zongker28ce47c2011-10-28 10:33:05 -070020#ifdef __cplusplus
21extern "C" {
22#endif
23
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080024/* Bootloader Message
25 *
26 * This structure describes the content of a block in flash
27 * that is used for recovery and the bootloader to talk to
28 * each other.
29 *
30 * The command field is updated by linux when it wants to
31 * reboot into recovery or to update radio or bootloader firmware.
32 * It is also updated by the bootloader when firmware update
33 * is complete (to boot into recovery for any final cleanup)
34 *
35 * The status field is written by the bootloader after the
36 * completion of an "update-radio" or "update-hboot" command.
37 *
38 * The recovery field is only written by linux and used
39 * for the system to send a message to recovery or the
40 * other way around.
Doug Zongkerc87bab12013-11-25 13:53:25 -080041 *
42 * The stage field is written by packages which restart themselves
43 * multiple times, so that the UI can reflect which invocation of the
44 * package it is. If the value is of the format "#/#" (eg, "1/3"),
45 * the UI will add a simple indicator of that status.
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080046 */
47struct bootloader_message {
48 char command[32];
49 char status[32];
Doug Zongkerc87bab12013-11-25 13:53:25 -080050 char recovery[768];
51
52 // The 'recovery' field used to be 1024 bytes. It has only ever
53 // been used to store the recovery command line, so 768 bytes
54 // should be plenty. We carve off the last 256 bytes to store the
55 // stage string (for multistage packages) and possible future
56 // expansion.
57 char stage[32];
58 char reserved[224];
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080059};
60
61/* Read and write the bootloader command from the "misc" partition.
62 * These return zero on success.
63 */
Dees_Troy1669f892013-09-04 18:35:08 +000064/*
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080065int get_bootloader_message(struct bootloader_message *out);
66int set_bootloader_message(const struct bootloader_message *in);
Dees_Troy1669f892013-09-04 18:35:08 +000067*/
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080068
Dees_Troy1669f892013-09-04 18:35:08 +000069void set_device_type(char new_type);
70void set_device_name(const char* new_name);
71
72int get_bootloader_message_mtd_name(struct bootloader_message *out);
Dees_Troy2673cec2013-04-02 20:22:16 +000073int set_bootloader_message_mtd_name(const struct bootloader_message *in, const char* mtd_name);
Dees_Troy1669f892013-09-04 18:35:08 +000074int get_bootloader_message_block_name(struct bootloader_message *out);
Dees_Troy2673cec2013-04-02 20:22:16 +000075int set_bootloader_message_block_name(const struct bootloader_message *in, const char* block_name);
76
Dees_Troya449a6f2013-04-07 17:50:11 -050077void get_args(int *argc, char ***argv);
78
Doug Zongker28ce47c2011-10-28 10:33:05 -070079#ifdef __cplusplus
80}
81#endif
82
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080083#endif