blob: e1f10cb1f244482907b17d68870c749f6f5e480e [file] [log] [blame]
/* system.c - system/hardware module for the ia32 platform */
/*
* Copyright (c) 2011-2015, Wind River Systems, Inc.
*
* 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.
*
* 3) Neither the name of Wind River Systems nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 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 HOLDER 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.
*/
/*
DESCRIPTION
This module provides routines to initialize and support board-level hardware
for the ia32 platform.
*/
#include <nanokernel.h>
#include "board.h"
#include <drivers/uart.h>
#include <drivers/pic.h>
#include <device.h>
#include <init.h>
#include <loapic.h>
#include <drivers/ioapic.h>
#include <drivers/hpet.h>
/**
*
* @brief Perform basic hardware initialization
*
* Initialize the interrupt controller and UARTs present in the
* platform.
*
* @return 0
*/
static int ia32_init(struct device *arg)
{
ARG_UNUSED(arg);
return 0;
}
#ifdef CONFIG_CONSOLE_HANDLER
static int console_irq_set(struct device *unsued)
{
#if defined(CONFIG_UART_CONSOLE)
_ioapic_irq_set(CONFIG_UART_CONSOLE_IRQ,
CONFIG_UART_CONSOLE_IRQ + INT_VEC_IRQ0,
UART_IOAPIC_FLAGS);
#endif
return 0;
}
DECLARE_DEVICE_INIT_CONFIG(consoleirq, "", console_irq_set, NULL);
pre_kernel_late_init(consoleirq, NULL);
#endif /* CONFIG_CONSOLE_HANDLER */
#ifdef CONFIG_HPET_TIMER
static int hpet_irq_set(struct device *unused)
{
ARG_UNUSED(unused);
_ioapic_irq_set(CONFIG_HPET_TIMER_IRQ,
CONFIG_HPET_TIMER_IRQ + INT_VEC_IRQ0,
HPET_IOAPIC_FLAGS);
return 0;
}
DECLARE_DEVICE_INIT_CONFIG(hpetirq, "", hpet_irq_set, NULL);
pre_kernel_late_init(hpetirq, NULL);
#endif /* CONFIG_HPET_TIMER */
#ifdef CONFIG_IOAPIC
DECLARE_DEVICE_INIT_CONFIG(ioapic_0, "", _ioapic_init, NULL);
pre_kernel_core_init(ioapic_0, NULL);
#endif /* CONFIG_IOAPIC */
#ifdef CONFIG_LOAPIC
DECLARE_DEVICE_INIT_CONFIG(loapic_0, "", _loapic_init, NULL);
pre_kernel_core_init(loapic_0, NULL);
#endif /* CONFIG_LOAPIC */
#if defined(CONFIG_PIC_DISABLE)
DECLARE_DEVICE_INIT_CONFIG(pic_0, "", _i8259_init, NULL);
pre_kernel_core_init(pic_0, NULL);
#endif /* CONFIG_PIC_DISABLE */
DECLARE_DEVICE_INIT_CONFIG(ia32_0, "", ia32_init, NULL);
pre_kernel_early_init(ia32_0, NULL);