Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset eff1f033 in mainline


Ignore:
Timestamp:
2010-12-21T22:23:03Z (11 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
5f0123b
Parents:
78ffb70
Message:

Match platform driver based on platform name instead of architecture name. Obtain platform name from kernel via sysinfo.

Files:
15 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/src/amd64.c

    r78ffb70 reff1f033  
    199199void arch_post_smp_init(void)
    200200{
     201        /* Currently the only supported platform for amd64 is 'pc'. */
     202        static const char *platform = "pc";
     203
     204        sysinfo_set_item_data("platform", NULL, (void *) platform,
     205            str_size(platform));
     206
    201207#ifdef CONFIG_PC_KBD
    202208        /*
  • kernel/arch/arm32/include/mach/integratorcp/integratorcp.h

    r78ffb70 reff1f033  
    106106extern void icp_frame_init(void);
    107107extern size_t icp_get_irq_count(void);
     108extern const char *icp_get_platform_name(void);
    108109
    109110extern struct arm_machine_ops icp_machine_ops;
  • kernel/arch/arm32/include/mach/testarm/testarm.h

    r78ffb70 reff1f033  
    7474extern void gxemul_frame_init(void);
    7575extern size_t gxemul_get_irq_count(void);
     76extern const char *gxemul_get_platform_name(void);
    7677
    7778extern struct arm_machine_ops gxemul_machine_ops;
  • kernel/arch/arm32/include/machine_func.h

    r78ffb70 reff1f033  
    5656        void (*machine_input_init)(void);
    5757        size_t (*machine_get_irq_count)(void);
     58        const char *(*machine_get_platform_name)(void);
    5859};
    5960
  • kernel/arch/arm32/src/mach/gta02/gta02.c

    r78ffb70 reff1f033  
    7171static void gta02_input_init(void);
    7272static size_t gta02_get_irq_count(void);
     73static const char *gta02_get_platform_name(void);
    7374
    7475static void gta02_timer_irq_init(void);
     
    9293        gta02_output_init,
    9394        gta02_input_init,
    94         gta02_get_irq_count
     95        gta02_get_irq_count,
     96        gta02_get_platform_name
    9597};
    9698
     
    235237}
    236238
     239const char *gta02_get_platform_name(void)
     240{
     241        return "gta02";
     242}
     243
    237244static void gta02_timer_irq_init(void)
    238245{
  • kernel/arch/arm32/src/mach/integratorcp/integratorcp.c

    r78ffb70 reff1f033  
    6565        icp_output_init,
    6666        icp_input_init,
    67         icp_get_irq_count
     67        icp_get_irq_count,
     68        icp_get_platform_name
    6869};
    6970
     
    342343}
    343344
     345const char *icp_get_platform_name(void)
     346{
     347        return "integratorcp";
     348}
     349
    344350/** @}
    345351 */
  • kernel/arch/arm32/src/mach/testarm/testarm.c

    r78ffb70 reff1f033  
    6565        gxemul_output_init,
    6666        gxemul_input_init,
    67         gxemul_get_irq_count
     67        gxemul_get_irq_count,
     68        gxemul_get_platform_name
    6869};
    6970
     
    132133}
    133134
     135const char *gxemul_get_platform_name(void)
     136{
     137        return "gxemul";
     138}
     139
    134140/** Starts gxemul Real Time Clock device, which asserts regular interrupts.
    135141 *
  • kernel/arch/ia32/src/ia32.c

    r78ffb70 reff1f033  
    157157void arch_post_smp_init(void)
    158158{
     159        /* Currently the only supported platform for ia32 is 'pc'. */
     160        static const char *platform = "pc";
     161
     162        sysinfo_set_item_data("platform", NULL, (void *) platform,
     163            str_size(platform));
     164
    159165#ifdef CONFIG_PC_KBD
    160166        /*
  • kernel/arch/ia64/src/ia64.c

    r78ffb70 reff1f033  
    147147void arch_post_smp_init(void)
    148148{
     149        static const char *platform;
     150
     151        /* Set platform name. */
     152#ifdef MACHINE_ski
     153        platform = "pc";
     154#endif
     155#ifdef MACHINE_i460GX
     156        platform = "i460GX";
     157#endif
     158        sysinfo_set_item_data("platform", NULL, (void *) platform,
     159            str_size(platform));
     160
    149161#ifdef MACHINE_ski
    150162        ski_instance_t *ski_instance = skiin_init();
  • kernel/arch/mips32/src/mips32.c

    r78ffb70 reff1f033  
    168168void arch_post_smp_init(void)
    169169{
     170        static const char *platform;
     171
     172        /* Set platform name. */
     173#ifdef MACHINE_msim
     174        platform = "msim";
     175#endif
     176#ifdef MACHINE_bgxemul
     177        platform = "gxemul";
     178#endif
     179#ifdef MACHINE_lgxemul
     180        platform = "gxemul";
     181#endif
     182        sysinfo_set_item_data("platform", NULL, (void *) platform,
     183            str_size(platform));
     184
    170185#ifdef CONFIG_MIPS_KBD
    171186        /*
  • kernel/arch/ppc32/src/ppc32.c

    r78ffb70 reff1f033  
    249249void arch_post_smp_init(void)
    250250{
     251        /* Currently the only supported platform for ppc32 is 'mac'. */
     252        static const char *platform = "mac";
     253
     254        sysinfo_set_item_data("platform", NULL, (void *) platform,
     255            str_size(platform));
     256
    251257        ofw_tree_walk_by_device_type("mac-io", macio_register, NULL);
    252258}
  • kernel/arch/sparc64/src/sun4u/sparc64.c

    r78ffb70 reff1f033  
    5050#include <ddi/irq.h>
    5151#include <str.h>
     52#include <sysinfo/sysinfo.h>
    5253
    5354memmap_t memmap;
     
    111112void arch_post_smp_init(void)
    112113{
     114        /* Currently the only supported platform for sparc64/sun4u is 'sun4u'. */
     115        static const char *platform = "sun4u";
     116
     117        sysinfo_set_item_data("platform", NULL, (void *) platform,
     118            str_size(platform));
     119
    113120        standalone_sparc64_console_init();
    114121}
  • kernel/arch/sparc64/src/sun4v/sparc64.c

    r78ffb70 reff1f033  
    5252#include <str.h>
    5353#include <arch/drivers/niagara.h>
     54#include <sysinfo/sysinfo.h>
    5455
    5556memmap_t memmap;
     
    109110void arch_post_smp_init(void)
    110111{
     112        /* Currently the only supported platform for sparc64/sun4v is 'sun4v'. */
     113        static const char *platform = "sun4v";
     114
     115        sysinfo_set_item_data("platform", NULL, (void *) platform,
     116            str_size(platform));
     117
    111118        niagarain_init();
    112119}
  • uspace/drv/root/root.c

    r78ffb70 reff1f033  
    4747#include <macros.h>
    4848#include <inttypes.h>
     49#include <sysinfo.h>
    4950
    5051#include <driver.h>
     
    5556
    5657#define PLATFORM_DEVICE_NAME "hw"
    57 #define PLATFORM_DEVICE_MATCH_ID STRING(UARCH)
     58#define PLATFORM_DEVICE_MATCH_ID_FMT "platform/%s"
    5859#define PLATFORM_DEVICE_MATCH_SCORE 100
    5960
     
    99100static int add_platform_child(device_t *parent)
    100101{
     102        char *match_id;
     103        char *platform;
     104        size_t platform_size;
     105        int res;
     106
     107        /* Get platform name from sysinfo. */
     108
     109        platform = sysinfo_get_data("platform", &platform_size);
     110        if (platform == NULL) {
     111                printf(NAME ": Failed to obtain platform name.\n");
     112                return ENOENT;
     113        }
     114
     115        /* Null-terminate string. */
     116        platform = realloc(platform, platform_size + 1);
     117        if (platform == NULL) {
     118                printf(NAME ": Memory allocation failed.\n");
     119                return ENOMEM;
     120        }
     121
     122        platform[platform_size] = '\0';
     123
     124        /* Construct match ID. */
     125
     126        if (asprintf(&match_id, PLATFORM_DEVICE_MATCH_ID_FMT, platform) == -1) {
     127                printf(NAME ": Memory allocation failed.\n");
     128                return ENOMEM;
     129        }
     130
     131        /* Add child. */
     132
    101133        printf(NAME ": adding new child for platform device.\n");
    102134        printf(NAME ":   device node is `%s' (%d %s)\n", PLATFORM_DEVICE_NAME,
    103             PLATFORM_DEVICE_MATCH_SCORE, PLATFORM_DEVICE_MATCH_ID);
    104        
    105         int res = child_device_register_wrapper(parent, PLATFORM_DEVICE_NAME,
    106             PLATFORM_DEVICE_MATCH_ID, PLATFORM_DEVICE_MATCH_SCORE);
     135            PLATFORM_DEVICE_MATCH_SCORE, match_id);
     136
     137        res = child_device_register_wrapper(parent, PLATFORM_DEVICE_NAME,
     138            match_id, PLATFORM_DEVICE_MATCH_SCORE);
    107139
    108140        return res;
  • uspace/drv/rootpc/rootpc.ma

    r78ffb70 reff1f033  
    1 10 ia32
    2 10 amd64
     110 platform/pc
Note: See TracChangeset for help on using the changeset viewer.