On Mon, Jan 21, 2013 at 05:22:44PM +0100, Andreas Färber wrote: > Am 21.01.2013 17:10, schrieb Eduardo Habkost: > > On Mon, Jan 21, 2013 at 12:28:21PM +0100, Andreas Färber wrote: > >> Am 17.01.2013 21:59, schrieb Eduardo Habkost: > >>> diff --git a/target-i386/topology.h b/target-i386/topology.h > >>> new file mode 100644 > >>> index 0000000..833ab47 > >>> --- /dev/null > >>> +++ b/target-i386/topology.h > >>> @@ -0,0 +1,133 @@ > >>> +/* > >>> + * x86 CPU topology data structures and functions > >>> + * > >>> + * Copyright (c) 2012 Red Hat Inc. > >>> + * > >>> + * Permission is hereby granted, free of charge, to any person obtaining > >>> a copy > >>> + * of this software and associated documentation files (the "Software"), > >>> to deal > >>> + * in the Software without restriction, including without limitation the > >>> rights > >>> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or > >>> sell > >>> + * copies of the Software, and to permit persons to whom the Software is > >>> + * furnished to do so, subject to the following conditions: > >>> + * > >>> + * The above copyright notice and this permission notice shall be > >>> included in > >>> + * all copies or substantial portions of the Software. > >>> + * > >>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, > >>> EXPRESS OR > >>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > >>> MERCHANTABILITY, > >>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT > >>> SHALL > >>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR > >>> OTHER > >>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, > >>> ARISING FROM, > >>> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER > >>> DEALINGS IN > >>> + * THE SOFTWARE. > >>> + */ > >>> +#ifndef TARGET_I386_TOPOLOGY_H > >>> +#define TARGET_I386_TOPOLOGY_H > >>> + > >>> +/* This file implements the APIC-ID-based CPU topology enumeration logic, > >>> + * documented at the following document: > >>> + * Intel® 64 Architecture Processor Topology Enumeration > >>> + * > >>> http://software.intel.com/en-us/articles/intel-64-architecture-processor-topology-enumeration/ > >>> + * > >>> + * This code should be compatible with AMD's "Extended Method" described > >>> at: > >>> + * AMD CPUID Specification (Publication #25481) > >>> + * Section 3: Multiple Core Calcuation > >>> + * as long as: > >>> + * nr_threads is set to 1; > >>> + * OFFSET_IDX is assumed to be 0; > >>> + * CPUID Fn8000_0008_ECX[ApicIdCoreIdSize[3:0]] is set to > >>> apicid_core_width(). > >>> + */ > >>> + > >>> +#include <stdint.h> > >>> +#include <string.h> > >>> + > >>> +#include "qemu/bitops.h" > >>> + > >>> +/* APIC IDs can be 32-bit, but beware: APIC IDs > 255 require x2APIC > >>> support > >>> + */ > >>> +typedef uint32_t apic_id_t; > >> > >> Is this file imported from somewhere? > > > > It's used by PATCH 12/12, when actually implementing the topology-aware > > APIC ID calculation in the CPU code. > > I meant, is this file/code from Linux or some other project? :) Or did > you write it from scratch? The commit message is a bit brief.
It was written from scratch. > > I was thinking about whether an x86_... function prefix would be needed, > but since these are static inline I think not. Even being inline static, they could conflict with functions from other headers if they are not unique. I plan to make them use a x86_ prefix in the next version. -- Eduardo