mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 18:21:39 +01:00
When the property "clock-frequency" is present in the DT timer node, it means that the bootloader/firmware didn't correctly configure the CNTFRQ/CNTFRQ_EL0 on each processor. The best solution would be to fix the offending firmware/bootloader, although it may not always be possible to modify and re-flash it. As it's not possible to trap the register CNTFRQ/CNTFRQ_EL0, we have to extend xen_arch_domainconfig to provide the timer frequency to the toolstack when the property "clock-frequency" is present to the host DT timer node. Then, a property "clock-frequency" will be created in the guest DT timer node if the value is not 0. We could have set the property in the guest DT no matter if the property is present in the host DT. Although, we still want to let the guest using CNTFRQ in normal case. After all, the property "clock-frequency" is just a workaround for buggy firmware. Also add a stub for fdt_property_u32 which is not present in libfdt < 1.4.0 used by distribution such as Debian Wheezy. Signed-off-by: Julien Grall <julien.grall@citrix.com> Tested-by: Chris Brand <chris.brand@broadcom.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> [ ijc -- ran autogen.sh ]
91 lines
3.5 KiB
C
91 lines
3.5 KiB
C
/*
|
|
* Copyright (C) 2006 David Gibson, IBM Corporation.
|
|
*
|
|
* This file is part of libxl, and was originally taken from libfdt.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published
|
|
* by the Free Software Foundation; version 2.1 only. with the special
|
|
* exception on linking described in file LICENSE.
|
|
*
|
|
* 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. See the
|
|
* GNU Lesser General Public License for more details.
|
|
*
|
|
* Additionally, this particular file is dual licensed. That is,
|
|
* alternatively, at your option:
|
|
*
|
|
* Redistribution and use in source and binary forms, with or
|
|
* without modification, are permitted provided that the following
|
|
* conditions are met:
|
|
*
|
|
* 1. Redistributions of source code must retain the above
|
|
* copyright notice, this list of conditions and the following
|
|
* disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above
|
|
* copyright notice, this list of conditions and the following
|
|
* disclaimer in the documentation and/or other materials
|
|
* provided with the distribution.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*
|
|
* Note that this applies only to this file, and other files with a
|
|
* similar notice. Also, note that when the same code is distributed
|
|
* along with the rest of libxl, you must comply with the terms of the
|
|
* LGPLv2.1 for the whole of libxl including this file.
|
|
*
|
|
* The intent is to permit, in particular, upstream libfdt to
|
|
* incorporate improvements to this file within upstream libfdt. At
|
|
* the time of writing, upstream libfdt is dual licensed: 2-clause BSD
|
|
* (as above) and GPLv2-or-later. The 2-clause BSD licence is
|
|
* compatible with both GPLv2-or-later and LGPLv2.1-only; this permits
|
|
* copying in both directions, and the optional licence upgrade to a
|
|
* copyleft licence by libdft upstream or the Xen Project,
|
|
* respectively.
|
|
*/
|
|
|
|
#ifndef LIBXL_LIBFDT_COMPAT_H
|
|
#define LIBXL_LIBFDT_COMPAT_H
|
|
|
|
#include "libxl_internal.h"
|
|
#include <libfdt.h>
|
|
|
|
#if !HAVE_DECL_FDT_FIRST_SUBNODE
|
|
_hidden int fdt_first_subnode(const void *fdt, int offset);
|
|
#endif
|
|
|
|
#if !HAVE_DECL_FDT_NEXT_SUBNODE
|
|
_hidden int fdt_next_subnode(const void *fdt, int offset);
|
|
#endif
|
|
|
|
#if !HAVE_DECL_FDT_PROPERTY_U32
|
|
static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val)
|
|
{
|
|
uint32_t tmp = cpu_to_fdt32(val);
|
|
return fdt_property(fdt, name, &tmp, sizeof(tmp));
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
/*
|
|
* Local variables:
|
|
* mode: C
|
|
* c-basic-offset: 4
|
|
* indent-tabs-mode: nil
|
|
* End:
|
|
*/
|