Skip to content

Commit 9161f40

Browse files
committed
add PCIe support
1 parent 26bc7f2 commit 9161f40

43 files changed

Lines changed: 989 additions & 22 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ tenders/spt/solo5-spt
1919
elftool/solo5-elftool
2020
opam/release
2121
solo5-*.tar.gz
22+
.vscode

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Adrian-Ken Rueegsegger
1212
Adam Steen
1313
Dan Williams (IBM)
1414
Emery Hemingway (Genode Labs)
15+
Fabian Bonk
1516
Gabriel Jaldon
1617
Hannes Mehnert
1718
Ian Campbell (Docker, Inc.)

bindings/GNUmakefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@ common_hvt_SRCS := hvt/platform.c hvt/platform_intr.c hvt/time.c
3939
#
4040
hvt_SRCS := hvt/start.c $(common_SRCS) $(common_hvt_SRCS) \
4141
hvt/platform_lifecycle.c hvt/yield.c hvt/tscclock.c hvt/console.c \
42-
hvt/net.c hvt/block.c
42+
hvt/net.c hvt/block.c hvt/pci.c
4343

4444
spt_SRCS := spt/start.c \
4545
abort.c crt.c printf.c lib.c mem.c exit.c log.c cmdline.c tls.c mft.c \
46-
spt/bindings.c spt/block.c spt/net.c spt/platform.c \
46+
spt/bindings.c spt/block.c spt/net.c spt/pci.c spt/platform.c \
4747
spt/sys_linux_$(CONFIG_ARCH).c
4848

4949
virtio_SRCS := virtio/boot.S virtio/start.c $(common_SRCS) \
5050
virtio/platform.c virtio/platform_intr.c \
5151
virtio/pci.c virtio/serial.c virtio/time.c virtio/virtio_ring.c \
5252
virtio/virtio_net.c virtio/virtio_blk.c virtio/tscclock.c \
53-
virtio/clock_subr.c virtio/pvclock.c
53+
virtio/clock_subr.c virtio/pvclock.c virtio/pci-stubs.c
5454

5555
muen_SRCS := muen/start.c $(common_SRCS) $(common_hvt_SRCS) \
5656
muen/channel.c muen/reader.c muen/writer.c muen/muen-block.c \
57-
muen/muen-clock.c muen/muen-console.c muen/muen-net.c \
57+
muen/muen-clock.c muen/muen-console.c muen/muen-net.c muen/muen-pci.c \
5858
muen/muen-platform_lifecycle.c muen/muen-yield.c muen/muen-sinfo.c
5959

6060
genode_SRCS := genode/stubs.c
@@ -108,6 +108,8 @@ endif
108108
ifdef CONFIG_SPT
109109
spt_OBJS := $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(spt_SRCS)))
110110

111+
spt/pci.o: CFLAGS += -Wno-unused-parameter
112+
111113
spt/solo5_spt.o: $(spt_OBJS)
112114
$(LINK.bindings)
113115

@@ -119,6 +121,8 @@ endif
119121
ifdef CONFIG_VIRTIO
120122
virtio_OBJS := $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(virtio_SRCS)))
121123

124+
virtio/pci-stubs.o: CFLAGS += -Wno-unused-parameter
125+
122126
virtio/solo5_virtio.o: $(virtio_OBJS)
123127
$(LINK.bindings)
124128

@@ -130,6 +134,8 @@ endif
130134
ifdef CONFIG_MUEN
131135
muen_OBJS := $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(muen_SRCS)))
132136

137+
muen/muen-pci.o: CFLAGS += -Wno-unused-parameter
138+
133139
muen/solo5_muen.o: $(muen_OBJS)
134140
$(LINK.bindings)
135141

