1.1 --- a/pkg/landfall-examples/hw_info/hw_info.c Thu Feb 15 23:15:30 2024 +0100
1.2 +++ b/pkg/landfall-examples/hw_info/hw_info.c Thu Feb 15 23:18:09 2024 +0100
1.3 @@ -497,11 +497,37 @@
1.4 return init_irq(0, dma_irq, dma_irq_start, dma_irq_end);
1.5 }
1.6
1.7 +static void _show_dma_region(struct dma_region *region, uint32_t offset)
1.8 +{
1.9 + unsigned int i;
1.10 +
1.11 + printf("size = %d; align = %d; virtual = 0x%lx; physical = 0x%llx\ndata (offset 0x%x) =",
1.12 + region->size, region->align, region->vaddr, region->paddr, offset);
1.13 +
1.14 + for (i = 0; (i < region->size) && (i < 16); i++)
1.15 + printf(" %02x", *((uint8_t *) region->vaddr + offset + i));
1.16 +
1.17 + printf("\n");
1.18 +}
1.19 +
1.20 +static void show_dma_region(void)
1.21 +{
1.22 + struct dma_region *region = _get_dma_region();
1.23 + uint32_t offset;
1.24 +
1.25 + if (region == NULL)
1.26 + return;
1.27 +
1.28 + if (!read_number("Offset", &offset))
1.29 + return;
1.30 +
1.31 + _show_dma_region(region, offset);
1.32 +}
1.33 +
1.34 static void list_dma_regions(void)
1.35 {
1.36 unsigned int num;
1.37 struct dma_region *region;
1.38 - unsigned int i;
1.39
1.40 for (num = 0; num < num_dma_regions; num++)
1.41 {
1.42 @@ -512,15 +538,7 @@
1.43 if (l4_is_invalid_cap(region->mem))
1.44 printf("(inactive)\n");
1.45 else
1.46 - {
1.47 - printf("size = %d; align = %d; virtual = 0x%lx; physical = 0x%llx\ndata =",
1.48 - region->size, region->align, region->vaddr, region->paddr);
1.49 -
1.50 - for (i = 0; (i < region->size) && (i < 16); i++)
1.51 - printf(" %02x", *((uint8_t *) region->vaddr + i));
1.52 -
1.53 - printf("\n");
1.54 - }
1.55 + _show_dma_region(region, 0);
1.56 }
1.57 }
1.58
1.59 @@ -1172,11 +1190,11 @@
1.60 msc_enable(channel);
1.61 }
1.62
1.63 -static void read_block_from_msc(void)
1.64 +static void read_blocks_from_msc(void)
1.65 {
1.66 void *channel = get_channel(num_msc_channels, msc_channels, NULL);
1.67 struct dma_region *dma_region = NULL;
1.68 - uint32_t card, transferred;
1.69 + uint32_t card, transferred, block_address, block_count;
1.70
1.71 if (channel == NULL)
1.72 return;
1.73 @@ -1189,9 +1207,24 @@
1.74 if (!read_number("Card", &card))
1.75 return;
1.76
1.77 + if (!read_number("Block address", &block_address))
1.78 + return;
1.79 +
1.80 + if (!read_number("Block count", &block_count))
1.81 + return;
1.82 +
1.83 + /* NOTE: Assuming 512-byte blocks. */
1.84 +
1.85 + if (block_count * 512 > dma_region->size)
1.86 + {
1.87 + printf("Too many blocks for region.\n");
1.88 + return;
1.89 + }
1.90 +
1.91 l4_cache_inv_data(dma_region->vaddr, dma_region->vaddr + dma_region->size);
1.92
1.93 - transferred = msc_read_block(channel, (uint8_t) card, dma_region->paddr);
1.94 + transferred = msc_read_blocks(channel, (uint8_t) card, dma_region->paddr,
1.95 + block_address, block_count);
1.96
1.97 printf("Transferred: %d\n", transferred);
1.98 }
1.99 @@ -1642,6 +1675,8 @@
1.100 new_dma_channel(dma);
1.101 else if (!strcmp(token, "r") || !strcmp(token, "region"))
1.102 new_dma_region();
1.103 + else if (!strcmp(token, "R") || !strcmp(token, "show"))
1.104 + show_dma_region();
1.105 else if (!strcmp(token, "s") || !strcmp(token, "set"))
1.106 set_dma_region();
1.107 else if (!strcmp(token, "t") || !strcmp(token, "transfer"))
1.108 @@ -1725,7 +1760,7 @@
1.109 else if (!strcmp(token, "e") || !strcmp(token, "enable"))
1.110 enable_msc_channel();
1.111 else if (!strcmp(token, "r") || !strcmp(token, "read"))
1.112 - read_block_from_msc();
1.113 + read_blocks_from_msc();
1.114 else
1.115 printf("msc channel | enable | read\n");
1.116 }