summaryrefslogtreecommitdiff
path: root/userland
diff options
context:
space:
mode:
Diffstat (limited to 'userland')
-rw-r--r--userland/libc/include/syscall.h7
-rw-r--r--userland/libppm/ppm.c29
2 files changed, 27 insertions, 9 deletions
diff --git a/userland/libc/include/syscall.h b/userland/libc/include/syscall.h
index b50c061..72f781d 100644
--- a/userland/libc/include/syscall.h
+++ b/userland/libc/include/syscall.h
@@ -45,6 +45,13 @@
#define SYS_IPC_READ 36
#define SYS_IPC_WRITE 37
#define SYS_IPC_WRITE_TO_PROCESS 38
+#define SYS_OUTW 39
+#define SYS_INL 40
+#define SYS_OUTL 41
+#define SYS_MAP_FRAMES 42
+#define SYS_VIRTUAL_TO_PHYSICAL 43
+#define SYS_INSTALL_IRQ 44
+#define SYS_TMP_KERNEL_HANDLE_PACKET 45
int syscall(uint32_t eax, uint32_t ebx, uint32_t ecx, uint32_t edx,
uint32_t esi, uint32_t edi);
diff --git a/userland/libppm/ppm.c b/userland/libppm/ppm.c
index 030c68d..9013e27 100644
--- a/userland/libppm/ppm.c
+++ b/userland/libppm/ppm.c
@@ -64,36 +64,47 @@ int load_ppm6_file(FILE *fp, const struct PPM_IMAGE *img, uint32_t buf_width,
printf("end malloc\n");
printf("fread");
- int rc = fread(rgb, 3, n_pixels, fp);
+ const int rc = fread(rgb, 3, n_pixels, fp);
if (0 == rc)
return 0;
printf("end fread");
uint32_t *p = rgb;
+ u32 buf_size = buf_height * buf_width;
if (1 == modifier) {
- for (; rc--; p = ((uint8_t *)p) + 3) {
- uint32_t v = *p;
- buffer[cy * buf_width + cx] =
- ((v & 0xFF) << 16) | ((v & 0xFF00)) | ((v & 0xFF0000) >> 16);
+ for (int i = 0; i < rc && i < buf_size; i++, p = ((uint8_t *)p) + 3) {
+ if (cx > buf_width) {
+ i--;
+ } else {
+ uint32_t v = *p;
+ buffer[cy * buf_width + cx] =
+ ((v & 0xFF) << 16) | ((v & 0xFF00)) | ((v & 0xFF0000) >> 16);
+ }
cx++;
if (cx == img->width) {
cx = 0;
cy++;
+ i--;
continue;
}
}
} else {
- for (; rc--; p = ((uint8_t *)p) + 3) {
+ for (int i = 0; i < rc && i < buf_size; i++, p = ((uint8_t *)p) + 3) {
((uint8_t *)p)[0] *= modifier;
((uint8_t *)p)[1] *= modifier;
((uint8_t *)p)[2] *= modifier;
- uint32_t v = *p;
- buffer[cy * buf_width + cx] =
- ((v & 0xFF) << 16) | ((v & 0xFF00)) | ((v & 0xFF0000) >> 16);
+ if (cx > buf_width) {
+ i--;
+ } else {
+ uint32_t v = *p;
+ buffer[cy * buf_width + cx] =
+ ((v & 0xFF) << 16) | ((v & 0xFF00)) | ((v & 0xFF0000) >> 16);
+ }
cx++;
if (cx == img->width) {
cx = 0;
cy++;
+ i--;
continue;
}
}