bindings/genode/stubs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@ solo5_result_t solo5_block_read(solo5_handle_t handle, solo5_off_t offset, uint8
1919

2020
solo5_result_t solo5_set_tls_base(uintptr_t base) { return SOLO5_R_EUNSPEC; }
2121

22+
solo5_result_t solo5_pci_acquire(const char *name, struct solo5_pci_info *info) { return SOLO5_R_EUNSPEC; }
23+
solo5_result_t solo5_dma_acquire(uint8_t **buffer, size_t *size) { return SOLO5_R_EUNSPEC; }
24+
2225
uintptr_t SSP_GUARD;
2326
void SSP_FAIL (void) { }

bindings/hvt/bindings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ void time_init(const struct hvt_boot_info *bi);
3535
void console_init(void);
3636
void net_init(const struct hvt_boot_info *bi);
3737
void block_init(const struct hvt_boot_info *bi);
38+
void pci_init(const struct hvt_boot_info *bi);
3839

3940
/* tscclock.c: TSC-based clock */
4041
uint64_t tscclock_monotonic(void);

bindings/hvt/pci.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#include "bindings.h"
2+
3+
static const struct mft *mft;
4+
5+
#define setup_bar(index, n) \
6+
do { \
7+
if (e->u.pci_basic.map_bar ## n) { \
8+
info->bar ## n = (uint8_t *) HVT_REGION(index, n); \
9+
info->bar ## n ## _size = e->u.pci_basic.bar ## n ## _size; \
10+
} else { \
11+
info->bar ## n = NULL; \
12+
info->bar ## n ## _size = 0; \
13+
} \
14+
} while (0)
15+
16+
solo5_result_t solo5_pci_acquire(const char *name, struct solo5_pci_info *info)
17+
{
18+
unsigned mft_index;
19+
const struct mft_entry *e =
20+
mft_get_by_name(mft, name, MFT_DEV_PCI_BASIC, &mft_index);
21+
if (e == NULL)
22+
return SOLO5_R_EINVAL;
23+
assert(e->attached);
24+
25+
info->bus_master_enable = e->u.pci_basic.bus_master_enable;
26+
info->class_code = e->u.pci_basic.class_code;
27+
info->subclass_code = e->u.pci_basic.subclass_code;
28+
info->progif = e->u.pci_basic.progif;
29+
info->vendor_id = e->u.pci_basic.vendor;
30+
info->device_id = e->u.pci_basic.device_id;
31+
32+
uint8_t index = e->u.pci_basic.device_index;
33+
setup_bar(index, 0);
34+
setup_bar(index, 1);
35+
setup_bar(index, 2);
36+
setup_bar(index, 3);
37+
setup_bar(index, 4);
38+
setup_bar(index, 5);
39+
40+
assert(info->bar0_size != 0);
41+
42+
return SOLO5_R_OK;
43+
}
44+
45+
solo5_result_t solo5_dma_acquire(uint8_t **buffer, size_t *size)
46+
{
47+
if (mft->dma_size > 0) {
48+
*buffer = (uint8_t *) HVT_DMA_BASE;
49+
*size = mft->dma_size;
50+
return SOLO5_R_OK;
51+
} else {
52+
*buffer = NULL;
53+
*size = 0;
54+
return SOLO5_R_EINVAL;
55+
}
56+
}
57+
58+
void pci_init(const struct hvt_boot_info *bi)
59+
{
60+
mft = bi->mft;
61+
}

bindings/hvt/start.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ void _start(const void *arg)
4444
time_init(arg);
4545
block_init(arg);
4646
net_init(arg);
47+
pci_init(arg);
4748

4849
mem_lock_heap(&si.heap_start, &si.heap_size);
4950
solo5_exit(solo5_app_main(&si));

bindings/muen/muen-pci.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "bindings.h"
2+
3+
solo5_result_t solo5_pci_acquire(const char *name, struct solo5_pci_info *info)
4+
{
5+
return SOLO5_R_EUNSPEC;
6+
}
7+
8+
solo5_result_t solo5_dma_acquire(uint8_t **buffer, size_t *size)
9+
{
10+
return SOLO5_R_EUNSPEC;
11+
}

bindings/spt/pci.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "bindings.h"
2+
3+
solo5_result_t solo5_pci_acquire(const char *name, struct solo5_pci_info *info)
4+
{
5+
return SOLO5_R_EUNSPEC;
6+
}
7+
8+
solo5_result_t solo5_dma_acquire(uint8_t **buffer, size_t *size)
9+
{
10+
return SOLO5_R_EUNSPEC;
11+
}

bindings/virtio/pci-stubs.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "bindings.h"
2+
3+
solo5_result_t solo5_pci_acquire(const char *name, struct solo5_pci_info *info)
4+
{
5+
return SOLO5_R_EUNSPEC;
6+
}
7+
8+
solo5_result_t solo5_dma_acquire(uint8_t **buffer, size_t *size)
9+
{
10+
return SOLO5_R_EUNSPEC;
11+
}

0 commit comments

Comments
 (0)