fw.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * * Copyright (C) 2007 Ubiquiti Networks, Inc.
  3. * *
  4. * * This program is free software; you can redistribute it and/or
  5. * * modify it under the terms of the GNU General Public License as
  6. * * published by the Free Software Foundation; either version 2 of the
  7. * * License, or (at your option) any later version.
  8. * *
  9. * * This program is distributed in the hope that it will be useful, but
  10. * * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * * General Public License for more details.
  13. * *
  14. * * You should have received a copy of the GNU General Public License
  15. * * along with this program; if not, write to the Free Software
  16. * * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. * */
  18. #ifndef FW_INCLUDED
  19. #define FW_INCLUDED
  20. #include <sys/types.h>
  21. #define MAGIC_HEADER "OPEN"
  22. #define MAGIC_PART "PART"
  23. #define MAGIC_END "END."
  24. #define MAGIC_LENGTH 4
  25. typedef struct header {
  26. char magic[MAGIC_LENGTH];
  27. char version[256];
  28. u_int32_t crc;
  29. u_int32_t pad;
  30. } __attribute__ ((packed)) header_t;
  31. typedef struct part {
  32. char magic[MAGIC_LENGTH];
  33. char name[16];
  34. char pad[12];
  35. u_int32_t memaddr;
  36. u_int32_t index;
  37. u_int32_t baseaddr;
  38. u_int32_t entryaddr;
  39. u_int32_t data_size;
  40. u_int32_t part_size;
  41. } __attribute__ ((packed)) part_t;
  42. typedef struct part_crc {
  43. u_int32_t crc;
  44. u_int32_t pad;
  45. } __attribute__ ((packed)) part_crc_t;
  46. typedef struct signature {
  47. char magic[MAGIC_LENGTH];
  48. u_int32_t crc;
  49. u_int32_t pad;
  50. } __attribute__ ((packed)) signature_t;
  51. #define VERSION "1.2"
  52. #define INFO(...) fprintf(stdout, __VA_ARGS__)
  53. #define ERROR(...) fprintf(stderr, "ERROR: "__VA_ARGS__)
  54. #define WARN(...) fprintf(stderr, "WARN: "__VA_ARGS__)
  55. #define DEBUG(...) do {\
  56. if (debug) \
  57. fprintf(stdout, "DEBUG: "__VA_ARGS__); \
  58. } while (0);
  59. #endif