ops.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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);
  23. void * (*realloc)(void *ptr, unsigned long size);
  24. void (*exit)(void);
  25. };
  26. extern struct platform_ops platform_ops;
  27. /* Device Tree operations */
  28. struct dt_ops {
  29. void * (*finddevice)(const char *name);
  30. int (*getprop)(const void *phandle, const char *name, void *buf,
  31. const int buflen);
  32. int (*setprop)(const void *phandle, const char *name,
  33. const void *buf, const int buflen);
  34. unsigned long (*finalize)(void);
  35. };
  36. extern struct dt_ops dt_ops;
  37. /* Console operations */
  38. struct console_ops {
  39. int (*open)(void);
  40. void (*write)(char *buf, int len);
  41. void (*edit_cmdline)(char *buf, int len);
  42. void (*close)(void);
  43. void *data;
  44. };
  45. extern struct console_ops console_ops;
  46. /* Serial console operations */
  47. struct serial_console_data {
  48. int (*open)(void);
  49. void (*putc)(unsigned char c);
  50. unsigned char (*getc)(void);
  51. u8 (*tstc)(void);
  52. void (*close)(void);
  53. };
  54. int platform_init(void *promptr, char *dt_blob_start, char *dt_blob_end);
  55. int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device);
  56. int serial_console_init(void);
  57. int ns16550_console_init(void *devp, struct serial_console_data *scdp);
  58. void *simple_alloc_init(char *base, u32 heap_size, u32 granularity,
  59. u32 max_allocs);
  60. static inline void *finddevice(const char *name)
  61. {
  62. return (dt_ops.finddevice) ? dt_ops.finddevice(name) : NULL;
  63. }
  64. static inline int getprop(void *devp, const char *name, void *buf, int buflen)
  65. {
  66. return (dt_ops.getprop) ? dt_ops.getprop(devp, name, buf, buflen) : -1;
  67. }
  68. static inline int setprop(void *devp, const char *name, void *buf, int buflen)
  69. {
  70. return (dt_ops.setprop) ? dt_ops.setprop(devp, name, buf, buflen) : -1;
  71. }
  72. static inline void *malloc(u32 size)
  73. {
  74. return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL;
  75. }
  76. static inline void free(void *ptr)
  77. {
  78. if (platform_ops.free)
  79. platform_ops.free(ptr);
  80. }
  81. static inline void exit(void)
  82. {
  83. if (platform_ops.exit)
  84. platform_ops.exit();
  85. for(;;);
  86. }
  87. #endif /* _PPC_BOOT_OPS_H_ */