Hello, Damien Zammit, le sam. 21 janv. 2023 08:04:59 +0000, a ecrit: > --- > i386/i386/apic.c | 87 ++++++++++++++++++++++++++++++---- > i386/i386/apic.h | 110 +++++++++++++++++++++++++++++++++++++++++-- > i386/i386/smp.c | 89 +++++++++++++++++++++++++++++++++- > i386/i386/smp.h | 7 +++ > i386/i386at/ioapic.c | 103 ++++++++++++---------------------------- > 5 files changed, 308 insertions(+), 88 deletions(-) > > diff --git a/i386/i386/apic.c b/i386/i386/apic.c > index d30084e2..78a2d006 100644 > --- a/i386/i386/apic.c > +++ b/i386/i386/apic.c > @@ -1,5 +1,5 @@ > /* apic.c - APIC controller management for Mach. > - Copyright (C) 2020 Free Software Foundation, Inc. > + Copyright (C) 2021 Free Software Foundation, Inc. > Written by Almudena Garcia Jurado-Centurion > > This file is part of GNU Mach.
? That really was committed in 2020. > @@ -116,11 +118,29 @@ uint16_t > apic_get_cpu_apic_id(int kernel_id) > { > if (kernel_id >= NCPUS) > - return -1; > + return 0; > > return apic_data.cpu_lapic_list[kernel_id]; > } > > + > +/* > + * apic_get_cpu_kernel_id: returns the kernel_id of a cpu. > + * Receives as input the APIC ID of a CPU. > + */ > +int > +apic_get_cpu_kernel_id(uint16_t apic_id) > +{ > + int i; > + > + for (i = 0; i < apic_data.ncpus; i++) { > + if (apic_data.cpu_lapic_list[i] == apic_id) > + return i; > + } > + > + return 0; As already mentioned, we do want to have a different value (here, -1) when unexpected things happen. Yes, it means the caller has to cope with such case. We do want to catch such cases otherwise we'll get bitten by bugs whenever they happen. Samuel