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 32fc79767fc26d8782403e7b1afa7b93d518a86b19Elliott Hughes#include <inttypes.h> 33fc79767fc26d8782403e7b1afa7b93d518a86b19Elliott Hughes#include <stdlib.h> 34dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 352fd45a9cea9d31375a44ba36b065c2f8a2999993Elliott Hughes#include <string> 362fd45a9cea9d31375a44ba36b065c2f8a2999993Elliott Hughes 370b156638307db890e5539b52521fd24beb3440cbDavid Pursell#include "transport.h" 38253c18d2fbab6c16886af8bdfd528df3ebf82b93Elliott Hughes 39f838788e6a4d57634a53eb597ee76a597feffcb5Colin Crossstruct sparse_file; 40f838788e6a4d57634a53eb597ee76a597feffcb5Colin Cross 41dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project/* protocol.c - fastboot protocol */ 420b156638307db890e5539b52521fd24beb3440cbDavid Pursellint fb_command(Transport* transport, const char* cmd); 430b156638307db890e5539b52521fd24beb3440cbDavid Pursellint fb_command_response(Transport* transport, const char* cmd, char* response); 440b156638307db890e5539b52521fd24beb3440cbDavid Pursellint fb_download_data(Transport* transport, const void* data, uint32_t size); 450b156638307db890e5539b52521fd24beb3440cbDavid Pursellint fb_download_data_sparse(Transport* transport, struct sparse_file* s); 462810d00dd95ed78fdd93f2ed68f06ee32bd8e1acElliott Hughesconst std::string fb_get_error(); 47dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 48dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define FB_COMMAND_SZ 64 49dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define FB_RESPONSE_SZ 64 50dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 51dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project/* engine.c - high level command queue engine */ 520b156638307db890e5539b52521fd24beb3440cbDavid Pursellbool fb_getvar(Transport* transport, const std::string& key, std::string* value); 53fc79767fc26d8782403e7b1afa7b93d518a86b19Elliott Hughesvoid fb_queue_flash(const char *ptn, void *data, uint32_t sz); 549da9ac5b2a109fa61826bc2609011ea84f175c28Josh Gaovoid fb_queue_flash_sparse(const char* ptn, struct sparse_file* s, uint32_t sz, size_t current, 559da9ac5b2a109fa61826bc2609011ea84f175c28Josh Gao size_t total); 56dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid fb_queue_erase(const char *ptn); 57fc79767fc26d8782403e7b1afa7b93d518a86b19Elliott Hughesvoid fb_queue_format(const char *ptn, int skip_if_not_supported, int32_t max_chunk_sz); 58fc79767fc26d8782403e7b1afa7b93d518a86b19Elliott Hughesvoid fb_queue_require(const char *prod, const char *var, bool invert, 59fc79767fc26d8782403e7b1afa7b93d518a86b19Elliott Hughes size_t nvalues, const char **value); 60dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid fb_queue_display(const char *var, const char *prettyname); 61fc79767fc26d8782403e7b1afa7b93d518a86b19Elliott Hughesvoid fb_queue_query_save(const char *var, char *dest, uint32_t dest_size); 62dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid fb_queue_reboot(void); 63dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid fb_queue_command(const char *cmd, const char *msg); 64fc79767fc26d8782403e7b1afa7b93d518a86b19Elliott Hughesvoid fb_queue_download(const char *name, void *data, uint32_t size); 65dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid fb_queue_notice(const char *notice); 66157b00171a06f9ac2fd25ee3a86e801e896713d6Mark Wachslervoid fb_queue_wait_for_disconnect(void); 670b156638307db890e5539b52521fd24beb3440cbDavid Pursellint fb_execute_queue(Transport* transport); 68b7bd4ae529148e7f4d830d98ea0a75bdc5d1ac17Daniel Rosenbergvoid fb_set_active(const char *slot); 69dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 70dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project/* util stuff */ 71157b00171a06f9ac2fd25ee3a86e801e896713d6Mark Wachslerdouble now(); 72157b00171a06f9ac2fd25ee3a86e801e896713d6Mark Wachslerchar *mkmsg(const char *fmt, ...); 73f6e9ffbc734c7100914e8164f735317a85151033Narayan Kamath__attribute__((__noreturn__)) void die(const char *fmt, ...); 74dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 75b98762f7824c291dc5d9a9b757af434ef31d8c81Wink Saville/* Current product */ 76b98762f7824c291dc5d9a9b757af434ef31d8c81Wink Savilleextern char cur_product[FB_RESPONSE_SZ + 1]; 77b98762f7824c291dc5d9a9b757af434ef31d8c81Wink Saville 78dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#endif 79