1dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project/*
2dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
3dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * All rights reserved.
4dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *
5dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * Redistribution and use in source and binary forms, with or without
6dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * modification, are permitted provided that the following conditions
7dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * are met:
8dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *  * Redistributions of source code must retain the above copyright
9dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *    notice, this list of conditions and the following disclaimer.
10dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *  * Redistributions in binary form must reproduce the above copyright
11dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *    notice, this list of conditions and the following disclaimer in
125ae3f93f3bafbeb1fc9a3324475c58c725749c5eAnatol Pomazau *    the documentation and/or other materials provided with the
13dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *    distribution.
14dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *
15dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
225ae3f93f3bafbeb1fc9a3324475c58c725749c5eAnatol Pomazau * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * SUCH DAMAGE.
27dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project */
28dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
29dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#ifndef _FASTBOOT_H_
30dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define _FASTBOOT_H_
31dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
32dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#include "usb.h"
33dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
34f838788e6a4d57634a53eb597ee76a597feffcb5Colin Crossstruct sparse_file;
35f838788e6a4d57634a53eb597ee76a597feffcb5Colin Cross
36dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project/* protocol.c - fastboot protocol */
37dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectint fb_command(usb_handle *usb, const char *cmd);
38dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectint fb_command_response(usb_handle *usb, const char *cmd, char *response);
398d7ddb35d510824e50833a9b31ae6486393b1436Alexander Levitskiyint fb_download_data(usb_handle *usb, const void *data, unsigned size);
40f838788e6a4d57634a53eb597ee76a597feffcb5Colin Crossint fb_download_data_sparse(usb_handle *usb, struct sparse_file *s);
41dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectchar *fb_get_error(void);
42dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
43dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define FB_COMMAND_SZ 64
44dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define FB_RESPONSE_SZ 64
45dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
46dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project/* engine.c - high level command queue engine */
4780f2d036a9dff894df27961c4aed300f1a5ebbc4Colin Crossint fb_getvar(struct usb_handle *usb, char *response, const char *fmt, ...);
487e85974fc2fc48a0cea7bb9bafcfcda863138eb6JP Abgrallint fb_format_supported(usb_handle *usb, const char *partition, const char *type_override);
495ee5d389d6cb90b3cd2856730f8ff12211bc95d2Ken Sumrallvoid fb_queue_flash(const char *ptn, void *data, unsigned sz);
508d7ddb35d510824e50833a9b31ae6486393b1436Alexander Levitskiyvoid fb_queue_flash_sparse(const char *ptn, struct sparse_file *s, unsigned sz);
51dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid fb_queue_erase(const char *ptn);
52e6f3e9bd2656fe132f829ed035fdea0cb111369dDmitry Grinbergvoid fb_queue_format(const char *ptn, int skip_if_not_supported, unsigned int max_chunk_sz);
53b98762f7824c291dc5d9a9b757af434ef31d8c81Wink Savillevoid fb_queue_require(const char *prod, const char *var, int invert,
54b98762f7824c291dc5d9a9b757af434ef31d8c81Wink Saville        unsigned nvalues, const char **value);
55dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid fb_queue_display(const char *var, const char *prettyname);
568d7ddb35d510824e50833a9b31ae6486393b1436Alexander Levitskiyvoid fb_queue_query_save(const char *var, char *dest, unsigned dest_size);
57dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid fb_queue_reboot(void);
58dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid fb_queue_command(const char *cmd, const char *msg);
598d7ddb35d510824e50833a9b31ae6486393b1436Alexander Levitskiyvoid fb_queue_download(const char *name, void *data, unsigned size);
60dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid fb_queue_notice(const char *notice);
61157b00171a06f9ac2fd25ee3a86e801e896713d6Mark Wachslervoid fb_queue_wait_for_disconnect(void);
62eb31c0bdc0eac0898f01cdc1737cea94269f8f27Brian Carlstromint fb_execute_queue(usb_handle *usb);
6313081c6915220db03886b177f1a8e0b2c63467c9Scott Andersonint fb_queue_is_empty(void);
64dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
65dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project/* util stuff */
66157b00171a06f9ac2fd25ee3a86e801e896713d6Mark Wachslerdouble now();
67157b00171a06f9ac2fd25ee3a86e801e896713d6Mark Wachslerchar *mkmsg(const char *fmt, ...);
68dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid die(const char *fmt, ...);
69dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
70b98762f7824c291dc5d9a9b757af434ef31d8c81Wink Saville/* Current product */
71b98762f7824c291dc5d9a9b757af434ef31d8c81Wink Savilleextern char cur_product[FB_RESPONSE_SZ + 1];
72b98762f7824c291dc5d9a9b757af434ef31d8c81Wink Saville
73dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#endif
74