Update jmk, PCI
diff --git a/share/jmk/jmk.m4 b/share/jmk/jmk.m4
index b454398..06ca08a 100644
--- a/share/jmk/jmk.m4
+++ b/share/jmk/jmk.m4
@@ -9,7 +9,8 @@
define(`_foreach', `ifelse(`$2', `()', `',
`define(`$1', _arg1$2)$3`'$0(`$1', (shift$2), `$3')')')
-
+define(status_log, ` @printf " \e[1;34m%8s\e[m %s\n" "$1" "$2"')
+define(DO_MAKE, `$(MAKE) --no-print-directory MAKEFILE_DEPTH="$$(( $(MAKEFILE_DEPTH) + 1))"')
define(init,
`jmk_project := $1
@@ -19,6 +20,9 @@
CC ?= gcc
LD ?= ld
CFLAGS += -I$(ROOT)/include
+jmk_clean_libs =
+
+MAKEFILE_DEPTH ?= 1
all: $(jmk_target)')
@@ -30,8 +34,7 @@
$1, `debug', `CFLAGS += -g',
$1, `32', `CFLAGS += -m32',
$1, `warn', `CFLAGS += -Wall -Wno-unused-function -Wno-unused-variable',
- $1, `nasm', `ASM = nasm'
- )')
+ $1, `nasm', `ASM = nasm')')
dnl this is really, really terrible, but to my knowledge there is no
dnl other way to escape a $. The manual says nothing about this.
@@ -41,20 +44,26 @@
dnl archetype enables a language archetype
define(archetype,
`ifelse($1, c, `.c.o:
- $(CC) -c $< -o dollar_at $(CFLAGS)',
+status_log(CC, $<)
+ @$(CC) -c $< -o dollar_at $(CFLAGS)',
$1, asm, `.s.o:
- $(ASM) $(ASMFLAGS) $< -o dollar_at'
- )'
-)
+status_log(AS, $<)
+ @$(ASM) $(ASMFLAGS) $< -o dollar_at')')
dnl depends declares an external dependency
define(`depends', `
+jmk_clean_libs += jmk_lib_clean_$1
jmk_lib_path_$1 = $2
jmk_lib_target_$1 = ifelse($3, `', $1.a, $3)
jmk_libs_phony += $(jmk_lib_path_$1)/$(jmk_lib_target_$1)
$(jmk_lib_path_$1)/$(jmk_lib_target_$1):
- $(MAKE) -C $(jmk_lib_path_$1) $(jmk_lib_target_$1)')
+status_log(MAKE[$(MAKEFILE_DEPTH)], Entering $2)
+ @DO_MAKE -C $(jmk_lib_path_$1) $(jmk_lib_target_$1)
+status_log(MAKE[$(MAKEFILE_DEPTH)], Leaving $2)
+
+jmk_lib_clean_$1:
+ @DO_MAKE -C $2 clean')
dnl lib is used to list an external dependency declared with depends()
define(`lib', `$(jmk_lib_path_$1)/$(jmk_lib_target_$1)')
@@ -65,25 +74,28 @@
define(type,
`ifelse($1, executable,
`$(jmk_target): $(OBJECTS)
- $(CC) -o dollar_at $^ $(CFLAGS)',
+status_log(CC, dollar_at)
+ @$(CC) -o dollar_at $^ $(CFLAGS)',
$1, static_lib,
`$(jmk_target): $(OBJECTS)
- ar rcs dollar_at $^',
+status_log(AR, dollar_at)
+ @ar rcs dollar_at $^',
$1, custom_link,
`$(jmk_target): $(OBJECTS)
- $(LD) $(LDFLAGS) -o dollar_at $^'
- )')
+status_log(LD, dollar_at)
+ @$(LD) $(LDFLAGS) -o dollar_at $^')')
dnl finish is required at the end of the Jmk file to generate some
dnl final declarations
define(finish,
-`clean:
- rm -f *.o *.a *.so $(jmk_target)
+`clean: $(jmk_clean_libs)
+ @rm -f *.o *.a *.so $(jmk_target)
Makefile: Jmk
- cd "jmk_build_dir" && jmk_build_cmd
+status_log(JMK, jmk_build_dir)
+ @cd "jmk_build_dir" && jmk_build_cmd
-.PHONY: $(jmk_libs_phony) $(jmk_custom_phony) clean all')
+.PHONY: $(jmk_libs_phony) $(jmk_custom_phony) $(jmk_clean_libs) clean all')
divert(0)dnl
diff --git a/src/kernel/Jmk b/src/kernel/Jmk
index 4133349..8300fd8 100644
--- a/src/kernel/Jmk
+++ b/src/kernel/Jmk
@@ -12,6 +12,9 @@
depends(initrd, $(ROOT)/boot/initrd, initrd.img)
depends(ata_pio, dri/ata_pio, ata_pio.a)
+depends(pci, dri/pci, pci.a)
+# AHCI not yet implemented
+# depends(ahci, dri/ahci, ahci.a)
CFLAGS += -I $(ROOT)/include/kernel
@@ -41,7 +44,8 @@
syscall.o \
task.o \
task_api.o \
- lib(ata_pio)
+ lib(ata_pio) \
+ lib(pci)
type(custom_link)
diff --git a/src/kernel/dri/pci/Jmk b/src/kernel/dri/pci/Jmk
index 07b50d2..4950d74 100644
--- a/src/kernel/dri/pci/Jmk
+++ b/src/kernel/dri/pci/Jmk
@@ -6,10 +6,10 @@
preset(32)
preset(warn)
-CFLAGS += -I $(ROOT)/include/kernel
-
archetype(c)
+CFLAGS += -I$(ROOT)/include/kernel
+
OBJECTS = pci.o
type(static_lib)
diff --git a/src/kernel/dri/pci/pci.c b/src/kernel/dri/pci/pci.c
index 09c9056..87e5d2e 100644
--- a/src/kernel/dri/pci/pci.c
+++ b/src/kernel/dri/pci/pci.c
@@ -1,10 +1,10 @@
-#include <dri/pci.h>
+#include <dri/pci/pci.h>
ushort pci_config_readw(uchar bus, uchar slot, uchar func, uchar offset)
{
struct pci_config_address address =
{
- .enabled = 1,
+ .enable = 1,
.bus = bus,
.device = slot,
.function = func,