Commit de642de7 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] i386 driverfs Topology

From Matthew Dobson.

Update/Create i386 specific files for DriverFS Topology.

This patch creates the i386 specific files/functions/structures to
implement driverfs Topology.  These structures have the generic
CPU/MemBlk/Node structures embedded in them.

This patch also creates the arch-specific initialization routine to
instantiate the topology.
parent dc909f53
......@@ -4,6 +4,6 @@
EXTRA_CFLAGS += -I../kernel
obj-y := setup.o
obj-y := setup.o topology.o
include $(TOPDIR)/Rules.make
/*
* arch/i386/mach-generic/topology.c - Populate driverfs with topology information
*
* Written by: Matthew Dobson, IBM Corporation
* Original Code: Paul Dorwin, IBM Corporation, Patrick Mochel, OSDL
*
* Copyright (C) 2002, IBM Corp.
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
* NON INFRINGEMENT. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Send feedback to <colpatch@us.ibm.com>
*/
#include <linux/init.h>
#include <asm/cpu.h>
struct i386_cpu cpu_devices[NR_CPUS];
#ifdef CONFIG_NUMA
#include <linux/mmzone.h>
#include <asm/node.h>
#include <asm/memblk.h>
struct i386_node node_devices[MAX_NUMNODES];
struct i386_memblk memblk_devices[MAX_NR_MEMBLKS];
extern int numnodes;
static int __init topology_init(void)
{
int i;
for (i = 0; i < numnodes; i++)
arch_register_node(i);
for (i = 0; i < NR_CPUS; i++)
if (cpu_possible(i)) arch_register_cpu(i);
for (i = 0; i < numnodes; i++)
arch_register_memblk(i);
return 0;
}
#else /* !CONFIG_NUMA */
static int __init topology_init(void)
{
int i;
for (i = 0; i < NR_CPUS; i++)
if (cpu_possible(i)) arch_register_cpu(i);
return 0;
}
#endif /* CONFIG_NUMA */
subsys_initcall(topology_init);
#ifndef _ASM_I386_CPU_H_
#define _ASM_I386_CPU_H_
#include <linux/device.h>
#include <linux/cpu.h>
#include <asm/topology.h>
#include <asm/node.h>
struct i386_cpu {
struct cpu cpu;
};
extern struct i386_cpu cpu_devices[NR_CPUS];
#ifdef CONFIG_NUMA
static inline void arch_register_cpu(int num){
int p_node = __cpu_to_node(num);
if (p_node >= 0 && p_node < NR_CPUS)
register_cpu(&cpu_devices[num].cpu, num,
&node_devices[p_node].node);
}
#else /* !CONFIG_NUMA */
static inline void arch_register_cpu(int num){
register_cpu(&cpu_devices[num].cpu, num, (struct node *) NULL);
}
#endif /* CONFIG_NUMA */
#endif /* _ASM_I386_CPU_H_ */
#ifndef _ASM_I386_MEMBLK_H_
#define _ASM_I386_MEMBLK_H_
#include <linux/device.h>
#include <linux/mmzone.h>
#include <linux/memblk.h>
#include <asm/topology.h>
#include <asm/node.h>
struct i386_memblk {
struct memblk memblk;
};
extern struct i386_memblk memblk_devices[MAX_NR_MEMBLKS];
static inline void arch_register_memblk(int num){
int p_node = __memblk_to_node(num);
if (p_node >= 0 && p_node < MAX_NR_MEMBLKS)
register_memblk(&memblk_devices[num].memblk, num,
&node_devices[p_node].node);
}
#endif /* _ASM_I386_MEMBLK_H_ */
#ifndef _ASM_I386_NODE_H_
#define _ASM_I386_NODE_H_
#include <linux/device.h>
#include <linux/mmzone.h>
#include <linux/node.h>
#include <asm/topology.h>
struct i386_node {
struct node node;
};
extern struct i386_node node_devices[MAX_NUMNODES];
static inline void arch_register_node(int num){
int p_node = __parent_node(num);
if (p_node != num)
register_node(&node_devices[num].node, num,
&node_devices[p_node].node);
else
register_node(&node_devices[num].node, num,
(struct node *) NULL);
}
#endif /* _ASM_I386_NODE_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment