Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions include/zone_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
#define MEM_TYPE_VIRTIO 2

#define CONFIG_MAX_MEMORY_REGIONS 64
#define CONFIG_MAX_INTERRUPTS 32

typedef __u32 BitmapWord;
#define CONFIG_MAX_INTERRUPTS 1024
#define CONFIG_INTERRUPTS_BITMAP_BITS_PER_WORD 32

#define CONFIG_MAX_ZONES 32
#define CONFIG_NAME_MAXLEN 32
#define CONFIG_MAX_PCI_DEV 32
Expand Down Expand Up @@ -123,7 +127,7 @@ struct ivc_config {
};
typedef struct ivc_config ivc_config_t;

#define CONFIG_MAGIC_VERSION 0x03
#define CONFIG_MAGIC_VERSION 0x04

// Every time you change the struct, you should also change the
// `CONFIG_MAGIC_VERSION`
Expand All @@ -132,8 +136,8 @@ struct zone_config {
__u64 cpus;
__u32 num_memory_regions;
memory_region_t memory_regions[CONFIG_MAX_MEMORY_REGIONS];
__u32 num_interrupts;
__u32 interrupts[CONFIG_MAX_INTERRUPTS];
BitmapWord interrupts_bitmap[CONFIG_MAX_INTERRUPTS /
CONFIG_INTERRUPTS_BITMAP_BITS_PER_WORD];
__u32 num_ivc_configs;
ivc_config_t ivc_configs[CONFIG_MAX_IVC_CONFIGS];

Expand Down
12 changes: 9 additions & 3 deletions tools/hvisor.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,16 @@ static int zone_start_from_json(const char *json_config_path,
mem_region->virtual_start, mem_region->size);
}

config->num_interrupts = num_interrupts;
// irq
memset(config->interrupts_bitmap, 0,
sizeof(BitmapWord) * (CONFIG_MAX_INTERRUPTS /
CONFIG_INTERRUPTS_BITMAP_BITS_PER_WORD));
for (int i = 0; i < num_interrupts; i++) {
config->interrupts[i] =
SAFE_CJSON_GET_ARRAY_ITEM(interrupts_json, i)->valueint;
__u32 irq = SAFE_CJSON_GET_ARRAY_ITEM(interrupts_json, i)->valueint;

size_t word_index = irq / CONFIG_INTERRUPTS_BITMAP_BITS_PER_WORD;
size_t bit_index = irq % CONFIG_INTERRUPTS_BITMAP_BITS_PER_WORD;
config->interrupts_bitmap[word_index] |= ((BitmapWord)1) << bit_index;
}

// ivc
Expand Down