]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/mips/nlm/xlp_machdep.c
MFV r354378,r354379,r354386: 10499 Multi-modifier protection (MMP)
[FreeBSD/FreeBSD.git] / sys / mips / nlm / xlp_machdep.c
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright 2003-2011 Netlogic Microsystems (Netlogic). All rights
5  * reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are
9  * met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28  * THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * NETLOGIC_BSD */
31
32 #include <sys/cdefs.h>
33 __FBSDID("$FreeBSD$");
34
35 #include "opt_ddb.h"
36 #include "opt_platform.h"
37
38 #include <sys/param.h>
39 #include <sys/bus.h>
40 #include <sys/conf.h>
41 #include <sys/rtprio.h>
42 #include <sys/systm.h>
43 #include <sys/interrupt.h>
44 #include <sys/limits.h>
45 #include <sys/lock.h>
46 #include <sys/malloc.h>
47 #include <sys/mutex.h>
48 #include <sys/random.h>
49
50 #include <sys/cons.h>           /* cinit() */
51 #include <sys/kdb.h>
52 #include <sys/boot.h>
53 #include <sys/reboot.h>
54 #include <sys/queue.h>
55 #include <sys/smp.h>
56 #include <sys/timetc.h>
57
58 #include <vm/vm.h>
59 #include <vm/vm_param.h>
60 #include <vm/vm_page.h>
61 #include <vm/vm_phys.h>
62
63 #include <machine/cpu.h>
64 #include <machine/cpufunc.h>
65 #include <machine/cpuinfo.h>
66 #include <machine/tlb.h>
67 #include <machine/cpuregs.h>
68 #include <machine/frame.h>
69 #include <machine/hwfunc.h>
70 #include <machine/md_var.h>
71 #include <machine/asm.h>
72 #include <machine/pmap.h>
73 #include <machine/trap.h>
74 #include <machine/clock.h>
75 #include <machine/fls64.h>
76 #include <machine/intr_machdep.h>
77 #include <machine/smp.h>
78
79 #include <mips/nlm/hal/mips-extns.h>
80 #include <mips/nlm/hal/haldefs.h>
81 #include <mips/nlm/hal/iomap.h>
82 #include <mips/nlm/hal/sys.h>
83 #include <mips/nlm/hal/pic.h>
84 #include <mips/nlm/hal/uart.h>
85 #include <mips/nlm/hal/mmu.h>
86 #include <mips/nlm/hal/bridge.h>
87 #include <mips/nlm/hal/cpucontrol.h>
88 #include <mips/nlm/hal/cop2.h>
89
90 #include <mips/nlm/clock.h>
91 #include <mips/nlm/interrupt.h>
92 #include <mips/nlm/board.h>
93 #include <mips/nlm/xlp.h>
94 #include <mips/nlm/msgring.h>
95
96 #ifdef FDT
97 #include <dev/fdt/fdt_common.h>
98 #include <dev/ofw/openfirm.h>
99 #endif
100
101 /* 4KB static data aread to keep a copy of the bootload env until
102    the dynamic kenv is setup */
103 char boot1_env[4096];
104
105 uint64_t xlp_cpu_frequency;
106 uint64_t xlp_io_base = MIPS_PHYS_TO_DIRECT_UNCACHED(XLP_DEFAULT_IO_BASE);
107
108 int xlp_ncores;
109 int xlp_threads_per_core;
110 uint32_t xlp_hw_thread_mask;
111 int xlp_cpuid_to_hwtid[MAXCPU];
112 int xlp_hwtid_to_cpuid[MAXCPU];
113 uint64_t xlp_pic_base;
114
115 static int xlp_mmuval;
116
117 extern uint32_t _end;
118 extern char XLPResetEntry[], XLPResetEntryEnd[];
119
120 static void
121 xlp_setup_core(void)
122 {
123         uint64_t reg;
124
125         reg = nlm_mfcr(LSU_DEFEATURE);
126         /* Enable Unaligned and L2HPE */
127         reg |= (1 << 30) | (1 << 23);
128         /*
129          * Experimental : Enable SUE
130          * Speculative Unmap Enable. Enable speculative L2 cache request for
131          * unmapped access.
132          */
133         reg |= (1ull << 31);
134         /* Clear S1RCM  - A0 errata */
135         reg &= ~0xeull;
136         nlm_mtcr(LSU_DEFEATURE, reg);
137
138         reg = nlm_mfcr(SCHED_DEFEATURE);
139         /* Experimental: Disable BRU accepting ALU ops - A0 errata */
140         reg |= (1 << 24);
141         nlm_mtcr(SCHED_DEFEATURE, reg);
142 }
143
144 static void
145 xlp_setup_mmu(void)
146 {
147         uint32_t pagegrain;
148
149         if (nlm_threadid() == 0) {
150                 nlm_setup_extended_pagemask(0);
151                 nlm_large_variable_tlb_en(1);
152                 nlm_extended_tlb_en(1);
153                 nlm_mmu_setup(0, 0, 0);
154         }
155
156         /* Enable no-read, no-exec, large-physical-address */
157         pagegrain = mips_rd_pagegrain();
158         pagegrain |= (1U << 31) |       /* RIE */
159             (1 << 30)           |       /* XIE */
160             (1 << 29);                  /* ELPA */
161         mips_wr_pagegrain(pagegrain);
162 }
163
164 static void
165 xlp_enable_blocks(void)
166 {
167         uint64_t sysbase;
168         int i;
169
170         for (i = 0; i < XLP_MAX_NODES; i++) {
171                 if (!nlm_dev_exists(XLP_IO_SYS_OFFSET(i)))
172                         continue;
173                 sysbase = nlm_get_sys_regbase(i);
174                 nlm_sys_enable_block(sysbase, DFS_DEVICE_RSA);
175         }
176 }
177
178 static void
179 xlp_parse_mmu_options(void)
180 {
181         uint64_t sysbase;
182         uint32_t cpu_map = xlp_hw_thread_mask;
183         uint32_t core0_thr_mask, core_thr_mask, cpu_rst_mask;
184         int i, j, k;
185
186 #ifdef SMP
187         if (cpu_map == 0)
188                 cpu_map = 0xffffffff;
189 #else /* Uniprocessor! */
190         if (cpu_map == 0)
191                 cpu_map = 0x1;
192         else if (cpu_map != 0x1) {
193                 printf("WARNING: Starting uniprocessor kernel on cpumask [0x%lx]!\n"
194                     "WARNING: Other CPUs will be unused.\n", (u_long)cpu_map);
195                 cpu_map = 0x1;
196         }
197 #endif
198
199         xlp_ncores = 1;
200         core0_thr_mask = cpu_map & 0xf;
201         switch (core0_thr_mask) {
202         case 1:
203                 xlp_threads_per_core = 1;
204                 xlp_mmuval = 0;
205                 break;
206         case 3:
207                 xlp_threads_per_core = 2;
208                 xlp_mmuval = 2;
209                 break;
210         case 0xf:
211                 xlp_threads_per_core = 4;
212                 xlp_mmuval = 3;
213                 break;
214         default:
215                 goto unsupp;
216         }
217
218         /* Try to find the enabled cores from SYS block */
219         sysbase = nlm_get_sys_regbase(0);
220         cpu_rst_mask = nlm_read_sys_reg(sysbase, SYS_CPU_RESET) & 0xff;
221
222         /* XLP 416 does not report this correctly, fix */
223         if (nlm_processor_id() == CHIP_PROCESSOR_ID_XLP_416)
224                 cpu_rst_mask = 0xe;
225
226         /* Take out cores which do not exist on chip */
227         for (i = 1; i < XLP_MAX_CORES; i++) {
228                 if ((cpu_rst_mask & (1 << i)) == 0)
229                         cpu_map &= ~(0xfu << (4 * i));
230         }
231
232         /* Verify other cores' CPU masks */
233         for (i = 1; i < XLP_MAX_CORES; i++) {
234                 core_thr_mask = (cpu_map >> (4 * i)) & 0xf;
235                 if (core_thr_mask == 0)
236                         continue;
237                 if (core_thr_mask != core0_thr_mask)
238                         goto unsupp;
239                 xlp_ncores++;
240         }
241
242         xlp_hw_thread_mask = cpu_map;
243         /* setup hardware processor id to cpu id mapping */
244         for (i = 0; i< MAXCPU; i++)
245                 xlp_cpuid_to_hwtid[i] =
246                     xlp_hwtid_to_cpuid[i] = -1;
247         for (i = 0, k = 0; i < XLP_MAX_CORES; i++) {
248                 if (((cpu_map >> (i * 4)) & 0xf) == 0)
249                         continue;
250                 for (j = 0; j < xlp_threads_per_core; j++) {
251                         xlp_cpuid_to_hwtid[k] = i * 4 + j;
252                         xlp_hwtid_to_cpuid[i * 4 + j] = k;
253                         k++;
254                 }
255         }
256
257         return;
258
259 unsupp:
260         printf("ERROR : Unsupported CPU mask [use 1,2 or 4 threads per core].\n"
261             "\tcore0 thread mask [%lx], boot cpu mask [%lx].\n",
262             (u_long)core0_thr_mask, (u_long)cpu_map);
263         panic("Invalid CPU mask - halting.\n");
264         return;
265 }
266
267 #ifdef FDT
268 static void
269 xlp_bootargs_init(__register_t arg)
270 {
271         char    buf[2048]; /* early stack is big enough */
272         void    *dtbp;
273         phandle_t chosen;
274         ihandle_t mask;
275
276         dtbp = (void *)(intptr_t)arg;
277 #if defined(FDT_DTB_STATIC)
278         /*
279          * In case the device tree blob was not passed as argument try
280          * to use the statically embedded one.
281          */
282         if (dtbp == NULL)
283                 dtbp = &fdt_static_dtb;
284 #endif
285         if (OF_install(OFW_FDT, 0) == FALSE)
286                 while (1);
287         if (OF_init((void *)dtbp) != 0)
288                 while (1);
289         OF_interpret("perform-fixup", 0);
290
291         chosen = OF_finddevice("/chosen");
292         if (OF_getprop(chosen, "cpumask", &mask, sizeof(mask)) != -1) {
293                 xlp_hw_thread_mask = mask;
294         }
295
296         if (OF_getprop(chosen, "bootargs", buf, sizeof(buf)) != -1)
297                 boothowto |= boot_parse_cmdline(buf);
298 }
299 #else
300 /*
301  * arg is a pointer to the environment block, the format of the block is
302  * a=xyz\0b=pqr\0\0
303  */
304 static void
305 xlp_bootargs_init(__register_t arg)
306 {
307         char    buf[2048]; /* early stack is big enough */
308         char    *p, *v, *n;
309         uint32_t mask;
310
311         /*
312          * provide backward compat for passing cpu mask as arg
313          */
314         if (arg & 1) {
315                 xlp_hw_thread_mask = arg;
316                 return;
317         }
318
319         p = (void *)(intptr_t)arg;
320         while (*p != '\0') {
321                 strlcpy(buf, p, sizeof(buf));
322                 v = buf;
323                 n = strsep(&v, "=");
324                 if (v == NULL)
325                         kern_setenv(n, "1");
326                 else
327                         kern_setenv(n, v);
328                 p += strlen(p) + 1;
329         }
330
331         /* CPU mask can be passed thru env */
332         if (getenv_uint("cpumask", &mask) != 0)
333                 xlp_hw_thread_mask = mask;
334
335         /* command line argument */
336         v = kern_getenv("bootargs");
337         if (v != NULL) {
338                 strlcpy(buf, v, sizeof(buf));
339                 boothowto |= boot_parse_cmdline(buf);
340                 freeenv(v);
341         }
342 }
343 #endif
344
345 static void
346 mips_init(void)
347 {
348         init_param1();
349         init_param2(physmem);
350
351         mips_cpu_init();
352         cpuinfo.cache_coherent_dma = TRUE;
353         pmap_bootstrap();
354         mips_proc0_init();
355         mutex_init();
356 #ifdef DDB
357         kdb_init();
358         if (boothowto & RB_KDB) {
359                 kdb_enter("Boot flags requested debugger", NULL);
360         }
361 #endif
362 }
363
364 unsigned int
365 platform_get_timecount(struct timecounter *tc __unused)
366 {
367         uint64_t count = nlm_pic_read_timer(xlp_pic_base, PIC_CLOCK_TIMER);
368
369         return (unsigned int)~count;
370 }
371
372 static void
373 xlp_pic_init(void)
374 {
375         struct timecounter pic_timecounter = {
376                 platform_get_timecount, /* get_timecount */
377                 0,                      /* no poll_pps */
378                 ~0U,                    /* counter_mask */
379                 XLP_IO_CLK,            /* frequency */
380                 "XLRPIC",               /* name */
381                 2000,                   /* quality (adjusted in code) */
382         };
383         int i;
384         int maxirt;
385
386         xlp_pic_base = nlm_get_pic_regbase(0);  /* TOOD: Add other nodes */
387         maxirt = nlm_read_reg(nlm_get_pic_pcibase(nlm_nodeid()),
388             XLP_PCI_DEVINFO_REG0);
389         printf("Initializing PIC...@%jx %d IRTs\n", (uintmax_t)xlp_pic_base,
390             maxirt);
391         /* Bind all PIC irqs to cpu 0 */
392         for (i = 0; i < maxirt; i++)
393             nlm_pic_write_irt(xlp_pic_base, i, 0, 0, 1, 0,
394             1, 0, 0x1);
395
396         nlm_pic_set_timer(xlp_pic_base, PIC_CLOCK_TIMER, ~0ULL, 0, 0);
397         platform_timecounter = &pic_timecounter;
398 }
399
400 #if defined(__mips_n32) || defined(__mips_n64) /* PHYSADDR_64_BIT */
401 #ifdef XLP_SIM
402 #define XLP_MEM_LIM     0x200000000ULL
403 #else
404 #define XLP_MEM_LIM     0x10000000000ULL
405 #endif
406 #else
407 #define XLP_MEM_LIM     0xfffff000UL
408 #endif
409 static vm_paddr_t xlp_mem_excl[] = {
410         0,          0,          /* for kernel image region, see xlp_mem_init */
411         0x0c000000, 0x14000000, /* uboot area, cms queue and other stuff */
412         0x1fc00000, 0x1fd00000, /* reset vec */
413         0x1e000000, 0x1e200000, /* poe buffers */
414 };
415
416 static int
417 mem_exclude_add(vm_paddr_t *avail, vm_paddr_t mstart, vm_paddr_t mend)
418 {
419         int i, pos;
420
421         pos = 0;
422         for (i = 0; i < nitems(xlp_mem_excl); i += 2) {
423                 if (mstart > xlp_mem_excl[i + 1])
424                         continue;
425                 if (mstart < xlp_mem_excl[i]) {
426                         avail[pos++] = mstart;
427                         if (mend < xlp_mem_excl[i])
428                                 avail[pos++] = mend;
429                         else
430                                 avail[pos++] = xlp_mem_excl[i];
431                 }
432                 mstart = xlp_mem_excl[i + 1];
433                 if (mend <= mstart)
434                         break;
435         }
436         if (mstart < mend) {
437                 avail[pos++] = mstart;
438                 avail[pos++] = mend;
439         }
440         return (pos);
441 }
442
443 static void
444 xlp_mem_init(void)
445 {
446         vm_paddr_t physsz, tmp;
447         uint64_t bridgebase, base, lim, val;
448         int i, j, k, n;
449
450         /* update kernel image area in exclude regions */
451         tmp = (vm_paddr_t)MIPS_KSEG0_TO_PHYS(&_end);
452         tmp = round_page(tmp) + 0x20000; /* round up */
453         xlp_mem_excl[1] = tmp;
454
455         printf("Memory (from DRAM BARs):\n");
456         bridgebase = nlm_get_bridge_regbase(0); /* TODO: Add other nodes */
457         physsz = 0;
458         for (i = 0, j = 0; i < 8; i++) {
459                 val = nlm_read_bridge_reg(bridgebase, BRIDGE_DRAM_BAR(i));
460                 val = (val >>  12) & 0xfffff;
461                 base = val << 20;
462                 val = nlm_read_bridge_reg(bridgebase, BRIDGE_DRAM_LIMIT(i));
463                 val = (val >>  12) & 0xfffff;
464                 if (val == 0)   /* BAR not enabled */
465                         continue;
466                 lim = (val + 1) << 20;
467                 printf("  BAR %d: %#jx - %#jx : ", i, (intmax_t)base,
468                     (intmax_t)lim);
469
470                 if (lim <= base) {
471                         printf("\tskipped - malformed %#jx -> %#jx\n",
472                             (intmax_t)base, (intmax_t)lim);
473                         continue;
474                 } else if (base >= XLP_MEM_LIM) {
475                         printf(" skipped - outside usable limit %#jx.\n",
476                             (intmax_t)XLP_MEM_LIM);
477                         continue;
478                 } else if (lim >= XLP_MEM_LIM) {
479                         lim = XLP_MEM_LIM;
480                         printf(" truncated to %#jx.\n", (intmax_t)XLP_MEM_LIM);
481                 } else
482                         printf(" usable\n");
483
484                 /* exclude unusable regions from BAR and add rest */
485                 n = mem_exclude_add(&phys_avail[j], base, lim);
486                 for (k = j; k < j + n; k += 2) {
487                         physsz += phys_avail[k + 1] - phys_avail[k];
488                         printf("\tMem[%d]: %#jx - %#jx\n", k/2,
489                             (intmax_t)phys_avail[k], (intmax_t)phys_avail[k+1]);
490                 }
491                 j = k;
492         }
493
494         /* setup final entry with 0 */
495         phys_avail[j] = phys_avail[j + 1] = 0;
496
497         /* copy phys_avail to dump_avail */
498         for (i = 0; i <= j + 1; i++)
499                 dump_avail[i] = phys_avail[i];
500
501         realmem = physmem = btoc(physsz);
502 }
503
504 void
505 platform_start(__register_t a0 __unused,
506     __register_t a1 __unused,
507     __register_t a2 __unused,
508     __register_t a3 __unused)
509 {
510
511         /* Initialize pcpu stuff */
512         mips_pcpu0_init();
513
514         /* initialize console so that we have printf */
515         boothowto |= (RB_SERIAL | RB_MULTIPLE); /* Use multiple consoles */
516
517         init_static_kenv(boot1_env, sizeof(boot1_env));
518         xlp_bootargs_init(a0);
519
520         /* clockrate used by delay, so initialize it here */
521         xlp_cpu_frequency = xlp_get_cpu_frequency(0, 0);
522         cpu_clock = xlp_cpu_frequency / 1000000;
523         mips_timer_early_init(xlp_cpu_frequency);
524
525         /* Init console please */
526         cninit();
527
528         /* Early core init and fixes for errata */
529         xlp_setup_core();
530
531         xlp_parse_mmu_options();
532         xlp_mem_init();
533
534         bcopy(XLPResetEntry, (void *)MIPS_RESET_EXC_VEC,
535               XLPResetEntryEnd - XLPResetEntry);
536 #ifdef SMP
537         /*
538          * We will enable the other threads in core 0 here
539          * so that the TLB and cache info is correct when
540          * mips_init runs
541          */
542         xlp_enable_threads(xlp_mmuval);
543 #endif
544         /* setup for the startup core */
545         xlp_setup_mmu();
546
547         xlp_enable_blocks();
548
549         /* Read/Guess/setup board information */
550         nlm_board_info_setup();
551
552         /* MIPS generic init */
553         mips_init();
554
555         /*
556          * XLP specific post initialization
557          * initialize other on chip stuff
558          */
559         xlp_pic_init();
560
561         mips_timer_init_params(xlp_cpu_frequency, 0);
562 }
563
564 void
565 platform_cpu_init()
566 {
567 }
568
569 void
570 platform_reset(void)
571 {
572         uint64_t sysbase = nlm_get_sys_regbase(0);
573
574         nlm_write_sys_reg(sysbase, SYS_CHIP_RESET, 1);
575         for( ; ; )
576                 __asm __volatile("wait");
577 }
578
579 #ifdef SMP
580 /*
581  * XLP threads are started simultaneously when we enable threads, this will
582  * ensure that the threads are blocked in platform_init_ap, until they are
583  * ready to proceed to smp_init_secondary()
584  */
585 static volatile int thr_unblock[4];
586
587 int
588 platform_start_ap(int cpuid)
589 {
590         uint32_t coremask, val;
591         uint64_t sysbase = nlm_get_sys_regbase(0);
592         int hwtid = xlp_cpuid_to_hwtid[cpuid];
593         int core, thr;
594
595         core = hwtid / 4;
596         thr = hwtid % 4;
597         if (thr == 0) {
598                 /* First thread in core, do core wake up */
599                 coremask = 1u << core;
600
601                 /* Enable core clock */
602                 val = nlm_read_sys_reg(sysbase, SYS_CORE_DFS_DIS_CTRL);
603                 val &= ~coremask;
604                 nlm_write_sys_reg(sysbase, SYS_CORE_DFS_DIS_CTRL, val);
605
606                 /* Remove CPU Reset */
607                 val = nlm_read_sys_reg(sysbase, SYS_CPU_RESET);
608                 val &=  ~coremask & 0xff;
609                 nlm_write_sys_reg(sysbase, SYS_CPU_RESET, val);
610
611                 if (bootverbose)
612                         printf("Waking up core %d ...", core);
613
614                 /* Poll for CPU to mark itself coherent */
615                 do {
616                         val = nlm_read_sys_reg(sysbase, SYS_CPU_NONCOHERENT_MODE);
617                 } while ((val & coremask) != 0);
618                 if (bootverbose)
619                         printf("Done\n");
620         } else {
621                 /* otherwise release the threads stuck in platform_init_ap */
622                 thr_unblock[thr] = 1;
623         }
624
625         return (0);
626 }
627
628 void
629 platform_init_ap(int cpuid)
630 {
631         uint32_t stat;
632         int thr;
633
634         /* The first thread has to setup the MMU and enable other threads */
635         thr = nlm_threadid();
636         if (thr == 0) {
637                 xlp_setup_core();
638                 xlp_enable_threads(xlp_mmuval);
639         } else {
640                 /*
641                  * FIXME busy wait here eats too many cycles, especially
642                  * in the core 0 while bootup
643                  */
644                 while (thr_unblock[thr] == 0)
645                         __asm__ __volatile__ ("nop;nop;nop;nop");
646                 thr_unblock[thr] = 0;
647         }
648
649         xlp_setup_mmu();
650         stat = mips_rd_status();
651         KASSERT((stat & MIPS_SR_INT_IE) == 0,
652             ("Interrupts enabled in %s!", __func__));
653         stat |= MIPS_SR_COP_2_BIT | MIPS_SR_COP_0_BIT;
654         mips_wr_status(stat);
655
656         nlm_write_c0_eimr(0ull);
657         xlp_enable_irq(IRQ_IPI);
658         xlp_enable_irq(IRQ_TIMER);
659         xlp_enable_irq(IRQ_MSGRING);
660
661         return;
662 }
663
664 int
665 platform_ipi_hardintr_num(void)
666 {
667
668         return (IRQ_IPI);
669 }
670
671 int
672 platform_ipi_softintr_num(void)
673 {
674
675         return (-1);
676 }
677
678 void
679 platform_ipi_send(int cpuid)
680 {
681
682         nlm_pic_send_ipi(xlp_pic_base, xlp_cpuid_to_hwtid[cpuid],
683             platform_ipi_hardintr_num(), 0);
684 }
685
686 void
687 platform_ipi_clear(void)
688 {
689 }
690
691 int
692 platform_processor_id(void)
693 {
694
695         return (xlp_hwtid_to_cpuid[nlm_cpuid()]);
696 }
697
698 void
699 platform_cpu_mask(cpuset_t *mask)
700 {
701         int i, s;
702
703         CPU_ZERO(mask);
704         s = xlp_ncores * xlp_threads_per_core;
705         for (i = 0; i < s; i++)
706                 CPU_SET(i, mask);
707 }
708
709 struct cpu_group *
710 platform_smp_topo()
711 {
712
713         return (smp_topo_2level(CG_SHARE_L2, xlp_ncores, CG_SHARE_L1,
714                 xlp_threads_per_core, CG_FLAG_THREAD));
715 }
716 #endif