2018-03-07 20:57:14 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
|
|
*
|
2018-05-26 01:49:13 +08:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2018-03-07 20:57:14 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <hypervisor.h>
|
2018-07-30 15:56:59 +08:00
|
|
|
#include <softirq.h>
|
2018-03-07 20:57:14 +08:00
|
|
|
|
|
|
|
|
2018-07-30 15:58:36 +08:00
|
|
|
static softirq_handler softirq_handlers[NR_SOFTIRQS];
|
2018-03-07 20:57:14 +08:00
|
|
|
|
|
|
|
void init_softirq(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-07-30 15:58:36 +08:00
|
|
|
/*
|
|
|
|
* @pre: nr will not equal or large than NR_SOFTIRQS
|
|
|
|
*/
|
|
|
|
void register_softirq(uint16_t nr, softirq_handler handler)
|
2018-03-07 20:57:14 +08:00
|
|
|
{
|
2018-07-30 15:58:36 +08:00
|
|
|
softirq_handlers[nr] = handler;
|
|
|
|
}
|
2018-03-07 20:57:14 +08:00
|
|
|
|
2018-07-30 15:58:36 +08:00
|
|
|
/*
|
|
|
|
* @pre: nr will not equal or large than NR_SOFTIRQS
|
|
|
|
*/
|
|
|
|
void fire_softirq(uint16_t nr)
|
|
|
|
{
|
|
|
|
bitmap_set_lock(nr, &per_cpu(softirq_pending, get_cpu_id()));
|
2018-03-07 20:57:14 +08:00
|
|
|
}
|
|
|
|
|
2018-07-30 15:58:36 +08:00
|
|
|
void do_softirq(void)
|
2018-03-07 20:57:14 +08:00
|
|
|
{
|
2018-06-20 15:42:52 +08:00
|
|
|
uint16_t cpu_id = get_cpu_id();
|
2018-07-30 15:58:36 +08:00
|
|
|
volatile uint64_t *softirq_pending_bitmap =
|
|
|
|
&per_cpu(softirq_pending, cpu_id);
|
2018-11-30 16:31:16 +08:00
|
|
|
uint16_t nr = ffs64(*softirq_pending_bitmap);
|
2018-03-07 20:57:14 +08:00
|
|
|
|
2018-11-30 16:31:16 +08:00
|
|
|
while (nr < NR_SOFTIRQS) {
|
2018-07-30 15:58:36 +08:00
|
|
|
bitmap_clear_lock(nr, softirq_pending_bitmap);
|
|
|
|
(*softirq_handlers[nr])(cpu_id);
|
2018-11-30 16:31:16 +08:00
|
|
|
nr = ffs64(*softirq_pending_bitmap);
|
2018-03-07 20:57:14 +08:00
|
|
|
}
|
|
|
|
}
|