ioapic.c 781 B

123456789101112131415161718192021222324252627282930313233343536
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
  4. */
  5. #include <common.h>
  6. #include <asm/io.h>
  7. #include <asm/ioapic.h>
  8. #include <asm/lapic.h>
  9. u32 io_apic_read(u32 reg)
  10. {
  11. writel(reg, IO_APIC_INDEX);
  12. return readl(IO_APIC_DATA);
  13. }
  14. void io_apic_write(u32 reg, u32 val)
  15. {
  16. writel(reg, IO_APIC_INDEX);
  17. writel(val, IO_APIC_DATA);
  18. }
  19. void io_apic_set_id(int ioapic_id)
  20. {
  21. int bsp_lapicid = lapicid();
  22. debug("IOAPIC: Initialising IOAPIC at %08x\n", IO_APIC_ADDR);
  23. debug("IOAPIC: Bootstrap Processor Local APIC = %#02x\n", bsp_lapicid);
  24. if (ioapic_id) {
  25. debug("IOAPIC: ID = 0x%02x\n", ioapic_id);
  26. /* Set IOAPIC ID if it has been specified */
  27. io_apic_write(0x00, (io_apic_read(0x00) & 0xf0ffffff) |
  28. (ioapic_id << 24));
  29. }
  30. }