summaryrefslogtreecommitdiff
path: root/stage3/gfx.c
diff options
context:
space:
mode:
authorKimapr <kimapr@mail.ru>2023-12-15 23:12:38 +0500
committerLizzy Fleckenstein <lizzy@vlhl.dev>2023-12-19 06:40:55 +0100
commita6b460d3b1b0909e0c7b388f1a55365bf24c6b7b (patch)
tree73484f566e56393122f20ddbd75f92752f992ac7 /stage3/gfx.c
parenteef564059f773e5d29b1f6e547b8b0a3c50dfab2 (diff)
downloadcuddles-a6b460d3b1b0909e0c7b388f1a55365bf24c6b7b.tar.xz
gfx: use barriers; fix entry symbol linking order
Diffstat (limited to 'stage3/gfx.c')
-rw-r--r--stage3/gfx.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/stage3/gfx.c b/stage3/gfx.c
index b01e89a..70a68d9 100644
--- a/stage3/gfx.c
+++ b/stage3/gfx.c
@@ -15,7 +15,9 @@ u32 make_color(color col)
void gfx_set_pixel(u16 x, u16 y, u32 col)
{
- *((u32 *) (u64) (gfx_info->framebuffer + y * gfx_info->pitch + x * sizeof col)) = col;
+ u32 *out = (u32 *) (u64) (gfx_info->framebuffer + y * gfx_info->pitch + x * sizeof col);
+ *out = col;
+ BARRIER_VAR(out);
}
void gfx_set_area(u16 x, u16 y, u16 w, u16 h, u32 col)
@@ -24,12 +26,14 @@ void gfx_set_area(u16 x, u16 y, u16 w, u16 h, u32 col)
void *cend = cbeg + h * gfx_info->pitch;
for (; cbeg < cend; cbeg += gfx_info->pitch) {
- void *rbeg = cbeg;
- void *rend = rbeg + w * sizeof col;
+ u32 *rbeg = cbeg;
+ u32 *rend = rbeg + w;
- for (; rbeg < rend; rbeg += sizeof col)
- *((u32 *) rbeg) = col;
+ for (; rbeg < rend; rbeg++)
+ *rbeg = col;
}
+
+ BARRIER_VAR(cbeg);
}
void gfx_draw_img(u16 x, u16 y, u16 w, u16 h, u32 *img)
@@ -37,4 +41,6 @@ void gfx_draw_img(u16 x, u16 y, u16 w, u16 h, u32 *img)
void *cbeg = (void *) (u64) (gfx_info->framebuffer + y * gfx_info->pitch + x * sizeof(color));
for (u16 yi = 0; yi < h; cbeg += gfx_info->pitch, yi++)
memcpy(cbeg, img + yi * w, w * sizeof(color));
+
+ BARRIER_VAR(cbeg);
}