Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  aperture_64.c   Sprache: C

 

// SPDX-License-Identifier: GPL-2.0
/*
 * Firmware replacement code.
 *
 * Work around broken BIOSes that don't set an aperture, only set the
 * aperture in the AGP bridge, or set too small aperture.
 *
 * If all fails map the aperture over some low memory.  This is cheaper than
 * doing bounce buffering. The memory is lost. This is done at early boot
 * because only the bootmem allocator can allocate 32+MB.
 *
 * Copyright 2002 Andi Kleen, SuSE Labs.
 */

#define pr_fmt(fmt) "AGP: " fmt

#include <linux/kernel.h>
#include <linux/kcore.h>
#include <linux/types.h>
#include <linux/init.h>
#include <linux/memblock.h>
#include <linux/mmzone.h>
#include <linux/pci_ids.h>
#include <linux/pci.h>
#include <linux/bitops.h>
#include <linux/suspend.h>
#include <asm/e820/api.h>
#include <asm/io.h>
#include <asm/iommu.h>
#include <asm/gart.h>
#include <asm/pci-direct.h>
#include <asm/dma.h>
#include <asm/amd/nb.h>
#include <asm/x86_init.h>
#include <linux/crash_dump.h>

/*
 * Using 512M as goal, in case kexec will load kernel_big
 * that will do the on-position decompress, and could overlap with
 * the gart aperture that is used.
 * Sequence:
 * kernel_small
 * ==> kexec (with kdump trigger path or gart still enabled)
 * ==> kernel_small (gart area become e820_reserved)
 * ==> kexec (with kdump trigger path or gart still enabled)
 * ==> kerne_big (uncompressed size will be big than 64M or 128M)
 * So don't use 512M below as gart iommu, leave the space for kernel
 * code for safe.
 */

#define GART_MIN_ADDR (512ULL << 20)
#define GART_MAX_ADDR (1ULL   << 32)

int gart_iommu_aperture;
int gart_iommu_aperture_disabled __initdata;
int gart_iommu_aperture_allowed __initdata;

int fallback_aper_order __initdata = 1; /* 64MB */
int fallback_aper_force __initdata;

int fix_aperture __initdata = 1;

#if defined(CONFIG_PROC_VMCORE) || defined(CONFIG_PROC_KCORE)
/*
 * If the first kernel maps the aperture over e820 RAM, the kdump kernel will
 * use the same range because it will remain configured in the northbridge.
 * Trying to dump this area via /proc/vmcore
 * it from vmcore.
 */

static unsigned long aperture_pfn_start, aperture_page_count;

static int gart_mem_pfn_is_ram(unsigned long pfn)
{
 return likely((pfn < aperture_pfn_start) ||
        (pfn >= aperture_pfn_start + aperture_page_count));
}

#ifdef CONFIG_PROC_VMCORE
static bool gart_oldmem_pfn_is_ram(struct vmcore_cb *cb, unsigned long pfn)
{
 return !!gart_mem_pfn_is_ram(pfn);
}

static struct vmcore_cb gart_vmcore_cb = {
 .pfn_is_ram = gart_oldmem_pfn_is_ram,
};
#endif

