Index: sys/arch/arm/broadcom/bcm2835_dmac.h =================================================================== RCS file: /home/netbsd/src/sys/arch/arm/broadcom/bcm2835_dmac.h,v retrieving revision 1.4 diff -p -u -r1.4 bcm2835_dmac.h --- sys/arch/arm/broadcom/bcm2835_dmac.h 9 Aug 2015 13:06:44 -0000 1.4 +++ sys/arch/arm/broadcom/bcm2835_dmac.h 6 Nov 2020 00:54:15 -0000 @@ -29,6 +29,8 @@ #ifndef BCM2835_DMAC_H #define BCM2835_DMAC_H +#include + #define DMAC_CS(n) (0x00 + (0x100 * (n))) #define DMAC_CS_RESET __BIT(31) #define DMAC_CS_ABORT __BIT(30) @@ -62,6 +64,9 @@ #define DMAC_DEBUG_FIFO_ERROR __BIT(1) #define DMAC_DEBUG_READ_LAST_NOT_SET_ERROR __BIT(0) +/* + * Byte-order is little endain. + */ struct bcm_dmac_conblk { uint32_t cb_ti; #define DMAC_TI_NO_WIDE_BURSTS __BIT(26) @@ -108,5 +113,16 @@ void bcm_dmac_set_conblk_addr(struct bcm int bcm_dmac_transfer(struct bcm_dmac_channel *); void bcm_dmac_halt(struct bcm_dmac_channel *); +static inline void +bcm_dmac_swap_conblk(struct bcm_dmac_conblk *conblk) +{ + + HTOLE32(conblk->cb_ti); + HTOLE32(conblk->cb_source_ad); + HTOLE32(conblk->cb_dest_ad); + HTOLE32(conblk->cb_txfr_len); + HTOLE32(conblk->cb_stride); + HTOLE32(conblk->cb_nextconbk); +} #endif /* !BCM2835_DMAC_H */ Index: sys/arch/arm/broadcom/bcm2835_emmc.c =================================================================== RCS file: /home/netbsd/src/sys/arch/arm/broadcom/bcm2835_emmc.c,v retrieving revision 1.38 diff -p -u -r1.38 bcm2835_emmc.c --- sys/arch/arm/broadcom/bcm2835_emmc.c 28 Aug 2020 13:13:55 -0000 1.38 +++ sys/arch/arm/broadcom/bcm2835_emmc.c 27 Oct 2020 22:15:23 -0000 @@ -327,6 +327,7 @@ bcmemmc_xfer_data_dma(struct sdhc_softc sc->sc_dmamap->dm_segs[0].ds_addr + sizeof(struct bcm_dmac_conblk) * (seg+1); } + bcm_dmac_swap_conblk(&sc->sc_cblk[seg]); sc->sc_cblk[seg].cb_padding[0] = 0; sc->sc_cblk[seg].cb_padding[1] = 0; } Index: sys/arch/arm/broadcom/bcm2835_genfb.c =================================================================== RCS file: /home/netbsd/src/sys/arch/arm/broadcom/bcm2835_genfb.c,v retrieving revision 1.9 diff -p -u -r1.9 bcm2835_genfb.c --- sys/arch/arm/broadcom/bcm2835_genfb.c 1 Apr 2018 04:35:03 -0000 1.9 +++ sys/arch/arm/broadcom/bcm2835_genfb.c 5 Nov 2020 06:25:28 -0000 @@ -96,6 +96,9 @@ bcmgenfb_attach(device_t parent, device_ sc->sc_wstype = WSDISPLAY_TYPE_VC4; prop_dictionary_get_uint32(dict, "wsdisplay_type", &sc->sc_wstype); prop_dictionary_get_bool(dict, "is_console", &is_console); +#if BYTE_ORDER == BIG_ENDIAN + prop_dictionary_set_bool(dict, "is_swapped", true); +#endif genfb_init(&sc->sc_gen); Index: sys/arch/arm/broadcom/bcm2835_sdhost.c =================================================================== RCS file: /home/netbsd/src/sys/arch/arm/broadcom/bcm2835_sdhost.c,v retrieving revision 1.5 diff -p -u -r1.5 bcm2835_sdhost.c --- sys/arch/arm/broadcom/bcm2835_sdhost.c 31 May 2020 23:52:19 -0000 1.5 +++ sys/arch/arm/broadcom/bcm2835_sdhost.c 27 Oct 2020 22:14:19 -0000 @@ -397,6 +397,7 @@ sdhost_dma_transfer(struct sdhost_softc sc->sc_dmamap->dm_segs[0].ds_addr + sizeof(struct bcm_dmac_conblk) * (seg+1); } + bcm_dmac_swap_conblk(&sc->sc_cblk[seg]); sc->sc_cblk[seg].cb_padding[0] = 0; sc->sc_cblk[seg].cb_padding[1] = 0; } Index: sys/arch/arm/broadcom/bcm283x_platform.c =================================================================== RCS file: /home/netbsd/src/sys/arch/arm/broadcom/bcm283x_platform.c,v retrieving revision 1.41 diff -p -u -r1.41 bcm283x_platform.c --- sys/arch/arm/broadcom/bcm283x_platform.c 28 Sep 2020 11:54:23 -0000 1.41 +++ sys/arch/arm/broadcom/bcm283x_platform.c 4 Nov 2020 12:44:22 -0000 @@ -53,6 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: bcm283x_plat #include #include #include +#include #include #include @@ -112,6 +113,7 @@ __KERNEL_RCSID(0, "$NetBSD: bcm283x_plat #define RPI_CPU_MAX 4 void bcm2835_platform_early_putchar(char c); +void bcm2835_aux_platform_early_putchar(char c); void bcm2836_platform_early_putchar(char c); void bcm2837_platform_early_putchar(char c); void bcm2711_platform_early_putchar(char c); @@ -348,27 +350,28 @@ static struct { struct vcprop_tag end; } vb_uart __cacheline_aligned = { .vb_hdr = { - .vpb_len = sizeof(vb_uart), - .vpb_rcode = VCPROP_PROCESS_REQUEST, + .vpb_len = htole32(sizeof(vb_uart)), + .vpb_rcode = htole32(VCPROP_PROCESS_REQUEST), }, .vbt_uartclockrate = { .tag = { - .vpt_tag = VCPROPTAG_GET_CLOCKRATE, - .vpt_len = VCPROPTAG_LEN(vb_uart.vbt_uartclockrate), - .vpt_rcode = VCPROPTAG_REQUEST + .vpt_tag = htole32(VCPROPTAG_GET_CLOCKRATE), + .vpt_len = + htole32(VCPROPTAG_LEN(vb_uart.vbt_uartclockrate)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST) }, - .id = VCPROP_CLK_UART + .id = htole32(VCPROP_CLK_UART) }, .vbt_vpuclockrate = { .tag = { - .vpt_tag = VCPROPTAG_GET_CLOCKRATE, - .vpt_len = VCPROPTAG_LEN(vb_uart.vbt_vpuclockrate), - .vpt_rcode = VCPROPTAG_REQUEST + .vpt_tag = htole32(VCPROPTAG_GET_CLOCKRATE), + .vpt_len = htole32(VCPROPTAG_LEN(vb_uart.vbt_vpuclockrate)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST) }, - .id = VCPROP_CLK_CORE + .id = htole32(VCPROP_CLK_CORE) }, .end = { - .vpt_tag = VCPROPTAG_NULL + .vpt_tag = htole32(VCPROPTAG_NULL) } }; @@ -389,99 +392,100 @@ static struct { struct vcprop_tag end; } vb __cacheline_aligned = { .vb_hdr = { - .vpb_len = sizeof(vb), - .vpb_rcode = VCPROP_PROCESS_REQUEST, + .vpb_len = htole32(sizeof(vb)), + .vpb_rcode = htole32(VCPROP_PROCESS_REQUEST), }, .vbt_fwrev = { .tag = { - .vpt_tag = VCPROPTAG_GET_FIRMWAREREV, - .vpt_len = VCPROPTAG_LEN(vb.vbt_fwrev), - .vpt_rcode = VCPROPTAG_REQUEST + .vpt_tag = htole32(VCPROPTAG_GET_FIRMWAREREV), + .vpt_len = htole32(VCPROPTAG_LEN(vb.vbt_fwrev)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST) }, }, .vbt_boardmodel = { .tag = { - .vpt_tag = VCPROPTAG_GET_BOARDMODEL, - .vpt_len = VCPROPTAG_LEN(vb.vbt_boardmodel), - .vpt_rcode = VCPROPTAG_REQUEST + .vpt_tag = htole32(VCPROPTAG_GET_BOARDMODEL), + .vpt_len = htole32(VCPROPTAG_LEN(vb.vbt_boardmodel)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST) }, }, .vbt_boardrev = { .tag = { - .vpt_tag = VCPROPTAG_GET_BOARDREVISION, - .vpt_len = VCPROPTAG_LEN(vb.vbt_boardrev), - .vpt_rcode = VCPROPTAG_REQUEST + .vpt_tag = htole32(VCPROPTAG_GET_BOARDREVISION), + .vpt_len = htole32(VCPROPTAG_LEN(vb.vbt_boardrev)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST) }, }, .vbt_macaddr = { .tag = { - .vpt_tag = VCPROPTAG_GET_MACADDRESS, - .vpt_len = VCPROPTAG_LEN(vb.vbt_macaddr), - .vpt_rcode = VCPROPTAG_REQUEST + .vpt_tag = htole32(VCPROPTAG_GET_MACADDRESS), + .vpt_len = htole32(VCPROPTAG_LEN(vb.vbt_macaddr)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST) }, }, .vbt_memory = { .tag = { - .vpt_tag = VCPROPTAG_GET_ARMMEMORY, - .vpt_len = VCPROPTAG_LEN(vb.vbt_memory), - .vpt_rcode = VCPROPTAG_REQUEST + .vpt_tag = htole32(VCPROPTAG_GET_ARMMEMORY), + .vpt_len = htole32(VCPROPTAG_LEN(vb.vbt_memory)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST) }, }, .vbt_serial = { .tag = { - .vpt_tag = VCPROPTAG_GET_BOARDSERIAL, - .vpt_len = VCPROPTAG_LEN(vb.vbt_serial), - .vpt_rcode = VCPROPTAG_REQUEST + .vpt_tag = htole32(VCPROPTAG_GET_BOARDSERIAL), + .vpt_len = htole32(VCPROPTAG_LEN(vb.vbt_serial)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST) }, }, .vbt_dmachan = { .tag = { - .vpt_tag = VCPROPTAG_GET_DMACHAN, - .vpt_len = VCPROPTAG_LEN(vb.vbt_dmachan), - .vpt_rcode = VCPROPTAG_REQUEST + .vpt_tag = htole32(VCPROPTAG_GET_DMACHAN), + .vpt_len = htole32(VCPROPTAG_LEN(vb.vbt_dmachan)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST) }, }, .vbt_cmdline = { .tag = { - .vpt_tag = VCPROPTAG_GET_CMDLINE, - .vpt_len = VCPROPTAG_LEN(vb.vbt_cmdline), - .vpt_rcode = VCPROPTAG_REQUEST + .vpt_tag = htole32(VCPROPTAG_GET_CMDLINE), + .vpt_len = htole32(VCPROPTAG_LEN(vb.vbt_cmdline)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST) }, }, .vbt_emmcclockrate = { .tag = { - .vpt_tag = VCPROPTAG_GET_CLOCKRATE, - .vpt_len = VCPROPTAG_LEN(vb.vbt_emmcclockrate), - .vpt_rcode = VCPROPTAG_REQUEST + .vpt_tag = htole32(VCPROPTAG_GET_CLOCKRATE), + .vpt_len = htole32(VCPROPTAG_LEN(vb.vbt_emmcclockrate)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST) }, - .id = VCPROP_CLK_EMMC + .id = htole32(VCPROP_CLK_EMMC) }, .vbt_armclockrate = { .tag = { - .vpt_tag = VCPROPTAG_GET_CLOCKRATE, - .vpt_len = VCPROPTAG_LEN(vb.vbt_armclockrate), - .vpt_rcode = VCPROPTAG_REQUEST + .vpt_tag = htole32(VCPROPTAG_GET_CLOCKRATE), + .vpt_len = htole32(VCPROPTAG_LEN(vb.vbt_armclockrate)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST) }, - .id = VCPROP_CLK_ARM + .id = htole32(VCPROP_CLK_ARM) }, .vbt_vpuclockrate = { .tag = { - .vpt_tag = VCPROPTAG_GET_CLOCKRATE, - .vpt_len = VCPROPTAG_LEN(vb.vbt_vpuclockrate), - .vpt_rcode = VCPROPTAG_REQUEST + .vpt_tag = htole32(VCPROPTAG_GET_CLOCKRATE), + .vpt_len = htole32(VCPROPTAG_LEN(vb.vbt_vpuclockrate)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST) }, - .id = VCPROP_CLK_CORE + .id = htole32(VCPROP_CLK_CORE) }, .vbt_emmc2clockrate = { .tag = { - .vpt_tag = VCPROPTAG_GET_CLOCKRATE, - .vpt_len = VCPROPTAG_LEN(vb.vbt_emmc2clockrate), - .vpt_rcode = VCPROPTAG_REQUEST + .vpt_tag = htole32(VCPROPTAG_GET_CLOCKRATE), + .vpt_len = + htole32(VCPROPTAG_LEN(vb.vbt_emmc2clockrate)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST) }, - .id = VCPROP_CLK_EMMC2 + .id = htole32(VCPROP_CLK_EMMC2) }, .end = { - .vpt_tag = VCPROPTAG_NULL + .vpt_tag = htole32(VCPROPTAG_NULL) } }; @@ -492,19 +496,19 @@ static struct { struct vcprop_tag end; } vb_edid __cacheline_aligned = { .vb_hdr = { - .vpb_len = sizeof(vb_edid), - .vpb_rcode = VCPROP_PROCESS_REQUEST, + .vpb_len = htole32(sizeof(vb_edid)), + .vpb_rcode = htole32(VCPROP_PROCESS_REQUEST), }, .vbt_edid = { .tag = { - .vpt_tag = VCPROPTAG_GET_EDID_BLOCK, - .vpt_len = VCPROPTAG_LEN(vb_edid.vbt_edid), - .vpt_rcode = VCPROPTAG_REQUEST, + .vpt_tag = htole32(VCPROPTAG_GET_EDID_BLOCK), + .vpt_len = htole32(VCPROPTAG_LEN(vb_edid.vbt_edid)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST), }, - .blockno = 0, + .blockno = htole32(0), }, .end = { - .vpt_tag = VCPROPTAG_NULL + .vpt_tag = htole32(VCPROPTAG_NULL) } }; @@ -520,68 +524,69 @@ static struct { struct vcprop_tag end; } vb_setfb __cacheline_aligned = { .vb_hdr = { - .vpb_len = sizeof(vb_setfb), - .vpb_rcode = VCPROP_PROCESS_REQUEST, + .vpb_len = htole32(sizeof(vb_setfb)), + .vpb_rcode = htole32(VCPROP_PROCESS_REQUEST), }, .vbt_res = { .tag = { - .vpt_tag = VCPROPTAG_SET_FB_RES, - .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_res), - .vpt_rcode = VCPROPTAG_REQUEST, + .vpt_tag = htole32(VCPROPTAG_SET_FB_RES), + .vpt_len = htole32(VCPROPTAG_LEN(vb_setfb.vbt_res)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST), }, - .width = 0, - .height = 0, + .width = htole32(0), + .height = htole32(0), }, .vbt_vres = { .tag = { - .vpt_tag = VCPROPTAG_SET_FB_VRES, - .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_vres), - .vpt_rcode = VCPROPTAG_REQUEST, + .vpt_tag = htole32(VCPROPTAG_SET_FB_VRES), + .vpt_len = htole32(VCPROPTAG_LEN(vb_setfb.vbt_vres)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST), }, - .width = 0, - .height = 0, + .width = htole32(0), + .height = htole32(0), }, .vbt_depth = { .tag = { - .vpt_tag = VCPROPTAG_SET_FB_DEPTH, - .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_depth), - .vpt_rcode = VCPROPTAG_REQUEST, + .vpt_tag = htole32(VCPROPTAG_SET_FB_DEPTH), + .vpt_len = htole32(VCPROPTAG_LEN(vb_setfb.vbt_depth)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST), }, - .bpp = 32, + .bpp = htole32(32), }, .vbt_alpha = { .tag = { - .vpt_tag = VCPROPTAG_SET_FB_ALPHA_MODE, - .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_alpha), - .vpt_rcode = VCPROPTAG_REQUEST, + .vpt_tag = htole32(VCPROPTAG_SET_FB_ALPHA_MODE), + .vpt_len = htole32(VCPROPTAG_LEN(vb_setfb.vbt_alpha)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST), }, - .state = VCPROP_ALPHA_IGNORED, + .state = htole32(VCPROP_ALPHA_IGNORED), }, .vbt_allocbuf = { .tag = { - .vpt_tag = VCPROPTAG_ALLOCATE_BUFFER, - .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_allocbuf), - .vpt_rcode = VCPROPTAG_REQUEST, + .vpt_tag = htole32(VCPROPTAG_ALLOCATE_BUFFER), + .vpt_len = + htole32(VCPROPTAG_LEN(vb_setfb.vbt_allocbuf)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST), }, - .address = PAGE_SIZE, /* alignment */ + .address = htole32(PAGE_SIZE), /* alignment */ }, .vbt_blank = { .tag = { - .vpt_tag = VCPROPTAG_BLANK_SCREEN, - .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_blank), - .vpt_rcode = VCPROPTAG_REQUEST, + .vpt_tag = htole32(VCPROPTAG_BLANK_SCREEN), + .vpt_len = htole32(VCPROPTAG_LEN(vb_setfb.vbt_blank)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST), }, - .state = VCPROP_BLANK_OFF, + .state = htole32(VCPROP_BLANK_OFF), }, .vbt_pitch = { .tag = { - .vpt_tag = VCPROPTAG_GET_FB_PITCH, - .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_pitch), - .vpt_rcode = VCPROPTAG_REQUEST, + .vpt_tag = htole32(VCPROPTAG_GET_FB_PITCH), + .vpt_len = htole32(VCPROPTAG_LEN(vb_setfb.vbt_pitch)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST), }, }, .end = { - .vpt_tag = VCPROPTAG_NULL, + .vpt_tag = htole32(VCPROPTAG_NULL), }, }; @@ -605,7 +610,7 @@ bcm283x_clk_get_rate_uart(void) { if (vcprop_tag_success_p(&vb_uart.vbt_uartclockrate.tag)) - return vb_uart.vbt_uartclockrate.rate; + return le32toh(vb_uart.vbt_uartclockrate.rate); return 0; } @@ -614,8 +619,8 @@ bcm283x_clk_get_rate_vpu(void) { if (vcprop_tag_success_p(&vb.vbt_vpuclockrate.tag) && - vb.vbt_vpuclockrate.rate > 0) { - return vb.vbt_vpuclockrate.rate; + vb.vbt_vpuclockrate.rate != 0) { + return le32toh(vb.vbt_vpuclockrate.rate); } return 0; } @@ -625,8 +630,8 @@ bcm283x_clk_get_rate_emmc(void) { if (vcprop_tag_success_p(&vb.vbt_emmcclockrate.tag) && - vb.vbt_emmcclockrate.rate > 0) { - return vb.vbt_emmcclockrate.rate; + vb.vbt_emmcclockrate.rate != 0) { + return le32toh(vb.vbt_emmcclockrate.rate); } return 0; } @@ -636,8 +641,8 @@ bcm283x_clk_get_rate_emmc2(void) { if (vcprop_tag_success_p(&vb.vbt_emmc2clockrate.tag) && - vb.vbt_emmc2clockrate.rate > 0) { - return vb.vbt_emmc2clockrate.rate; + vb.vbt_emmc2clockrate.rate != 0) { + return le32toh(vb.vbt_emmc2clockrate.rate); } return 0; } @@ -662,9 +667,9 @@ bcm283x_uartinit(bus_space_tag_t iot, bu cpu_dcache_inv_range((vaddr_t)&vb_uart, sizeof(vb_uart)); if (vcprop_tag_success_p(&vb_uart.vbt_uartclockrate.tag)) - uart_clk = vb_uart.vbt_uartclockrate.rate; + uart_clk = le32toh(vb_uart.vbt_uartclockrate.rate); if (vcprop_tag_success_p(&vb_uart.vbt_vpuclockrate.tag)) - core_clk = vb_uart.vbt_vpuclockrate.rate; + core_clk = le32toh(vb_uart.vbt_vpuclockrate.rate); } #if defined(SOC_BCM2835) @@ -757,16 +762,19 @@ bcm283x_bootparams(bus_space_tag_t iot, bootconfig.dramblocks = 0; for (int i = 0; i < n && i < DRAM_BLOCKS; i++) { - bootconfig.dram[i].address = vptp_mem->mem[i].base; - bootconfig.dram[i].pages = atop(vptp_mem->mem[i].size); + bootconfig.dram[i].address = + le32toh(vptp_mem->mem[i].base); + bootconfig.dram[i].pages = + atop(le32toh(vptp_mem->mem[i].size)); bootconfig.dramblocks++; - bcm283x_memorysize += vptp_mem->mem[i].size; + bcm283x_memorysize += le32toh(vptp_mem->mem[i].size); } } if (vcprop_tag_success_p(&vb.vbt_armclockrate.tag)) - curcpu()->ci_data.cpu_cc_freq = vb.vbt_armclockrate.rate; + curcpu()->ci_data.cpu_cc_freq = + le32toh(vb.vbt_armclockrate.rate); #ifdef VERBOSE_INIT_ARM if (vcprop_tag_success_p(&vb.vbt_memory.tag)) @@ -774,34 +782,34 @@ bcm283x_bootparams(bus_space_tag_t iot, bcm283x_memorysize); if (vcprop_tag_success_p(&vb.vbt_armclockrate.tag)) printf("%s: arm clock %d\n", __func__, - vb.vbt_armclockrate.rate); + le32toh(vb.vbt_armclockrate.rate)); if (vcprop_tag_success_p(&vb.vbt_vpuclockrate.tag)) printf("%s: vpu clock %d\n", __func__, - vb.vbt_vpuclockrate.rate); + le32toh(vb.vbt_vpuclockrate.rate)); if (vcprop_tag_success_p(&vb.vbt_emmcclockrate.tag)) printf("%s: emmc clock %d\n", __func__, - vb.vbt_emmcclockrate.rate); + le32toh(vb.vbt_emmcclockrate.rate)); if (vcprop_tag_success_p(&vb.vbt_emmc2clockrate.tag)) printf("%s: emmc2 clock %d\n", __func__, - vb.vbt_emmcclockrate.rate); + le32toh(vb.vbt_emmcclockrate.rate)); if (vcprop_tag_success_p(&vb.vbt_fwrev.tag)) printf("%s: firmware rev %x\n", __func__, - vb.vbt_fwrev.rev); + le32toh(vb.vbt_fwrev.rev)); if (vcprop_tag_success_p(&vb.vbt_boardmodel.tag)) printf("%s: board model %x\n", __func__, - vb.vbt_boardmodel.model); + le32toh(vb.vbt_boardmodel.model)); if (vcprop_tag_success_p(&vb.vbt_macaddr.tag)) printf("%s: mac-address %" PRIx64 "\n", __func__, - vb.vbt_macaddr.addr); + le64toh(vb.vbt_macaddr.addr)); if (vcprop_tag_success_p(&vb.vbt_boardrev.tag)) printf("%s: board rev %x\n", __func__, - vb.vbt_boardrev.rev); + le32toh(vb.vbt_boardrev.rev)); if (vcprop_tag_success_p(&vb.vbt_serial.tag)) printf("%s: board serial %" PRIx64 "\n", __func__, - vb.vbt_serial.sn); + le64toh(vb.vbt_serial.sn)); if (vcprop_tag_success_p(&vb.vbt_dmachan.tag)) printf("%s: DMA channel mask 0x%08x\n", __func__, - vb.vbt_dmachan.mask); + le32toh(vb.vbt_dmachan.mask)); if (vcprop_tag_success_p(&vb.vbt_cmdline.tag)) printf("%s: cmdline %s\n", __func__, @@ -954,10 +962,10 @@ rpi_fb_init(prop_dictionary_t dict, void height = RPI_FB_HEIGHT; } - vb_setfb.vbt_res.width = width; - vb_setfb.vbt_res.height = height; - vb_setfb.vbt_vres.width = width; - vb_setfb.vbt_vres.height = height; + vb_setfb.vbt_res.width = htole32(width); + vb_setfb.vbt_res.height = htole32(height); + vb_setfb.vbt_vres.width = htole32(width); + vb_setfb.vbt_vres.height = htole32(height); error = bcmmbox_request(BCMMBOX_CHANARM2VC, &vb_setfb, sizeof(vb_setfb), &res); if (error) { @@ -978,15 +986,16 @@ rpi_fb_init(prop_dictionary_t dict, void #ifdef VERBOSE_INIT_ARM printf("%s: addr = 0x%x size = %d\n", __func__, - vb_setfb.vbt_allocbuf.address, - vb_setfb.vbt_allocbuf.size); - printf("%s: depth = %d\n", __func__, vb_setfb.vbt_depth.bpp); + le32toh(vb_setfb.vbt_allocbuf.address), + le32toh(vb_setfb.vbt_allocbuf.size)); + printf("%s: depth = %d\n", __func__, le32toh(vb_setfb.vbt_depth.bpp)); printf("%s: pitch = %d\n", __func__, - vb_setfb.vbt_pitch.linebytes); + le32toh(vb_setfb.vbt_pitch.linebytes)); printf("%s: width = %d height = %d\n", __func__, - vb_setfb.vbt_res.width, vb_setfb.vbt_res.height); + le32toh(vb_setfb.vbt_res.width), le32toh(vb_setfb.vbt_res.height)); printf("%s: vwidth = %d vheight = %d\n", __func__, - vb_setfb.vbt_vres.width, vb_setfb.vbt_vres.height); + le32toh(vb_setfb.vbt_vres.width), + le32toh(vb_setfb.vbt_vres.height)); #endif if (vb_setfb.vbt_allocbuf.address == 0 || @@ -1001,13 +1010,16 @@ rpi_fb_init(prop_dictionary_t dict, void return false; } - prop_dictionary_set_uint32(dict, "width", vb_setfb.vbt_res.width); - prop_dictionary_set_uint32(dict, "height", vb_setfb.vbt_res.height); - prop_dictionary_set_uint8(dict, "depth", vb_setfb.vbt_depth.bpp); + prop_dictionary_set_uint32(dict, "width", + le32toh(vb_setfb.vbt_res.width)); + prop_dictionary_set_uint32(dict, "height", + le32toh(vb_setfb.vbt_res.height)); + prop_dictionary_set_uint8(dict, "depth", + le32toh(vb_setfb.vbt_depth.bpp)); prop_dictionary_set_uint16(dict, "linebytes", - vb_setfb.vbt_pitch.linebytes); + le32toh(vb_setfb.vbt_pitch.linebytes)); prop_dictionary_set_uint32(dict, "address", - vb_setfb.vbt_allocbuf.address); + le32toh(vb_setfb.vbt_allocbuf.address)); /* * Old firmware uses BGR. New firmware uses RGB. The get and set @@ -1335,15 +1347,29 @@ bcm283x_platform_early_putchar(vaddr_t v (volatile uint32_t *)va : (volatile uint32_t *)pa; - while ((uartaddr[PL01XCOM_FR / 4] & PL01X_FR_TXFF) != 0) + while ((le32toh(uartaddr[PL01XCOM_FR / 4]) & PL01X_FR_TXFF) != 0) continue; - uartaddr[PL01XCOM_DR / 4] = c; + uartaddr[PL01XCOM_DR / 4] = htole32(c); - while ((uartaddr[PL01XCOM_FR / 4] & PL01X_FR_TXFE) == 0) + while ((le32toh(uartaddr[PL01XCOM_FR / 4]) & PL01X_FR_TXFE) == 0) continue; } +static void __noasan +bcm283x_aux_platform_early_putchar(vaddr_t va, paddr_t pa, char c) +{ + volatile uint32_t *uartaddr = + cpu_earlydevice_va_p() ? + (volatile uint32_t *)va : + (volatile uint32_t *)pa; + + while ((le32toh(uartaddr[com_lsr]) & LSR_TXRDY) == 0) + continue; + + uartaddr[com_data] = htole32(c); +} + void __noasan bcm2835_platform_early_putchar(char c) { @@ -1354,6 +1380,15 @@ bcm2835_platform_early_putchar(char c) } void __noasan +bcm2835_aux_platform_early_putchar(char c) +{ + paddr_t pa = BCM2835_PERIPHERALS_BUS_TO_PHYS(BCM2835_AUX_UART_BASE); + vaddr_t va = BCM2835_IOPHYSTOVIRT(pa); + + bcm283x_aux_platform_early_putchar(va, pa, c); +} + +void __noasan bcm2836_platform_early_putchar(char c) { paddr_t pa = BCM2836_PERIPHERALS_BUS_TO_PHYS(BCM2835_UART0_BASE); @@ -1365,37 +1400,19 @@ bcm2836_platform_early_putchar(char c) void __noasan bcm2837_platform_early_putchar(char c) { -#define AUCONSADDR_PA BCM2836_PERIPHERALS_BUS_TO_PHYS(BCM2835_AUX_UART_BASE) -#define AUCONSADDR_VA BCM2835_IOPHYSTOVIRT(AUCONSADDR_PA) - volatile uint32_t *uartaddr = - cpu_earlydevice_va_p() ? - (volatile uint32_t *)AUCONSADDR_VA : - (volatile uint32_t *)AUCONSADDR_PA; - - while ((uartaddr[com_lsr] & LSR_TXRDY) == 0) - ; + paddr_t pa = BCM2836_PERIPHERALS_BUS_TO_PHYS(BCM2835_AUX_UART_BASE); + vaddr_t va = BCM2835_IOPHYSTOVIRT(pa); - uartaddr[com_data] = c; -#undef AUCONSADDR_VA -#undef AUCONSADDR_PA + bcm283x_aux_platform_early_putchar(va, pa, c); } void __noasan bcm2711_platform_early_putchar(char c) { -#define AUCONSADDR_PA BCM2711_PERIPHERALS_BUS_TO_PHYS(BCM2835_AUX_UART_BASE) -#define AUCONSADDR_VA BCM2711_IOPHYSTOVIRT(AUCONSADDR_PA) - volatile uint32_t *uartaddr = - cpu_earlydevice_va_p() ? - (volatile uint32_t *)AUCONSADDR_VA : - (volatile uint32_t *)AUCONSADDR_PA; - - while ((uartaddr[com_lsr] & LSR_TXRDY) == 0) - ; + paddr_t pa = BCM2711_PERIPHERALS_BUS_TO_PHYS(BCM2835_AUX_UART_BASE); + vaddr_t va = BCM2711_IOPHYSTOVIRT(pa); - uartaddr[com_data] = c; -#undef AUCONSADDR_VA -#undef AUCONSADDR_PA + bcm283x_aux_platform_early_putchar(va, pa, c); } #define BCM283x_REF_FREQ 19200000 @@ -1408,7 +1425,7 @@ bcm283x_platform_device_register(device_ if (device_is_a(dev, "bcmdmac") && vcprop_tag_success_p(&vb.vbt_dmachan.tag)) { prop_dictionary_set_uint32(dict, - "chanmask", vb.vbt_dmachan.mask); + "chanmask", le32toh(vb.vbt_dmachan.mask)); } #if NSDHC > 0 if (booted_device == NULL && @@ -1422,13 +1439,11 @@ bcm283x_platform_device_register(device_ device_is_a(dev, "mue") || device_is_a(dev, "genet")) && vcprop_tag_success_p(&vb.vbt_macaddr.tag)) { + const uint64_t addr = le64toh(vb.vbt_macaddr.addr); const uint8_t enaddr[ETHER_ADDR_LEN] = { - (vb.vbt_macaddr.addr >> 0) & 0xff, - (vb.vbt_macaddr.addr >> 8) & 0xff, - (vb.vbt_macaddr.addr >> 16) & 0xff, - (vb.vbt_macaddr.addr >> 24) & 0xff, - (vb.vbt_macaddr.addr >> 32) & 0xff, - (vb.vbt_macaddr.addr >> 40) & 0xff + (addr >> 0) & 0xff, (addr >> 8) & 0xff, + (addr >> 16) & 0xff, (addr >> 24) & 0xff, + (addr >> 32) & 0xff, (addr >> 40) & 0xff }; prop_dictionary_set_data(dict, "mac-address", enaddr, Index: sys/arch/evbarm/rpi/rpi_vcmbox.c =================================================================== RCS file: /home/netbsd/src/sys/arch/evbarm/rpi/rpi_vcmbox.c,v retrieving revision 1.5 diff -p -u -r1.5 rpi_vcmbox.c --- sys/arch/evbarm/rpi/rpi_vcmbox.c 8 Dec 2018 06:53:11 -0000 1.5 +++ sys/arch/evbarm/rpi/rpi_vcmbox.c 27 Oct 2020 20:36:28 -0000 @@ -35,11 +35,12 @@ __KERNEL_RCSID(0, "$NetBSD: rpi_vcmbox.c #include #include -#include -#include -#include #include +#include +#include +#include #include +#include #include #include @@ -67,15 +68,15 @@ struct vcmbox_clockrate_request { #define VCMBOX_INIT_REQUEST(req) \ do { \ memset(&(req), 0, sizeof((req))); \ - (req).vb_hdr.vpb_len = sizeof((req)); \ - (req).vb_hdr.vpb_rcode = VCPROP_PROCESS_REQUEST; \ - (req).end.vpt_tag = VCPROPTAG_NULL; \ + (req).vb_hdr.vpb_len = htole32(sizeof((req))); \ + (req).vb_hdr.vpb_rcode = htole32(VCPROP_PROCESS_REQUEST);\ + (req).end.vpt_tag = htole32(VCPROPTAG_NULL); \ } while (0) #define VCMBOX_INIT_TAG(s, t) \ do { \ - (s).tag.vpt_tag = (t); \ - (s).tag.vpt_rcode = VCPROPTAG_REQUEST; \ - (s).tag.vpt_len = VCPROPTAG_LEN(s); \ + (s).tag.vpt_tag = htole32(t); \ + (s).tag.vpt_rcode = htole32(VCPROPTAG_REQUEST); \ + (s).tag.vpt_len = htole32(VCPROPTAG_LEN(s)); \ } while (0) struct vcmbox_softc { @@ -168,7 +169,7 @@ vcmbox_read_temp(struct vcmbox_softc *sc VCMBOX_INIT_REQUEST(vb); VCMBOX_INIT_TAG(vb.vbt_temp, tag); - vb.vbt_temp.id = id; + vb.vbt_temp.id = htole32(id); error = bcmmbox_request(BCMMBOX_CHANARM2VC, &vb, sizeof(vb), &res); if (error) return error; @@ -176,7 +177,7 @@ vcmbox_read_temp(struct vcmbox_softc *sc !vcprop_tag_success_p(&vb.vbt_temp.tag)) { return EIO; } - *val = vb.vbt_temp.value; + *val = le32toh(vb.vbt_temp.value); return 0; } @@ -191,7 +192,7 @@ vcmbox_read_clockrate(struct vcmbox_soft VCMBOX_INIT_REQUEST(vb); VCMBOX_INIT_TAG(vb.vbt_clockrate, tag); - vb.vbt_clockrate.id = id; + vb.vbt_clockrate.id = htole32(id); error = bcmmbox_request(BCMMBOX_CHANARM2VC, &vb, sizeof(vb), &res); if (error) return error; @@ -199,7 +200,7 @@ vcmbox_read_clockrate(struct vcmbox_soft !vcprop_tag_success_p(&vb.vbt_clockrate.tag)) { return EIO; } - *val = vb.vbt_clockrate.rate; + *val = le32toh(vb.vbt_clockrate.rate); return 0; } @@ -214,8 +215,8 @@ vcmbox_write_clockrate(struct vcmbox_sof VCMBOX_INIT_REQUEST(vb); VCMBOX_INIT_TAG(vb.vbt_clockrate, tag); - vb.vbt_clockrate.id = id; - vb.vbt_clockrate.rate = val; + vb.vbt_clockrate.id = htole32(id); + vb.vbt_clockrate.rate = htole32(val); error = bcmmbox_request(BCMMBOX_CHANARM2VC, &vb, sizeof(vb), &res); if (error) return error; Index: sys/arch/evbarm/rpi/vcprop.h =================================================================== RCS file: /home/netbsd/src/sys/arch/evbarm/rpi/vcprop.h,v retrieving revision 1.17 diff -p -u -r1.17 vcprop.h --- sys/arch/evbarm/rpi/vcprop.h 30 Dec 2019 15:58:12 -0000 1.17 +++ sys/arch/evbarm/rpi/vcprop.h 31 Oct 2020 23:39:50 -0000 @@ -38,6 +38,8 @@ #include "opt_vcprop.h" +#include + struct vcprop_tag { uint32_t vpt_tag; #define VCPROPTAG_NULL 0x00000000 @@ -130,12 +132,12 @@ struct vcprop_tag_fwrev { struct vcprop_tag_boardmodel { struct vcprop_tag tag; uint32_t model; -} ; +}; struct vcprop_tag_boardrev { struct vcprop_tag tag; uint32_t rev; -} ; +}; #define VCPROP_REV_PCBREV __BITS(3,0) #define VCPROP_REV_MODEL __BITS(11,4) @@ -368,21 +370,21 @@ static inline bool vcprop_buffer_success_p(struct vcprop_buffer_hdr *vpbh) { - return (vpbh->vpb_rcode & VCPROP_REQ_SUCCESS); + return le32toh(vpbh->vpb_rcode) & VCPROP_REQ_SUCCESS; } static inline bool vcprop_tag_success_p(struct vcprop_tag *vpbt) { - return (vpbt->vpt_rcode & VCPROPTAG_RESPONSE); + return le32toh(vpbt->vpt_rcode) & VCPROPTAG_RESPONSE; } static inline size_t vcprop_tag_resplen(struct vcprop_tag *vpbt) { - return (vpbt->vpt_rcode & ~VCPROPTAG_RESPONSE); + return le32toh(vpbt->vpt_rcode) & ~VCPROPTAG_RESPONSE; } #endif /* _EVBARM_RPI_VCPROP_H_ */ Index: sys/arch/evbarm/rpi/vcprop_subr.c =================================================================== RCS file: /home/netbsd/src/sys/arch/evbarm/rpi/vcprop_subr.c,v retrieving revision 1.6 diff -p -u -r1.6 vcprop_subr.c --- sys/arch/evbarm/rpi/vcprop_subr.c 4 Jul 2020 15:14:56 -0000 1.6 +++ sys/arch/evbarm/rpi/vcprop_subr.c 27 Oct 2020 20:39:55 -0000 @@ -30,8 +30,9 @@ */ #include -#include #include +#include +#include #include @@ -62,19 +63,21 @@ rpi_fb_set_video(int b) } vb_setblank = { .vb_hdr = { - .vpb_len = sizeof(vb_setblank), - .vpb_rcode = VCPROP_PROCESS_REQUEST, + .vpb_len = htole32(sizeof(vb_setblank)), + .vpb_rcode = htole32(VCPROP_PROCESS_REQUEST), }, .vbt_blank = { .tag = { - .vpt_tag = VCPROPTAG_BLANK_SCREEN, - .vpt_len = VCPROPTAG_LEN(vb_setblank.vbt_blank), - .vpt_rcode = VCPROPTAG_REQUEST, + .vpt_tag = htole32(VCPROPTAG_BLANK_SCREEN), + .vpt_len = htole32(VCPROPTAG_LEN( + vb_setblank.vbt_blank)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST), }, - .state = (b != 0) ? VCPROP_BLANK_OFF : VCPROP_BLANK_ON, + .state = htole32((b != 0) ? + VCPROP_BLANK_OFF : VCPROP_BLANK_ON), }, .end = { - .vpt_tag = VCPROPTAG_NULL, + .vpt_tag = htole32(VCPROPTAG_NULL), }, }; @@ -82,8 +85,8 @@ rpi_fb_set_video(int b) sizeof(vb_setblank), &res); #ifdef RPI_IOCTL_DEBUG printf("%s: %d %d %d %08x %08x\n", __func__, b, - vb_setblank.vbt_blank.state, error, res, - vb_setblank.vbt_blank.tag.vpt_rcode); + le32toh(vb_setblank.vbt_blank.state), error, res, + le32toh(vb_setblank.vbt_blank.tag.vpt_rcode)); #endif if (error) return error; @@ -109,21 +112,22 @@ rpi_alloc_mem(uint32_t size, uint32_t al } vb_allocmem = { .vb_hdr = { - .vpb_len = sizeof(vb_allocmem), - .vpb_rcode = VCPROP_PROCESS_REQUEST, + .vpb_len = htole32(sizeof(vb_allocmem)), + .vpb_rcode = htole32(VCPROP_PROCESS_REQUEST), }, .vbt_am = { .tag = { - .vpt_tag = VCPROPTAG_ALLOCMEM, - .vpt_len = VCPROPTAG_LEN(vb_allocmem.vbt_am), - .vpt_rcode = VCPROPTAG_REQUEST, + .vpt_tag = htole32(VCPROPTAG_ALLOCMEM), + .vpt_len = + htole32(VCPROPTAG_LEN(vb_allocmem.vbt_am)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST), }, - .size = size, - .align = align, - .flags = flags, + .size = htole32(size), + .align = htole32(align), + .flags = htole32(flags), }, .end = { - .vpt_tag = VCPROPTAG_NULL, + .vpt_tag = htole32(VCPROPTAG_NULL), }, }; @@ -131,8 +135,8 @@ rpi_alloc_mem(uint32_t size, uint32_t al sizeof(vb_allocmem), &res); #ifdef RPI_IOCTL_DEBUG printf("%s: %d %d %08x %08x\n", __func__, - vb_allocmem.vbt_am.size, error, res, - vb_allocmem.vbt_am.tag.vpt_rcode); + le32toh(vb_allocmem.vbt_am.size), error, res, + le32toh(vb_allocmem.vbt_am.tag.vpt_rcode)); #endif if (error) return error; @@ -143,7 +147,7 @@ rpi_alloc_mem(uint32_t size, uint32_t al } /* Return the handle from the VC */ - return vb_allocmem.vbt_am.size; + return le32toh(vb_allocmem.vbt_am.size); } bus_addr_t @@ -159,19 +163,20 @@ rpi_lock_mem(uint32_t handle) } vb_lockmem = { .vb_hdr = { - .vpb_len = sizeof(vb_lockmem), - .vpb_rcode = VCPROP_PROCESS_REQUEST, + .vpb_len = htole32(sizeof(vb_lockmem)), + .vpb_rcode = htole32(VCPROP_PROCESS_REQUEST), }, .vbt_lm = { .tag = { - .vpt_tag = VCPROPTAG_LOCKMEM, - .vpt_len = VCPROPTAG_LEN(vb_lockmem.vbt_lm), - .vpt_rcode = VCPROPTAG_REQUEST, + .vpt_tag = htole32(VCPROPTAG_LOCKMEM), + .vpt_len = + htole32(VCPROPTAG_LEN(vb_lockmem.vbt_lm)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST), }, - .handle = handle, + .handle = htole32(handle), }, .end = { - .vpt_tag = VCPROPTAG_NULL, + .vpt_tag = htole32(VCPROPTAG_NULL), }, }; @@ -179,8 +184,8 @@ rpi_lock_mem(uint32_t handle) sizeof(vb_lockmem), &res); #ifdef RPI_IOCTL_DEBUG printf("%s: %d %d %08x %08x\n", __func__, - vb_lockmem.vbt_lm.handle, error, res, - vb_lockmem.vbt_lm.tag.vpt_rcode); + le32toh(vb_lockmem.vbt_lm.handle), error, res, + le32toh(vb_lockmem.vbt_lm.tag.vpt_rcode)); #endif if (error) return 0; @@ -190,7 +195,7 @@ rpi_lock_mem(uint32_t handle) return 0; } - return vb_lockmem.vbt_lm.handle; + return le32toh(vb_lockmem.vbt_lm.handle); } int @@ -206,19 +211,20 @@ rpi_unlock_mem(uint32_t handle) } vb_unlockmem = { .vb_hdr = { - .vpb_len = sizeof(vb_unlockmem), - .vpb_rcode = VCPROP_PROCESS_REQUEST, + .vpb_len = htole32(sizeof(vb_unlockmem)), + .vpb_rcode = htole32(VCPROP_PROCESS_REQUEST), }, .vbt_lm = { .tag = { - .vpt_tag = VCPROPTAG_UNLOCKMEM, - .vpt_len = VCPROPTAG_LEN(vb_unlockmem.vbt_lm), - .vpt_rcode = VCPROPTAG_REQUEST, + .vpt_tag = htole32(VCPROPTAG_UNLOCKMEM), + .vpt_len = + htole32(VCPROPTAG_LEN(vb_unlockmem.vbt_lm)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST), }, - .handle = handle, + .handle = htole32(handle), }, .end = { - .vpt_tag = VCPROPTAG_NULL, + .vpt_tag = htole32(VCPROPTAG_NULL), }, }; @@ -226,8 +232,8 @@ rpi_unlock_mem(uint32_t handle) sizeof(vb_unlockmem), &res); #ifdef RPI_IOCTL_DEBUG printf("%s: %d %d %08x %08x\n", __func__, - vb_unlockmem.vbt_lm.handle, error, res, - vb_unlockmem.vbt_lm.tag.vpt_rcode); + le32toh(vb_unlockmem.vbt_lm.handle), error, res, + le32toh(vb_unlockmem.vbt_lm.tag.vpt_rcode)); #endif if (error) return error; @@ -253,19 +259,20 @@ rpi_release_mem(uint32_t handle) } vb_releasemem = { .vb_hdr = { - .vpb_len = sizeof(vb_releasemem), - .vpb_rcode = VCPROP_PROCESS_REQUEST, + .vpb_len = htole32(sizeof(vb_releasemem)), + .vpb_rcode = htole32(VCPROP_PROCESS_REQUEST), }, .vbt_lm = { .tag = { - .vpt_tag = VCPROPTAG_RELEASEMEM, - .vpt_len = VCPROPTAG_LEN(vb_releasemem.vbt_lm), - .vpt_rcode = VCPROPTAG_REQUEST, + .vpt_tag = htole32(VCPROPTAG_RELEASEMEM), + .vpt_len = htole32(VCPROPTAG_LEN( + vb_releasemem.vbt_lm)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST), }, - .handle = handle, + .handle = htole32(handle), }, .end = { - .vpt_tag = VCPROPTAG_NULL, + .vpt_tag = htole32(VCPROPTAG_NULL), }, }; @@ -273,8 +280,8 @@ rpi_release_mem(uint32_t handle) sizeof(vb_releasemem), &res); #ifdef RPI_IOCTL_DEBUG printf("%s: %d %d %08x %08x\n", __func__, - vb_releasemem.vbt_lm.handle, error, res, - vb_releasemem.vbt_lm.tag.vpt_rcode); + le32toh(vb_releasemem.vbt_lm.handle), error, res, + le32toh(vb_releasemem.vbt_lm.tag.vpt_rcode)); #endif if (error) return error; @@ -300,22 +307,23 @@ rpi_fb_movecursor(int x, int y, int on) } vb_cursorstate = { .vb_hdr = { - .vpb_len = sizeof(vb_cursorstate), - .vpb_rcode = VCPROP_PROCESS_REQUEST, + .vpb_len = htole32(sizeof(vb_cursorstate)), + .vpb_rcode = htole32(VCPROP_PROCESS_REQUEST), }, .vbt_cs = { .tag = { - .vpt_tag = VCPROPTAG_SET_CURSOR_STATE, - .vpt_len = VCPROPTAG_LEN(vb_cursorstate.vbt_cs), - .vpt_rcode = VCPROPTAG_REQUEST, + .vpt_tag = htole32(VCPROPTAG_SET_CURSOR_STATE), + .vpt_len = htole32(VCPROPTAG_LEN( + vb_cursorstate.vbt_cs)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST), }, - .enable = (on != 0) ? 1 : 0, - .x = x, - .y = y, - .flags = 1, + .enable = htole32((on != 0) ? 1 : 0), + .x = htole32(x), + .y = htole32(y), + .flags = htole32(1), }, .end = { - .vpt_tag = VCPROPTAG_NULL, + .vpt_tag = htole32(VCPROPTAG_NULL), }, }; @@ -323,8 +331,8 @@ rpi_fb_movecursor(int x, int y, int on) sizeof(vb_cursorstate), &res); #ifdef RPI_IOCTL_DEBUG printf("%s: %08x %d %08x %08x\n", __func__, - vb_cursorstate.vbt_cs.enable, error, res, - vb_cursorstate.vbt_cs.tag.vpt_rcode); + le32toh(vb_cursorstate.vbt_cs.enable), error, res, + le32toh(vb_cursorstate.vbt_cs.tag.vpt_rcode)); #endif if (error) return error; @@ -351,24 +359,25 @@ rpi_fb_initcursor(bus_addr_t pixels, int } vb_cursorinfo = { .vb_hdr = { - .vpb_len = sizeof(vb_cursorinfo), - .vpb_rcode = VCPROP_PROCESS_REQUEST, + .vpb_len = htole32(sizeof(vb_cursorinfo)), + .vpb_rcode = htole32(VCPROP_PROCESS_REQUEST), }, .vbt_ci = { .tag = { - .vpt_tag = VCPROPTAG_SET_CURSOR_INFO, - .vpt_len = VCPROPTAG_LEN(vb_cursorinfo.vbt_ci), - .vpt_rcode = VCPROPTAG_REQUEST, + .vpt_tag = htole32(VCPROPTAG_SET_CURSOR_INFO), + .vpt_len = htole32(VCPROPTAG_LEN( + vb_cursorinfo.vbt_ci)), + .vpt_rcode = htole32(VCPROPTAG_REQUEST), }, - .width = 64, - .height = 64, - .format = 0, - .pixels = pixels, - .hotspot_x = hx, - .hotspot_y = hy, + .width = htole32(64), + .height = htole32(64), + .format = htole32(0), + .pixels = htole32(pixels), + .hotspot_x = htole32(hx), + .hotspot_y = htole32(hy), }, .end = { - .vpt_tag = VCPROPTAG_NULL, + .vpt_tag = htole32(VCPROPTAG_NULL), }, }; @@ -376,8 +385,8 @@ rpi_fb_initcursor(bus_addr_t pixels, int sizeof(vb_cursorinfo), &res); #ifdef RPI_IOCTL_DEBUG printf("%s: %d %d %08x %08x\n", __func__, - vb_cursorinfo.vbt_ci.width, error, res, - vb_cursorinfo.vbt_ci.tag.vpt_rcode); + le32toh(vb_cursorinfo.vbt_ci.width), error, res, + le32toh(vb_cursorinfo.vbt_ci.tag.vpt_rcode)); #endif if (error) return error;