cregit-Linux how code gets into the kernel

Release 4.10 arch/sparc/kernel/devices.c

/* devices.c: Initial scan of the prom device tree for important
 *            Sparc device nodes which we need to find.
 *
 * This is based on the sparc64 version, but sun4m doesn't always use
 * the hardware MIDs, so be careful.
 *
 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
 */

#include <linux/kernel.h>
#include <linux/threads.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/errno.h>

#include <asm/page.h>
#include <asm/oplib.h>
#include <asm/prom.h>
#include <asm/smp.h>
#include <asm/cpudata.h>
#include <asm/cpu_type.h>
#include <asm/setup.h>

#include "kernel.h"


static char *cpu_mid_prop(void) { if (sparc_cpu_model == sun4d) return "cpu-id"; return "mid"; }

Contributors

PersonTokensPropCommitsCommitProp
keith m. wesolowskikeith m. wesolowski2095.24%150.00%
rob radezrob radez14.76%150.00%
Total21100.00%2100.00%


static int check_cpu_node(phandle nd, int *cur_inst, int (*compare)(phandle, int, void *), void *compare_arg, phandle *prom_node, int *mid) { if (!compare(nd, *cur_inst, compare_arg)) { if (prom_node) *prom_node = nd; if (mid) { *mid = prom_getintdefault(nd, cpu_mid_prop(), 0); if (sparc_cpu_model == sun4m) *mid &= 3; } return 0; } (*cur_inst)++; return -ENODEV; }

Contributors

PersonTokensPropCommitsCommitProp
keith m. wesolowskikeith m. wesolowski7974.53%120.00%
pre-gitpre-git2321.70%240.00%
andres salomonandres salomon32.83%120.00%
rob radezrob radez10.94%120.00%
Total106100.00%5100.00%


static int __cpu_find_by(int (*compare)(phandle, int, void *), void *compare_arg, phandle *prom_node, int *mid) { struct device_node *dp; int cur_inst; cur_inst = 0; for_each_node_by_type(dp, "cpu") { int err = check_cpu_node(dp->phandle, &cur_inst, compare, compare_arg, prom_node, mid); if (!err) { of_node_put(dp); return 0; } } return -ENODEV; }

Contributors

PersonTokensPropCommitsCommitProp
keith m. wesolowskikeith m. wesolowski6065.22%112.50%
david s. millerdavid s. miller1314.13%112.50%
pre-gitpre-git99.78%337.50%
julia lawalljulia lawall77.61%112.50%
andres salomonandres salomon22.17%112.50%
grant likelygrant likely11.09%112.50%
Total92100.00%8100.00%


static int cpu_instance_compare(phandle nd, int instance, void *_arg) { int desired_instance = (int) _arg; if (instance == desired_instance) return 0; return -ENODEV; }

Contributors

PersonTokensPropCommitsCommitProp
keith m. wesolowskikeith m. wesolowski3286.49%133.33%
pre-gitpre-git410.81%133.33%
andres salomonandres salomon12.70%133.33%
Total37100.00%3100.00%


int cpu_find_by_instance(int instance, phandle *prom_node, int *mid) { return __cpu_find_by(cpu_instance_compare, (void *)instance, prom_node, mid); }

Contributors

PersonTokensPropCommitsCommitProp
keith m. wesolowskikeith m. wesolowski2681.25%133.33%
pre-gitpre-git515.62%133.33%
andres salomonandres salomon13.12%133.33%
Total32100.00%3100.00%


static int cpu_mid_compare(phandle nd, int instance, void *_arg) { int desired_mid = (int) _arg; int this_mid; this_mid = prom_getintdefault(nd, cpu_mid_prop(), 0); if (this_mid == desired_mid || (sparc_cpu_model == sun4m && (this_mid & 3) == desired_mid)) return 0; return -ENODEV; }

Contributors

PersonTokensPropCommitsCommitProp
keith m. wesolowskikeith m. wesolowski5989.39%133.33%
pre-gitpre-git69.09%133.33%
andres salomonandres salomon11.52%133.33%
Total66100.00%3100.00%


int cpu_find_by_mid(int mid, phandle *prom_node) { return __cpu_find_by(cpu_mid_compare, (void *)mid, prom_node, NULL); }

Contributors

PersonTokensPropCommitsCommitProp
keith m. wesolowskikeith m. wesolowski2071.43%133.33%
pre-gitpre-git725.00%133.33%
andres salomonandres salomon13.57%133.33%
Total28100.00%3100.00%

/* sun4m uses truncated mids since we base the cpuid on the ttable/irqset * address (0-3). This gives us the true hardware mid, which might have * some other bits set. On 4d hardware and software mids are the same. */
int cpu_get_hwmid(phandle prom_node) { return prom_getintdefault(prom_node, cpu_mid_prop(), -ENODEV); }

Contributors

PersonTokensPropCommitsCommitProp
keith m. wesolowskikeith m. wesolowski1785.00%133.33%
pre-gitpre-git210.00%133.33%
andres salomonandres salomon15.00%133.33%
Total20100.00%3100.00%


void __init device_scan(void) { printk(KERN_NOTICE "Booting Linux...\n"); #ifndef CONFIG_SMP { phandle cpu_node; int err; err = cpu_find_by_instance(0, &cpu_node, NULL); if (err) { /* Probably a sun4e, Sun is trying to trick us ;-) */ prom_printf("No cpu nodes, cannot continue\n"); prom_halt(); } cpu_data(0).clock_tick = prom_getintdefault(cpu_node, "clock-frequency", 0); } #endif /* !CONFIG_SMP */ auxio_probe(); auxio_power_probe(); }

Contributors

PersonTokensPropCommitsCommitProp
keith m. wesolowskikeith m. wesolowski4153.25%112.50%
pre-gitpre-git3038.96%450.00%
andres salomonandres salomon33.90%112.50%
sam ravnborgsam ravnborg22.60%112.50%
david s. millerdavid s. miller11.30%112.50%
Total77100.00%8100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
keith m. wesolowskikeith m. wesolowski36169.42%15.00%
pre-gitpre-git10820.77%840.00%
david s. millerdavid s. miller173.27%210.00%
andres salomonandres salomon132.50%15.00%
sam ravnborgsam ravnborg81.54%315.00%
julia lawalljulia lawall71.35%15.00%
rob radezrob radez20.38%15.00%
david howellsdavid howells20.38%15.00%
linus torvaldslinus torvalds10.19%15.00%
grant likelygrant likely10.19%15.00%
Total520100.00%20100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.