1/* 2 * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3 * 4 * SPDX-License-Identifier: GPL-2.0-only 5 */ 6 7#pragma once 8 9struct elfloader_device; 10struct elfloader_driver; 11 12typedef int (*driver_init_t)(struct elfloader_device *dev, void *match_data); 13 14/* 15 * Each driver has an array of dtb_match_tables. 16 * The last entry in the array should have compatible = NULL, 17 * all others contain a compatible string that the driver accepts. 18 * The match_data pointer will be passed to the driver's init() function. 19 */ 20struct dtb_match_table { 21 const char *compatible; 22 void *match_data; 23}; 24 25enum driver_type { 26 DRIVER_INVALID = 0, 27 DRIVER_SMP, 28 DRIVER_UART, 29 DRIVER_MAX 30}; 31 32struct elfloader_driver { 33 const struct dtb_match_table *match_table; 34 enum driver_type type; 35 driver_init_t init; 36 /* ops struct, type depends on driver type. */ 37 const void *ops; 38}; 39 40 41extern struct elfloader_driver *__start__driver_list[]; 42extern struct elfloader_driver *__stop__driver_list[]; 43 44#define ELFLOADER_DRIVER(_name) \ 45 const struct elfloader_driver *_driver_list_##_name \ 46 __attribute__((unused,section("_driver_list"))) = &_name; 47