1/* 2 * Copyright 2007, Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Fran��ois Revol <revol@free.fr> 7 * 8 * Copyright 2004, Axel D��rfler, axeld@pinc-software.de 9 * Distributed under the terms of the MIT License. 10 */ 11 12 13#include <KernelExport.h> 14 15#include <boot/stage2.h> 16#include <arch/smp.h> 17#include <debug.h> 18#include <int.h> 19 20#include <cpu.h> 21#include <platform/sbi/sbi_syscalls.h> 22 23 24extern uint32 gPlatform; 25 26 27status_t 28arch_smp_init(kernel_args *args) 29{ 30 dprintf("arch_smp_init()\n"); 31 return B_OK; 32} 33 34 35status_t 36arch_smp_per_cpu_init(kernel_args *args, int32 cpuId) 37{ 38 return B_OK; 39} 40 41 42void 43arch_smp_send_multicast_ici(CPUSet& cpuSet) 44{ 45 switch (gPlatform) { 46 case kPlatformSbi: { 47 uint64 hartMask = 0; 48 int32 cpuCount = smp_get_num_cpus(); 49 for (int32 i = 0; i < cpuCount; i++) { 50 if (cpuSet.GetBit(i) && i != smp_get_current_cpu()) 51 hartMask |= (uint64)1 << gCPU[i].arch.hartId; 52 } 53 // TODO: handle hart ID >= 64 54 sbi_send_ipi(hartMask, 0); 55 break; 56 } 57 case kPlatformMNative: 58 default: 59 dprintf("arch_smp_send_multicast_ici: not implemented\n"); 60 } 61#if KDEBUG 62 if (are_interrupts_enabled()) 63 panic("arch_smp_send_multicast_ici: called with interrupts enabled"); 64#endif 65} 66 67 68void 69arch_smp_send_ici(int32 target_cpu) 70{ 71 switch (gPlatform) { 72 case kPlatformSbi: 73 // dprintf("arch_smp_send_ici(%" B_PRId32 ")\n", target_cpu); 74 sbi_send_ipi((uint64)1 << gCPU[target_cpu].arch.hartId, 0); 75 break; 76 case kPlatformMNative: 77 default: 78 dprintf("arch_smp_send_ici: not implemented\n"); 79 } 80} 81 82 83void 84arch_smp_send_broadcast_ici() 85{ 86 switch (gPlatform) { 87 case kPlatformSbi: 88 // dprintf("arch_smp_send_broadcast_ici()\n"); 89 sbi_send_ipi(0, -1); 90 break; 91 case kPlatformMNative: 92 default: 93 dprintf("arch_smp_send_broadcast_ici: not implemented\n"); 94 } 95} 96