aboutsummaryrefslogtreecommitdiffstats
path: root/com32/modules
diff options
context:
space:
mode:
Diffstat (limited to 'com32/modules')
-rw-r--r--com32/modules/Makefile16
-rw-r--r--com32/modules/hello.c26
-rw-r--r--com32/modules/meminfo.c18
-rw-r--r--com32/modules/vesainfo.c44
4 files changed, 69 insertions, 35 deletions
diff --git a/com32/modules/Makefile b/com32/modules/Makefile
index e9ce1d1f..9d88d75b 100644
--- a/com32/modules/Makefile
+++ b/com32/modules/Makefile
@@ -17,32 +17,24 @@
topdir = ../..
MAKEDIR = $(topdir)/mk
-include $(MAKEDIR)/com32.mk
+include $(MAKEDIR)/elf.mk
MODULES = chain.c32 config.c32 ethersel.c32 dmitest.c32 cpuidtest.c32 \
disk.c32 pcitest.c32 elf.c32 linux.c32 reboot.c32 pmload.c32 \
meminfo.c32 sdi.c32 sanboot.c32 ifcpu64.c32 vesainfo.c32 \
kbdmap.c32 cmd.c32 vpdtest.c32 host.c32 ls.c32 gpxecmd.c32 \
- ifcpu.c32 cpuid.c32 cat.c32 pwd.c32 ifplop.c32 zzjson.c32 whichsys.c32
+ ifcpu.c32 cpuid.c32 cat.c32 pwd.c32 ifplop.c32 zzjson.c32 whichsys.c32 \
+ hello.c32
TESTFILES =
all: $(MODULES) $(TESTFILES)
-pcitest.elf : pcitest.o $(LIBS) $(C_LIBS)
- $(LD) $(LDFLAGS) -o $@ $^
-
-cpuidtest.elf : cpuidtest.o $(GPLLIB) $(LIBS) $(C_LIBS)
- $(LD) $(LDFLAGS) -o $@ $^
-
.PRECIOUS: %.o
dmitest.o: dmitest.c
$(CC) $(CFLAGS) $(GPLINCLUDE) -c -o $@ $<
-dmitest.elf : dmi_utils.o dmitest.o $(GPLLIB) $(LIBS) $(C_LIBS)
- $(LD) $(LDFLAGS) -o $@ $^
-
-ethersel.elf : ethersel.o $(LIBS) $(C_LIBS)
+dmitest.c32 : dmi_utils.o dmitest.o $(GPLLIB) $(LIBS) $(C_LIBS)
$(LD) $(LDFLAGS) -o $@ $^
tidy dist:
diff --git a/com32/modules/hello.c b/com32/modules/hello.c
new file mode 100644
index 00000000..f28d38d3
--- /dev/null
+++ b/com32/modules/hello.c
@@ -0,0 +1,26 @@
+/*
+ * hello.c - A simple ELF module that sorts a couple of numbers
+ *
+ * Created on: Aug 11, 2008
+ * Author: Stefan Bucur <stefanb@zytor.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "sort.h"
+
+#define NUM_COUNT 10
+#define MAX_NUM 100
+
+int main(int argc, char **argv)
+{
+ int *nums = NULL;
+
+ nums = malloc(NUM_COUNT * sizeof(int));
+ printf("Hello, world, from 0x%08X! malloc return %p\n", (unsigned int)&main, nums);
+
+ free(nums);
+
+ return 0;
+}
diff --git a/com32/modules/meminfo.c b/com32/modules/meminfo.c
index 96006d4c..00d0e14d 100644
--- a/com32/modules/meminfo.c
+++ b/com32/modules/meminfo.c
@@ -42,27 +42,32 @@ static void dump_e820(void)
com32sys_t ireg, oreg;
struct e820_data ed;
uint32_t type;
+ void *low_ed;
+
+ low_ed = lmalloc(sizeof ed);
+ if (!low_ed)
+ return;
memset(&ireg, 0, sizeof ireg);
ireg.eax.w[0] = 0xe820;
ireg.edx.l = 0x534d4150;
ireg.ecx.l = sizeof(struct e820_data);
- ireg.edi.w[0] = OFFS(__com32.cs_bounce);
- ireg.es = SEG(__com32.cs_bounce);
+ ireg.edi.w[0] = OFFS(low_ed);
+ ireg.es = SEG(low_ed);
memset(&ed, 0, sizeof ed);
ed.extattr = 1;
do {
- memcpy(__com32.cs_bounce, &ed, sizeof ed);
+ memcpy(low_ed, &ed, sizeof ed);
__intcall(0x15, &ireg, &oreg);
if (oreg.eflags.l & EFLAGS_CF ||
oreg.eax.l != 0x534d4150 || oreg.ecx.l < 20)
break;
- memcpy(&ed, __com32.cs_bounce, sizeof ed);
+ memcpy(&ed, low_ed, sizeof ed);
if (oreg.ecx.l >= 24) {
/* ebx base length end type */
@@ -84,6 +89,8 @@ static void dump_e820(void)
ireg.ebx.l = oreg.ebx.l;
} while (ireg.ebx.l);
+
+ free(low_ed);
}
static void dump_legacy(void)
@@ -115,10 +122,9 @@ static void dump_legacy(void)
oreg.ecx.w[0], oreg.ecx.w[0], oreg.edx.w[0], oreg.edx.w[0] << 6);
}
-int main(void)
+int main(int argc, char **argv)
{
dump_legacy();
dump_e820();
-
return 0;
}
diff --git a/com32/modules/vesainfo.c b/com32/modules/vesainfo.c
index f9b25026..86a43657 100644
--- a/com32/modules/vesainfo.c
+++ b/com32/modules/vesainfo.c
@@ -20,25 +20,31 @@ static void wait_key(void)
static void print_modes(void)
{
- static com32sys_t rm;
- struct vesa_general_info *gi;
- struct vesa_mode_info *mi;
- uint16_t mode, *mode_ptr;
- int lines;
-
- /* Allocate space in the bounce buffer for these structures */
- gi = &((struct vesa_info *)__com32.cs_bounce)->gi;
- mi = &((struct vesa_info *)__com32.cs_bounce)->mi;
-
- gi->signature = VBE2_MAGIC; /* Get VBE2 extended data */
- rm.eax.w[0] = 0x4F00; /* Get SVGA general information */
- rm.edi.w[0] = OFFS(gi);
- rm.es = SEG(gi);
- __intcall(0x10, &rm, &rm);
+ static com32sys_t rm;
+ struct vesa_general_info *gi;
+ struct vesa_mode_info *mi;
+ uint16_t mode, *mode_ptr;
+ int lines;
+
+ struct vesa_info *vesa;
+
+ vesa = lmalloc(sizeof(*vesa));
+ if (!vesa) {
+ printf("vesainfo.c32: fail in lmalloc\n");
+ return;
+ }
+ gi = &vesa->gi;
+ mi = &vesa->mi;
+
+ gi->signature = VBE2_MAGIC; /* Get VBE2 extended data */
+ rm.eax.w[0] = 0x4F00; /* Get SVGA general information */
+ rm.edi.w[0] = OFFS(gi);
+ rm.es = SEG(gi);
+ __intcall(0x10, &rm, &rm);
if (rm.eax.w[0] != 0x004F) {
printf("No VESA BIOS detected\n");
- return;
+ goto exit;
} else if (gi->signature != VESA_MAGIC) {
printf("VESA information structure has bad magic, trying anyway...\n");
}
@@ -71,9 +77,13 @@ static void print_modes(void)
mode, mi->mode_attr, mi->h_res, mi->v_res, mi->bpp,
mi->memory_layout, mi->rpos, mi->gpos, mi->bpos);
}
+
+exit:
+ free(vesa);
+ return;
}
-int main(void)
+int main(int argc, char **argv)
{
print_modes();
return 0;