Fix sign errors, make JMK2 show relative paths
diff --git a/bin/jmk2 b/bin/jmk2
index 186344c..92b703a 100755
--- a/bin/jmk2
+++ b/bin/jmk2
@@ -38,6 +38,7 @@
set root {$root}
set jmk_build_cmd {$0 $*}
set jmk_build_dir {$(pwd)}
+set jmk_makefile_dir {$PWD/$outdir}
cd {$outdir}
array set options {$options}
source {$root/share/jmk/multiplat.jmk}
diff --git a/include/kernel/sync.h b/include/kernel/sync.h
index 3fbe209..6dfdae4 100644
--- a/include/kernel/sync.h
+++ b/include/kernel/sync.h
@@ -5,14 +5,14 @@
// Synchronization primitives
/// Spinlock
-typedef volatile int spinlock_t;
+typedef int spinlock_t;
void sl_acquire(spinlock_t *sl);
void sl_release(spinlock_t *sl);
spinlock_t sl_new();
/// Semaphore
-typedef volatile int semaphore_t;
+typedef int semaphore_t;
void sm_wait(semaphore_t sm);
void sm_signal(semaphore_t sm);
diff --git a/share/jmk/jmk.m4 b/share/jmk/jmk.m4
index aa3ad79..ee4fef7 100644
--- a/share/jmk/jmk.m4
+++ b/share/jmk/jmk.m4
@@ -45,7 +45,7 @@
$1, `debug', `CFLAGS += -g
ASMFLAGS += -Fdwarf',
$1, `32', `CFLAGS += -m32',
- $1, `warn', `CFLAGS += -Wall -Wextra -Wno-unused-function -Wno-unused-variable -Wno-incompatible-pointer-types',
+ $1, `warn', `CFLAGS += -Wall -Wextra -Wno-unused-function -Wno-unused-variable -Wno-incompatible-pointer-types -Wno-unused-parameter',
$1, `nasm', `ASM = nasm',
$1, `glossaries', `LATEX_MAKE_GLOSSARIES = 1',
$1, xelatex, `LATEXC = xelatex')')
diff --git a/share/jmk/jmk.tcl b/share/jmk/jmk.tcl
index 13f3fca..2c949f4 100644
--- a/share/jmk/jmk.tcl
+++ b/share/jmk/jmk.tcl
@@ -145,6 +145,8 @@
variable obj [regsub -- {(.+)\.\w+} $src {\1.o}]
set ::objs "$::objs $obj"
+ set relpath [exec sh -c "realpath --relative-to '$::jmk_makefile_dir' '$src'"]
+
if {[string match *.c $src]} {
variable cc $::cc
if {[string match *distcc* $cc]} {
@@ -157,9 +159,14 @@
rule $obj $src {}
}
- log CC $src
+ log CC $relpath
cc "-c $::first_src -o $::target"
puts ""
+ } elseif {[string match *.s $src]} {
+ log ASM $relpath
+ rule $obj $src {
+ asm "$::asmflags $::first_src -o $::target"
+ }
}
}
}
@@ -214,11 +221,6 @@
# cc "-c $::first_src -o $::target"
# }
- rule .s.o {} {
- log ASM $::first_src
- asm "$::asmflags $::first_src -o $::target"
- }
-
rule clean {} {
shell "rm -f **/*.o **/*.a *.so $::jmk_target $::objs"
@@ -243,7 +245,7 @@
}
proc warn {} {
- cflags -Wall -Wno-unused-function -Wno-unused-variable -Wno-incompatible-pointer-types -Wno-sign-compare
+ cflags -Wall
}
proc 32 {} {
diff --git a/src/kernel/Jmk2 b/src/kernel/Jmk2
index 57a657a..39d795f 100644
--- a/src/kernel/Jmk2
+++ b/src/kernel/Jmk2
@@ -4,7 +4,7 @@
presets freestanding debug warn
-cflags -I$root/include/kernel -I$root/include -I[pwd] -O0 -Wno-ignored-qualifiers -Wno-unused-params -Wno-sign-compare
+cflags -I$root/include/kernel -I$root/include -I[pwd] -O0 -Wno-ignored-qualifiers -Wno-unused-params
# Sources are mostly platform dependent (for now ;D )
enable_multiplat
diff --git a/src/kernel/dri/fs/ext2/ext2.c b/src/kernel/dri/fs/ext2/ext2.c
index 99d5e9d..b526e8f 100644
--- a/src/kernel/dri/fs/ext2/ext2.c
+++ b/src/kernel/dri/fs/ext2/ext2.c
@@ -417,7 +417,7 @@
const uint block_size = ext2_block_size(sb);
char transfer[block_size];
- uint fsize = MIN(inode->size, size);
+ uint fsize = MIN(inode->size, (uint)size);
uint i;
// Transfer full blocks straight to the output buffer
@@ -478,8 +478,8 @@
return true;
}
-static const uint ext2_bitmap_block(struct ext2_superblock *sb,
- uint *bitmap_block, uint *index)
+static uint ext2_bitmap_block(struct ext2_superblock *sb,
+ uint *bitmap_block, uint *index)
{
const uint block_size = ext2_block_size(sb);
@@ -539,7 +539,7 @@
ext2_read_block(sb, buffer, block);
// If this is the first block start at start_at, otherwise 0
- for (int i = 0; i < block_size / 4; i++)
+ for (uint i = 0; i < block_size / 4; i++)
{
// The bitwise negative will be non-zero if there are zero bits in
// the original.
@@ -577,7 +577,7 @@
kprintf(INFO "%d block groups\n", num_block_groups);
- for (int bg_num = 0; bg_num < num_block_groups; bg_num++)
+ for (uint bg_num = 0; bg_num < num_block_groups; bg_num++)
{
struct ext2_block_group_descriptor bgd =
ext2_load_bgd(sb, 0);
@@ -607,7 +607,7 @@
{
uint num_block_groups = ext2_num_block_groups(sb);
- for (int bg_num = 0; bg_num < num_block_groups; bg_num++)
+ for (uint bg_num = 0; bg_num < num_block_groups; bg_num++)
{
struct ext2_block_group_descriptor bgd =
ext2_load_bgd(sb, 0);
diff --git a/src/kernel/dri/pci/pci.c b/src/kernel/dri/pci/pci.c
index bb0b36c..df958b1 100644
--- a/src/kernel/dri/pci/pci.c
+++ b/src/kernel/dri/pci/pci.c
@@ -119,7 +119,7 @@
// Do any drivers support this?
- for (int i = 0; i < num_drivers; i++)
+ for (uint i = 0; i < num_drivers; i++)
{
if (drivers[i].supports(&dev))
{
@@ -136,9 +136,9 @@
void pci_print_drivers()
{
kprintf(INFO "Enumerating PCI device drivers:\n");
- for (int i = 0; i < num_drivers; i++)
+ for (uint i = 0; i < num_drivers; i++)
{
- for (int j = 0; j < drivers[i].loaded; j++)
+ for (uint j = 0; j < drivers[i].loaded; j++)
{
struct pci_device_driver d = drivers[i];
kprintf(INFO "Driver: %s, vendor: %s\n", d.generic_name, d.dev.vendor->name);
diff --git a/src/kernel/x86_32/descriptor_tables.c b/src/kernel/x86_32/descriptor_tables.c
index 339162e..56ea13f 100644
--- a/src/kernel/x86_32/descriptor_tables.c
+++ b/src/kernel/x86_32/descriptor_tables.c
@@ -47,6 +47,7 @@
e->access = access;
}
+/*
static void init_tss(uint num, uint ss, uint esp)
{
gdt_set_gate(num, (uint)&tss_entry, (uint)&tss_entry+1, 0xe9, 0x00);
@@ -60,6 +61,7 @@
// can switch to kernel mode using this tss
tss_entry.ss = tss_entry.ds = tss_entry.es = tss_entry.fs = tss_entry.gs = 0x13;
}
+*/
void init_gdt()
{
diff --git a/src/kernel/x86_32/main.c b/src/kernel/x86_32/main.c
index 4d3d868..e1963e8 100644
--- a/src/kernel/x86_32/main.c
+++ b/src/kernel/x86_32/main.c
@@ -75,7 +75,7 @@
#ifdef TEST_THREADS
kprintf(DEBUG "Spawning test thread\n");
- spawn_thread(other_thread, NULL);
+ spawn_thread((task_function_t)other_thread, NULL);
greet();
#endif
diff --git a/src/kernel/x86_32/paging.c b/src/kernel/x86_32/paging.c
index c77f499..ff6226b 100644
--- a/src/kernel/x86_32/paging.c
+++ b/src/kernel/x86_32/paging.c
@@ -17,7 +17,6 @@
/* frames bitset, 0 = free, 1 = used */
static uint frames[NUM_FRAMES];
-static uint first_page_table[1024] __attribute__((aligned(4096)));
uint kernel_page_directory[1024] __attribute__((aligned(4096)));
@@ -31,12 +30,6 @@
frames[frame / BITS] |= 1 << (frame % BITS);
}
-static bool test_frame(size_t frame_addr)
-{
- uint frame = frame_addr / 0x1000; // page aligned
- return frames[frame / BITS] & 1 << (frame % BITS);
-}
-
static void clear_frame(size_t frame_addr)
{
uint frame = frame_addr / 0x1000; // page aligned
@@ -90,7 +83,6 @@
void map_4mb(uint *dir, size_t virt_start, size_t phys_start, bool user,
bool rw)
{
- uint page = virt_start / 0x1000;
uint table = virt_start >> 22;
for (uint i = 0; i < 1024 * 0x1000; i += 0x1000)
@@ -238,6 +230,7 @@
load_page_directory(VIRT_TO_PHYS(kernel_page_directory));
}
+#ifdef TEST_PAGING
void test_paging()
{
// a random page base address
@@ -252,3 +245,4 @@
base[i] = i;
}
}
+#endif
diff --git a/src/kernel/x86_32/timer.c b/src/kernel/x86_32/timer.c
index 0e52d0e..59af51d 100644
--- a/src/kernel/x86_32/timer.c
+++ b/src/kernel/x86_32/timer.c
@@ -5,8 +5,6 @@
#include "registers.h"
#include "task.h"
-static ulong tick = 0;
-
static void timer_cb(struct registers *regs)
{
if (tasks_initialized)