ops.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Global definition of all the bootwrapper operations.
  3. *
  4. * Author: Mark A. Greer <mgreer@mvista.com>
  5. *
  6. * 2006 (c) MontaVista Software, Inc. This file is licensed under
  7. * the terms of the GNU General Public License version 2. This program
  8. * is licensed "as is" without any warranty of any kind, whether express
  9. * or implied.
  10. */
  11. #ifndef _PPC_BOOT_OPS_H_
  12. #define _PPC_BOOT_OPS_H_
  13. #include "types.h"
  14. #define COMMAND_LINE_SIZE 512
  15. #define MAX_PATH_LEN 256
  16. #define MAX_PROP_LEN 256 /* What should this be? */
  17. /* Platform specific operations */
  18. struct platform_ops {
  19. void (*fixups)(void);
  20. void (*image_hdr)(const void *);
  21. void * (*malloc)(u32 size);
  22. void (*free)(void *ptr, u32 size);
  23. void (*exit)(void);
  24. };
  25. extern struct platform_ops platform_ops;
  26. /* Device Tree operations */
  27. struct dt_ops {
  28. void * (*finddevice)(const char *name);
  29. int (*getprop)(const void *node, const char *name, void *buf,
  30. const int buflen);
  31. int (*setprop)(const void *node, const char *name,
  32. const void *buf, const int buflen);
  33. u64 (*translate_addr)(const char *path, const u32 *in_addr,
  34. const u32 addr_len);
  35. unsigned long (*ft_addr)(void);
  36. };
  37. extern struct dt_ops dt_ops;
  38. /* Console operations */
  39. struct console_ops {
  40. int (*open)(void);
  41. void (*write)(char *buf, int len);
  42. void (*edit_cmdline)(char *buf, int len);
  43. void (*close)(void);
  44. void *data;
  45. };
  46. extern struct console_ops console_ops;
  47. /* Serial console operations */
  48. struct serial_console_data {
  49. int (*open)(void);
  50. void (*putc)(unsigned char c);
  51. unsigned char (*getc)(void);
  52. u8 (*tstc)(void);
  53. void (*close)(void);
  54. };
  55. extern int platform_init(void *promptr);
  56. extern void simple_alloc_init(void);
  57. extern void ft_init(void *dt_blob);
  58. extern int serial_console_init(void);
  59. static inline void *finddevice(const char *name)
  60. {
  61. return (dt_ops.finddevice) ? dt_ops.finddevice(name) : NULL;
  62. }
  63. static inline int getprop(void *devp, const char *name, void *buf, int buflen)
  64. {
  65. return (dt_ops.getprop) ? dt_ops.getprop(devp, name, buf, buflen) : -1;
  66. }
  67. static inline int setprop(void *devp, const char *name, void *buf, int buflen)
  68. {
  69. return (dt_ops.setprop) ? dt_ops.setprop(devp, name, buf, buflen) : -1;
  70. }
  71. static inline void *malloc(u32 size)
  72. {
  73. return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL;
  74. }
  75. static inline void free(void *ptr, u32 size)
  76. {
  77. if (platform_ops.free)
  78. platform_ops.free(ptr, size);
  79. }
  80. static inline void exit(void)
  81. {
  82. if (platform_ops.exit)
  83. platform_ops.exit();
  84. for(;;);
  85. }
  86. #endif /* _PPC_BOOT_OPS_H_ */