board.h (3448B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * File: board.h 8 * Purpose: Board driver interface 9 */ 10 11 #ifndef _BOARD_H_ 12 #define _BOARD_H_ 13 14 #if defined(INCLUDE_BOARD) 15 16 #include <bcm/types.h> 17 #include <bcm/init.h> 18 19 #define BOARD_LOWEST_PRIORITY 0 20 #define BOARD_GENERIC_PRIORITY 25 21 #define BOARD_DEFAULT_PRIORITY 50 22 23 #define BOARD_START_F_COLD_BOOT 0x00000000 24 #define BOARD_START_F_WARM_BOOT 0x00000001 25 #define BOARD_START_F_CLEAR 0x00000002 26 27 /* 28 * Board driver interface 29 */ 30 31 typedef struct board_connection_s { 32 bcm_gport_t from; 33 bcm_gport_t to; 34 } board_connection_t; 35 36 struct board_driver_s; /* forward reference */ 37 38 typedef int (*board_attribute_get_f)(struct board_driver_s *driver, 39 char *name, int *value); 40 typedef int (*board_attribute_set_f)(struct board_driver_s *driver, 41 char *name, int value); 42 43 typedef struct board_attribute_s { 44 char *name; 45 char *description; 46 char *units; 47 char *format; 48 board_attribute_get_f get; 49 board_attribute_set_f set; 50 } board_attribute_t; 51 52 typedef char *(*board_desc_f)(struct board_driver_s *driver); 53 typedef int (*board_probe_f)(struct board_driver_s *driver, 54 int num, bcm_info_t *info); 55 typedef int (*board_start_f)(struct board_driver_s *driver, uint32 flags); 56 typedef int (*board_stop_f)(struct board_driver_s *driver); 57 58 typedef struct board_driver_s { 59 char *name; 60 int priority; 61 void *user_data; 62 int num_connection; 63 board_connection_t *connection; 64 int num_attribute; 65 board_attribute_t *attribute; 66 board_desc_f description; 67 board_probe_f probe; 68 board_start_f start; 69 board_stop_f stop; 70 } board_driver_t; 71 72 /* Board Manager API */ 73 extern int board_init(void); 74 extern int board_deinit(void); 75 76 extern int board_driver_add(board_driver_t *driver); 77 extern int board_driver_delete(board_driver_t *driver); 78 extern int board_driver_builtins_add(void); 79 extern int board_driver_builtins_delete(void); 80 extern int board_driver_builtins_get(int max_num, 81 board_driver_t **driver, 82 int *actual); 83 84 extern int board_drivers_get(int max_num, 85 board_driver_t **driver, 86 int *actual); 87 88 extern char *board_probe(void); 89 extern int board_find(char *name); 90 extern int board_attach(char *name); 91 extern int board_detach(void); 92 93 /* Board System API */ 94 extern char *board_name(void); 95 extern char *board_description(void); 96 extern int board_start(uint32 start_flags); 97 extern int board_stop(void); 98 extern int board_attribute_get(char *attrib, int *value); 99 extern int board_attribute_set(char *attrib, int value); 100 extern int board_attributes_get(int max_num, board_attribute_t *attrib, 101 int *actual); 102 extern int board_connections_get(int max_num, 103 board_connection_t *connection, 104 int *actual); 105 106 #endif /* INCLUDE_BOARD */ 107 108 #endif /* _BOARD_H_ */