cregit-Linux how code gets into the kernel

Release 4.14 arch/sparc/kernel/devices.c

// SPDX-License-Identifier: GPL-2.0
/* 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. Wesolowski2095.24%150.00%
Rob 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. Wesolowski7974.53%120.00%
Linus Torvalds (pre-git)2321.70%240.00%
Andres Salomon32.83%120.00%
Rob 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. Wesolowski6166.30%112.50%
David S. Miller1314.13%112.50%
Linus Torvalds (pre-git)88.70%337.50%
Julia Lawall77.61%112.50%
Andres Salomon22.17%112.50%
Grant C. 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. Wesolowski3286.49%133.33%
Linus Torvalds (pre-git)410.81%133.33%
Andres 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. Wesolowski2681.25%133.33%
Linus Torvalds (pre-git)515.62%133.33%
Andres 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. Wesolowski5989.39%133.33%
Linus Torvalds (pre-git)69.09%133.33%
Andres 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. Wesolowski2071.43%133.33%
Linus Torvalds (pre-git)725.00%133.33%
Andres 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. Wesolowski1785.00%133.33%
Linus Torvalds (pre-git)210.00%133.33%
Andres 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. Wesolowski4153.25%114.29%
Linus Torvalds (pre-git)3038.96%342.86%
Andres Salomon33.90%114.29%
Sam Ravnborg22.60%114.29%
David S. Miller11.30%114.29%
Total77100.00%7100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Keith M. Wesolowski36269.48%14.76%
Linus Torvalds (pre-git)10720.54%838.10%
David S. Miller173.26%29.52%
Andres Salomon132.50%14.76%
Sam Ravnborg81.54%314.29%
Julia Lawall71.34%14.76%
Rob Radez20.38%14.76%
David Howells20.38%14.76%
Linus Torvalds10.19%14.76%
Grant C. Likely10.19%14.76%
Greg Kroah-Hartman10.19%14.76%
Total521100.00%21100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.