BarryServer : Git

All the code for all my projects
// BarryServer : Git / OrionDesktop / commit / 535aa6298753c88a7d809227cf64962f7924543b

// Related

OrionDesktop

Barry Initial commit 535aa62 (2 years, 4 months ago)
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..85d9ce7
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,12 @@
+PROGS=$(shell basename -a $(shell find . -mindepth 1 -maxdepth 1 -type d -not -path '*/.*'))
+
+.PHONY: clean all install
+
+all:
+	@$(foreach prog,$(PROGS),$(MAKE) -s -C $(prog);)
+
+clean:
+	@$(foreach prog,$(PROGS),$(MAKE) -s -C $(prog) clean;)
+
+install:
+	@$(foreach prog,$(PROGS),$(MAKE) -s -C $(prog) install;)
diff --git a/winmgr/Makefile b/winmgr/Makefile
new file mode 100644
index 0000000..5254c7c
--- /dev/null
+++ b/winmgr/Makefile
@@ -0,0 +1,46 @@
+PRODUCT=$(notdir $(abspath $(CURDIR)))
+
+CC=i686-orion-gcc
+CFLAGS=
+
+AS=i686-orion-as
+AFLAGS=
+
+LD=i686-orion-gcc
+LFLAGS=
+
+AS_SOURCES := $(shell find . -name '*.S')
+OBJS = $(sort $(subst ./,build/,$(subst .S,.o,$(AS_SOURCES))))
+
+C_SOURCES := $(shell find . -name '*.c')
+OBJS += $(sort $(subst ./,build/,$(subst .c,.o,$(C_SOURCES))))
+
+.PHONY: clean all install
+
+all: $(PRODUCT)
+
+clean:
+	@echo "REMOVING OBJECT FILES"
+	@mkdir -p build
+	@rm -rf build
+	@touch $(PRODUCT)
+	@rm $(PRODUCT)
+
+install: $(PRODUCT)
+	@echo "INSTALLING $^"
+	@mkdir -p ${SYSROOT}/bin/
+	@install -Dm 755 $(PRODUCT) -t ${SYSROOT}/bin/
+
+$(PRODUCT): $(OBJS)
+	@echo "LINKING $@"
+	@$(LD) -o $@ $^ $(LFLAGS)
+
+build/%.o: %.c
+	@echo "COMPILING $<"
+	@mkdir -p $(@D)
+	@$(CC) -c $< -o $@ $(CFLAGS)
+
+build/%.o: %.S
+	@echo "ASSEMBLING $<"
+	@mkdir -p $(@D)
+	@$(AS) $< -o $@ $(AFLAGS)
diff --git a/winmgr/main.c b/winmgr/main.c
new file mode 100644
index 0000000..847f151
--- /dev/null
+++ b/winmgr/main.c
@@ -0,0 +1,69 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <sys/fb.h>
+
+FBVarInfo vinfo;
+FBFixInfo finfo;
+void *lfb;
+
+/* Put a pixel on the screen */
+static void
+putpixel(int x, int y, int colour)
+{
+	*((uint32_t *) lfb + (y * vinfo.xres) + x) = colour;
+}
+
+/* Main function */
+int
+main(int argc, char *argv[])
+{
+	printf("Staring Orion Desktop\n");
+
+	/* Open framebuffer */
+	int fb = open("/dev/fb", O_RDWR);
+	if (fb == -1) {
+		perror("Failed to open framebuffer");
+		goto exit_fail;
+	}
+
+	/* Get size of framebuffer */
+	if (ioctl(fb, FBIOGET_VSCREENINFO, &vinfo) == -1) {
+		perror("Failed to get framebuffer variable info");
+		goto exit_fail;
+	}
+	if (ioctl(fb, FBIOGET_FSCREENINFO, &finfo) == -1) {
+		perror("Failed to get framebuffer fixed info");
+		goto exit_fail;
+	}
+	printf("Screen is %dx%dx%d\n", vinfo.xres, vinfo.yres, vinfo.bpp);
+
+	/* Map framebuffer */
+	lfb = mmap(NULL, finfo.fbmemLen, PROT_READ|PROT_WRITE,
+	                 MAP_PRIVATE, fb, 0);
+	if ((int) lfb == -1) {
+		perror("Failed to map framebuffer");
+		goto exit_fail;
+	}
+	close(fb);
+	printf("Framebuffer mapped at %#.8x (%d bytes)\n", lfb, finfo.fbmemLen);
+
+	/* Draw to screen */
+	int x, y;
+	for (y = 0; y < 720; y++)
+		for (x = 0; x < 1280; x++)
+			putpixel(x, y, ((x*0xFF)/vinfo.xres)
+			         + (((y*0xFF)/vinfo.yres) << 8));
+
+	return 0;
+
+exit_fail:
+	if (fb != -1)
+		close(fb);
+	exit(EXIT_FAILURE);
+}