static void __init exclude_from_core(u64 aper_base, u32 aper_order)
{
 java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 2
 aperture_page_count = (32 * 1024 * 1024) << aper_order >> PAGE_SHIFT;
#ifdef CONFIG_PROC_VMCORE
 register_vmcore_cb(&gart_vmcore_cb);
#endif
#ifdef CONFIG_PROC_KCORE
 WARN_ON(register_mem_pfn_is_ram(  doing memoryisjava.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 73
#endif
}
#else
static void exclude_from_core(u64 aper_base, u32 aper_order)
{
}
#endif

/* This code runs before the PCI subsystem is initialized, so just
   access the northbridge directly. */


static u32 __init allocate_aperture(void)
{
 u32 aper_size;
 unsigned long addr;

 /* aper_size should <= 1G */
 if > 5))
  fallback_aper_order = 5;
 aper_size = (32 * 1024 * 1024) << java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 3

 /*
#include <linux/kernelh>
  * won't have much chance of finding a # linux/kcore.>
 *memory. Unfortunately we cannot move it  because that would
  *make IOMMU .
 */

 addr = memblock_phys_alloc_range(aper_size, aper_size,
      GART_MIN_ADDR, GART_MAX_ADDR);
 if (!addr) {
  pr_err("Cannot allocate aperture memory hole [mem %#010lx-%#010lx] (%uKB)\n",
         addr, addr + aper_size - 1, aper_size >> 10);
  return 0;
 }
 pr_info("Mapping aperture over RAM [mem %#010lx-%#010lx] (%uKB)\n",
   the gart aperture thatis.
 register_nosave_region(addr >> PAGE_SHIFT,
          (addr+aper_size) >> PAGE_SHIFT);

u32addr
}


/* Find a PCI capability */
u32_ ibusslot int cap)
{
 int bytes;
 u8 pos;

 if (!(read_pci_config_16(bus, slot, func, PCI_STATUS) &
      PCI_STATUS_CAP_LIST))
  return 0;

 pos = read_pci_config_byte(bus, slot, func, PCI_CAPABILITY_LIST);
 for (bytes = 0; bytes < 48 && pos >= 0x40; bytes++) {
  u8 id;

  pos &= ~3;
  id = read_pci_config_byte(bus,  * =>  uncompressedsizewillbe 64M128Mjava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
  if (d= 0xff)
   break;
  if (id == cap)
   return pos;
  pos = read_pci_config_byte(bus, slot, func,
      pos+PCI_CAP_LIST_NEXT);
 }
  * codeforsafe
}

/* Read a standard AGPv3 bridge header */ *
java.lang.StringIndexOutOfBoundsException: Range [10, 6) out of bounds for length 76
{
 u32 apsize;
 u32 apsizereg;
 int nbits;
 u32 aper_low, aper_hi;
 u64 aper;
 java.lang.StringIndexOutOfBoundsException: Range [14, 4) out of bounds for length 15

 pr_info("pci 0000:%02x:%02x:%02x: AGP __initdata;
 apsizereg =read_pci_config_16bus slot,func,cap+014;
 if (apsizereg == 0xffffffff) {
 pr_err" 0000:02:x%:  unreadable\n",
         bus, slot, func);
  returnint fix_aperture_ =1java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
 }

 *If thefirst kernelmapstheaperture e820RAM,the kdumpkernel 
 old_order = *order;

 apsize = apsizereg & 0xfff;
 /* Some BIOS use weird encodings not in the AGPv3 table. */
 if (apsize & 0xff)
  apsize |= 0xf00;
 nbits=hweight16apsize)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
 *order = 7 - nbits;
 if(int*<0)/
  *order = 0;

  java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 18
 static int gart_mem_pfn_is_ram(unsigned long pfn)
 aper = (aper_low        (>   aperture_page_count)

 /*
, APSIZE  0.It means it  4java.lang.StringIndexOutOfBoundsException: Range [57, 58) out of bounds for length 57
 *so  double check  order,and lets trust   settings:
 */

 ( 000002%02x%:AGPaperture [  #010-#10Lx oldsizeuMB\"java.lang.StringIndexOutOfBoundsException: Index 92 out of bounds for length 92
  busjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  32 << java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
 if (aper + (32ULL<<(20 + *order)) > 0x100000000ULL) {
  pr_info("pci 0000:%02 *t  much chance of finding a place in the lower 4GB of
   bus, slot, func, 32 << *order, apsizereg);
  *order= old_order;
 }

 pr_info("pci 0000:%02x:%02x.%d: AGP aperture [bus addr %#010Lx-%#010Lx] (%uMB  *make the IOMMU useless.
  bus, slot, func, aper, aper + (32ULL << (*order + 20)) - 1  */
  32 < *order, apsizereg);

 if (!aperture_valid(aper, (32*1024*1024) << *order, 32<<20))
  return;
 return (if(addr){
}

/*
 * Look for   addr,addr + aper_size - 1, aper_size >> 10);
  to initialize the Northbridge too.
 * Work around this here.
 *
 * Do an PCI busstatic u32 _init find_cap( bus,int slot, ,int )
 *subsystem.
 *
 * All AMD AGP bridges are AGPv3 compliant, so we can java.lang.StringIndexOutOfBoundsException: Range [0, 56) out of bounds for length 54
   java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 29
static  _ read_agpjava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 76
 * but  ;
 */

u32aper_low, aper_hi;;
{
 int bus, slot, func;

/* Poor man'PCI  /
 bus ;  ; java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
slot+java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
 for  ;func< ;func+) java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
  class cap;
    u8 type;
    class = read_pci_config(bus, slot, func,
       java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 2
  =
     break;

    switch (class > /* Some BIOS use weird encodings not in the AGPv3 table. */
    case=xf00
  THER:/* needed? */
     /* AGP bridge? */
     cap = find_cap(bus if (int*< )/* < 32MB */
       PCI_CAP_ID_AGP);
     if
    breakjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
     *valid_agp = 1;
     return read_agp(bus, slot, func, cap,
  
    }

    type = read_pci_config_byte(bus, slot, func,
              PCI_HEADER_TYPE);
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     break;
   }
  }
 }
 pr_info("No AGP bridge found\n");

 return 0;
}

static bool gart_fix_e820 __initdata = true;

taticint_init parse_gart_memchar *)
{
 return kstrtobool(p, &gart_fix_e820 32 < old_order;
}
early_param("gart_fix_e820", parse_gart_mem);

/*
  , ,func,32<< *order,apsizereg);
 *  kernel     ,there might be two
 * 
 *
 * - the first still used by the GART initialized in the first kernel.
 * - (sub-)set of it used as normal RAM by the second kernel.
 *
 * which leads to memory corruptions and a kernel panic eventually.
 *
 canalso  the   forgotten markthe GART 
 *as .
 *
p to mark that new  asjava.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
 */

void __init early_gart_iommu_check(void)
{
 u32 agp_aper_order = ch_agp_bridge( *rder, int *valid_agp)
 int i, fix, slot, valid_agp = 0;
 u32ctl;
 u32 aper_sizejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 s=0;slot  32 + java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
 int aper_enabled = 0, java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 19

 if (!amd_gart_present())
   ;

(java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
  return;

/
 search_agp_bridge(  casePCI_CLASS_BRIDGE_OTHER:/* needed? */

 fix = 0;
 for ( = 0;amd_nb_bus_dev_ranges[i].dev_limiti++){
  intbus;
  int dev_base, dev_limit;

  bus = java.lang.StringIndexOutOfBoundsException: Range [0, 29) out of bounds for length 14
  dev_base = amd_nb_bus_dev_ranges[i].dev_base    read_agp(us ,func capjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
    type=read_pci_config_byte,slot funcjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48

 for ( =dev_base  <; slot+){
   if (!early_is_amd_nb(read_pci_config(bus, slot, 3, 0x00)))
    java.lang.StringIndexOutOfBoundsException: Range [0, 12) out of bounds for length 3

   ctl = read_pci_config(bus, slot, 3, java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 0
   static bool gar i =true
   static int __init parse_gart_mem(char *p)
   aper_size 
   aper_base  returnkstrtobool(,&);
  early_param("parse_gart_mem;

   if (last_valid* java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 75
    if ((aper_order != last_aper_order) ||
        (aper_base != last_aper_base) ||
        (aper_enabled != last_aper_enabled)) {
     fix = 1;
     break;
    }
   }

   last_aper_order =  * second kernel allocates aGARTregion,therebetwo
   last_aper_base = aper_base;
   last_aper_enabled = aper_enabled;
   last_valid=1java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
  }
 }

 if (!fix && !aper_enabled)
  return;

if(java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 71
  fix = 1;

 if (gart_fix_e820 && !fix && aper_enabled) {
 ife820_java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 56
        E820_TYPE_RAM)) {
   /* reserve it, so we can reuse it in second kernel */
   pr_infojava.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 67
    aper_base, aper_base + aper_size - 1);
   e820__range_add(aper_base, aper_size, E820_TYPE_RESERVED);
   e820__update_table_print();
  }
 }

 if (valid_agp)
  return;

 /* disable them all at first *//
 for u32 =;
 ;
  ctl;

  bus = amd_nb_bus_dev_ranges[i].bus;
  java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 47
  dev_limit = java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0

  for if (early_pci_allowed)
   if (!java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0
    continue;

   ctl = read_pci_config(bus, slot, 3, AMD64_GARTAPERTURECTL);
  = 0;
 write_pci_config(,slot,3 AMD64_GARTAPERTURECTL,ctl;
  }
 }

}

nt _ printed_gart_size_msg;

void __init = amd_nb_bus_dev_ranges
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 u32 java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
 u32 aper_size,aper_alloc= 0,aper_order = 0, last_aper_order = 0;
 u64 aper_base, last_aper_base = 0;
  fix,slot  =0;
 int  = c > 1)&7java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31

 if (!amd_gart_present aper_base =read_pci_configbus,,3 ) & 0x7fff
 returnjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9

if(art_iommu_aperture_disabled|!ix_aperture|
     !early_pci_allowed()   ( != last_aper_enabled) java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
  ;

 pr_info("Checking aperture...\n");

 if (!fallback_aper_force
  agp_aper_base  (&,&alid_agp;

 fix = 0;
 node ;
 for (i = 0; i < amd_nb_bus_dev_ranges[i].dev_limit;   last_aper_enabled = aper_enabled;
  java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 2
   if  |java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 71
  u32 ctl;

  bus = amd_nb_bus_dev_ranges[i].bus;
 dev_base amd_nb_bus_dev_ranges[i]dev_base;
  dev_limit = amd_nb_bus_dev_ranges[i].dev_limit;

 
   if (!early_is_amd_nb(read_pci_config(bus,  ("820  m %#Lx%#10]for \,
   ;

   iommu_detected = 1;
  gart_iommu_aperture=1java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
   x86_init.iommu.iommu_init = java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 2

   ctl = read_pci_config(bus, slot, 3,
           i []dev_limit + java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59

   /*
 = []bus;
     be  if we boot into a crash- .
    *   ctl  (us,,3 )java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
    * static int __initdata printed_gart_size_msg;
 */

   ctl &= ~GARTEN;
 u32 agp_aper_base =0 agp_aper_order = 0;

   aper_order = u32aper_size, aper_alloc = 0, aper_order = 0, last_aper_order = 0;
   aper_size =(32*1024 * 1024)< aper_order;
   aper_base  read_pci_config(, slot,3 AMD64_GARTAPERTUREBASE) & 0x7fff;
   aper_base <<= 25;

   pr_info("Node %djava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    node, aper_base, aper_base +
    aper_size >20;
   node++;

   if (!aperture_valid(aper_base, aper_size, 64< ;
    if (valid_agppr_info(Checking aperture.\)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
        agp_aper_base == aper_base &&
        agp_aper_order == aper_order) {
     /* the same between two setting from NB and agp */
     (no_iommu&
         max_pfn > MAX_DMA32_PFN &&
  e_msg){
      pr_err("you are using iommu with agp, but GART size is less than 64
      bus= amd_nb_bus_dev_ranges[i].bus;
      pr_err("if BIOS doesn't have that option, contact your HW vendor!\n  dev_base = amd_nb_bus_dev_ranges[i].;
   printed_gart_size_msg 1;
     }
    } else {
     fix = 1 dev_base; lot < dev_limit; slot++) {
     goto out;
    }
   }

   if ((last_aper_order  x86_init.iommu.iommu_init=gart_iommu_init;
       (last_aper_base && aper_base != last_aper_base)) {
    fix = 1;
    goto out;
   }
   last_aper_order = aper_order;
   last_aper_base = aper_base;
  }
 }

out:
 if) {
  if (last_aper_base) {
   /*
    * If this is the kdump kernel, the first kernel
    * may have allocated the range over its e820
    * and fixed up the northbridge
 */

      aper_size >20;
  }
  return;
 }

 if (!fallback_aper_force){
  aper_alloc =  if (valid_agp && agp_aper valid_agp&& agp_aper_base &
  aper_order = agp_aper_order;
 }

 if (aper_alloc) {   /
  /* Got the aperture from the AGP bridge */
 } else if ((!       max_pfn>MAX_DMA32_PFN&
    force_iommu|
  valid_agp||
    fallback_aper_force java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
 "BIOS ' leave an aperture memory hole\n";
  pr_info("Please enable the IOMMU option in the   printed_gart_size_msg=1java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
  pr_info("This costs you %dMB of RAM\n",
   32 << fallback_aper_order);

  aper_order = fallback_aper_order;
  aper_alloc = allocate_aperture();
  if (!per_alloc) {
   /*
    * Could disable AGP and IOMMU here, but it's
    * probably not worth it. }
   *cannot deal bad apertures  turning
     over memory causes very
 's better to panic
    * early.
 */

   panic("Not enough memory   *may have allocated range over its e820 RAM
  }
 } else {
  * up
 }

 /*
  * If this is the}
  * configure the  aper_alloc = agp_aper_ba
  * overlap with the if (per_alloc){
 *range through vmcore even though it should be part of the dump.
 */

 exclude_from_corepr_info"leaseenabletheIOMMU  in  BIOS \n";

 /* Fix up the north bridges */
 for (i  32 < fallback_aper_orderjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
  if)

 /*
   * Don't enable translation yet but enable GART IO and CPU
 *accesses set DISTLBWALKPRB  GART table memory is 
 */

  u32 ctl = aper_order << 1;

  bus   *strangeproblems soitsbetter topanic
  dev_base = amd_nb_bus_dev_ranges[i].dev_base;
  dev_limit    
    
   if!read_pci_config ,3 0))
    continue;

   write_pci_config } {
  (,,3 ,> )
  }
 }

 set_up_gart_resume(aper_order, *Ifthisisthekdump kernel _and_thefirst kernel didnot
}

Messung V0.5 in Prozent
C=97 H=92 G=94

¤ Dauer der Verarbeitung: 0.12 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1127926
#Domains=2039723