From d2600d1c841009dd32c5db3f62871ae306c490a6 Mon Sep 17 00:00:00 2001 From: jepler Date: Thu, 27 Sep 2007 11:59:26 -0500 Subject: [PATCH] make most drivers compile (but they may not load) --- src/Makefile | 30 ++++++++++---------- src/hal/components/Submakefile | 1 + src/hal/drivers/Submakefile | 2 - src/hal/drivers/hal_ax5214h.c | 4 +-- src/hal/drivers/hal_evoreg.c | 4 +-- src/hal/drivers/hal_motenc.c | 1 + src/hal/drivers/hal_ppmc.c | 11 +++++-- src/hal/drivers/hal_skeleton.c | 6 +--- src/hal/drivers/hal_speaker.c | 8 +++--- src/hal/drivers/hal_stg.c | 3 +- src/hal/drivers/hal_tiro.c | 2 +- src/hal/drivers/hal_vti.c | 3 +- src/hal/drivers/hal_vti.h | 58 ++++++++++++++++++++-------------------- src/hal/drivers/pci_8255.c | 3 +- src/hal/drivers/pluto_common.h | 1 + src/hal/drivers/serport.comp | 2 +- src/par.comp | 10 +++++++ src/par.hal | 4 +++ src/rtapi/rtapi_bitops.h | 1 + src/rtapi/rtapi_io.h | 10 +++++++ 20 files changed, 95 insertions(+), 69 deletions(-) create mode 100644 src/par.comp create mode 100644 src/par.hal create mode 100644 src/rtapi/rtapi_io.h diff --git a/src/Makefile b/src/Makefile index 7872a4a..f5e34ce 100644 --- a/src/Makefile +++ b/src/Makefile @@ -591,25 +591,14 @@ sampler-objs := hal/components/sampler.o $(MATHSTUB) # Subdirectory: hal/drivers obj-$(CONFIG_HAL_PARPORT) += hal_parport.o hal_parport-objs := hal/drivers/hal_parport.o $(MATHSTUB) -ifneq ($(BUILD_SYS),sim) obj-$(CONFIG_PCI_8255) += pci_8255.o pci_8255-objs := hal/drivers/pci_8255.o obj-$(CONFIG_HAL_TIRO) += hal_tiro.o hal_tiro-objs := hal/drivers/hal_tiro.o $(MATHSTUB) obj-$(CONFIG_HAL_STG) += hal_stg.o hal_stg-objs := hal/drivers/hal_stg.o $(MATHSTUB) -obj-$(CONFIG_HAL_VTI) += hal_vti.o -hal_vti-objs := hal/drivers/hal_vti.o $(MATHSTUB) obj-$(CONFIG_HAL_EVOREG) += hal_evoreg.o hal_evoreg-objs := hal/drivers/hal_evoreg.o $(MATHSTUB) -obj-$(CONFIG_HAL_MOTENC) += hal_motenc.o -hal_motenc-objs := hal/drivers/hal_motenc.o $(MATHSTUB) -obj-$(CONFIG_HAL_M5I20) += hal_m5i20.o -hal_m5i20-objs := hal/drivers/hal_m5i20.o $(MATHSTUB) -obj-$(CONFIG_HAL_5I2X) += hal_5i2x.o -hal_5i2x-objs := hal/drivers/mesa_5i2x/hal_5i2x.o $(MATHSTUB) -hal_5i2x-objs += hal/drivers/mesa_5i2x/5i2x_gpio.o -hal_5i2x-objs += hal/drivers/mesa_5i2x/5i2x_stepgen.o obj-$(CONFIG_HAL_AX521H) += hal_ax5214h.o hal_ax5214h-objs := hal/drivers/hal_ax5214h.o $(MATHSTUB) obj-$(CONFIG_HAL_PPMC) += hal_ppmc.o @@ -618,6 +607,17 @@ obj-$(CONFIG_HAL_SPEAKER) += hal_speaker.o hal_speaker-objs := hal/drivers/hal_speaker.o $(MATHSTUB) obj-$(CONFIG_HAL_SKELETON) += hal_skeleton.o hal_skeleton-objs := hal/drivers/hal_skeleton.o $(MATHSTUB) +ifneq ($(BUILD_SYS),sim) +obj-$(CONFIG_HAL_VTI) += hal_vti.o +hal_vti-objs := hal/drivers/hal_vti.o $(MATHSTUB) +obj-$(CONFIG_HAL_5I2X) += hal_5i2x.o +hal_5i2x-objs := hal/drivers/mesa_5i2x/hal_5i2x.o $(MATHSTUB) +hal_5i2x-objs += hal/drivers/mesa_5i2x/5i2x_gpio.o +hal_5i2x-objs += hal/drivers/mesa_5i2x/5i2x_stepgen.o +obj-$(CONFIG_HAL_MOTENC) += hal_motenc.o +hal_motenc-objs := hal/drivers/hal_motenc.o $(MATHSTUB) +obj-$(CONFIG_HAL_M5I20) += hal_m5i20.o +hal_m5i20-objs := hal/drivers/hal_m5i20.o $(MATHSTUB) endif ifneq "$(filter 2.6.%, $(kernelvers))" "" @@ -693,10 +693,10 @@ RTDEPS := $(sort $(patsubst objects/%.o,depends/%.d, $(RTOBJS))) modules: $(patsubst %.o,../rtlib/%.so,$(obj-m)) ../rtlib/%.so: $(ECHO) Linking $@ - ld -r -o objects/$*.tmp.o $^ - if test `uname -m` != ppc; then objcopy -j .rtapi_export -O binary objects/$*.tmp.o objects/$*.exp; fi - if test `uname -m` != ppc; then objcopy -G __i686.get_pc_thunk.bx `xargs -r0n1 echo -G < objects/$*.exp | grep -ve '^-G $$' | sort -u` objects/$*.tmp.o; fi - ld -shared -o $@ objects/$*.tmp.o -lm + @ld -r -o objects/$*.tmp.o $^ + @if test `uname -m` != ppc; then objcopy -j .rtapi_export -O binary objects/$*.tmp.o objects/$*.exp; fi + @if test `uname -m` != ppc; then objcopy -G __i686.get_pc_thunk.bx `xargs -r0n1 echo -G < objects/$*.exp | grep -ve '^-G $$' | sort -u` objects/$*.tmp.o; fi + @ld -shared -o $@ objects/$*.tmp.o -lm $(sort $(RTDEPS)): depends/rt%.d: %.c @mkdir -p $(dir $@) diff --git a/src/hal/components/Submakefile b/src/hal/components/Submakefile index ed7f603..145c28a 100644 --- a/src/hal/components/Submakefile +++ b/src/hal/components/Submakefile @@ -20,6 +20,7 @@ endif endif obj-m += $(patsubst hal/drivers/%.comp, %.o, $(patsubst hal/components/%.comp, %.o, $(COMPS))) +obj-m += $(patsubst hal/drivers/%.comp, %.o, $(patsubst hal/drivers/%.comp, %.o, $(COMP_DRIVERS))) $(COMP_MANPAGES): ../docs/man/man9/%.9: hal/components/%.comp ../bin/comp @mkdir -p $(dir $@) diff --git a/src/hal/drivers/Submakefile b/src/hal/drivers/Submakefile index f83140c..436d625 100644 --- a/src/hal/drivers/Submakefile +++ b/src/hal/drivers/Submakefile @@ -36,6 +36,4 @@ pluto_clean: # The kernel's build system won't know how to rebuild generated files # so modules must depend on them explicitly -ifneq ($(BUILD_SYS),sim) modules: hal/drivers/pluto_servo_rbf.h hal/drivers/m5i20_HM5-4E.h hal/drivers/pluto_step_rbf.h -endif diff --git a/src/hal/drivers/hal_ax5214h.c b/src/hal/drivers/hal_ax5214h.c index 72b6b78..e589c9f 100644 --- a/src/hal/drivers/hal_ax5214h.c +++ b/src/hal/drivers/hal_ax5214h.c @@ -108,17 +108,15 @@ #ifdef FASTIO #define rtapi_inb inb #define rtapi_outb outb -#include +#include "rtapi_io.h" #endif -#ifdef MODULE /* module information */ MODULE_AUTHOR("John Kasunich"); MODULE_DESCRIPTION("Axiom AX5214H Driver for HAL"); MODULE_LICENSE("GPL"); static char *cfg = ""; /* config string, default no boards */ RTAPI_MP_STRING(cfg, "config string"); -#endif /* MODULE */ /*********************************************************************** * STRUCTURES AND GLOBAL VARIABLES * diff --git a/src/hal/drivers/hal_evoreg.c b/src/hal/drivers/hal_evoreg.c index b17296d..4978d7c 100644 --- a/src/hal/drivers/hal_evoreg.c +++ b/src/hal/drivers/hal_evoreg.c @@ -93,9 +93,7 @@ #ifdef FASTIO #define rtapi_inb inb #define rtapi_outb outb -#ifdef RTAPI /* for ULAPI, sys/io.h defines these functs */ -#include -#endif +#include "rtapi_io.h" #endif #ifdef RTAPI /* realtime */ diff --git a/src/hal/drivers/hal_motenc.c b/src/hal/drivers/hal_motenc.c index 02580a8..b4b214b 100644 --- a/src/hal/drivers/hal_motenc.c +++ b/src/hal/drivers/hal_motenc.c @@ -137,6 +137,7 @@ #include "rtapi.h" // RTAPI realtime OS API. #include "rtapi_app.h" // RTAPI realtime module decls. +#include "rtapi_errno.h" #include "hal.h" // HAL public API decls. #include "motenc.h" // Hardware dependent defines. diff --git a/src/hal/drivers/hal_ppmc.c b/src/hal/drivers/hal_ppmc.c index 2c2e680..97e3ef1 100644 --- a/src/hal/drivers/hal_ppmc.c +++ b/src/hal/drivers/hal_ppmc.c @@ -63,7 +63,6 @@ #error This is a realtime component only! #endif -#include /* kmalloc() */ #include "rtapi.h" /* RTAPI realtime OS API */ #include "rtapi_app.h" /* RTAPI realtime module decls */ #include "hal.h" /* HAL public API decls */ @@ -72,7 +71,6 @@ #define EPSILON 1e-20 -#ifdef MODULE /* module information */ MODULE_AUTHOR("John Kasunich"); MODULE_DESCRIPTION("HAL driver for Universal PWM Controller"); @@ -89,7 +87,6 @@ int extradout[MAX_BUS*8] = { -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1 }; /* default, no extra stuff */ RTAPI_MP_ARRAY_INT(extradout, MAX_BUS*8, "bus/slot locations of extra dig out modules"); -#endif /* MODULE */ /*********************************************************************** * DEFINES (MOSTLY REGISTER ADDRESSES) * @@ -461,7 +458,11 @@ int rtapi_app_main(void) busnum, port_addr[busnum]); boards = 0; /* allocate memory for bus data - this is not shared memory */ +#ifdef SIM + bus = malloc(sizeof(bus_data_t)); +#else bus = kmalloc(sizeof(bus_data_t), GFP_KERNEL); +#endif if (bus == 0) { rtapi_print_msg(RTAPI_MSG_ERR, "PPMC: ERROR: kmalloc() failed\n"); @@ -696,7 +697,11 @@ int rtapi_app_main(void) /* mark it invalid so RT code won't access */ bus_array[busnum] = NULL; /* and free the block */ +#ifdef SIM + free(bus); +#else kfree(bus); +#endif } } /* disconnect from HAL */ diff --git a/src/hal/drivers/hal_skeleton.c b/src/hal/drivers/hal_skeleton.c index e315bf4..134b515 100644 --- a/src/hal/drivers/hal_skeleton.c +++ b/src/hal/drivers/hal_skeleton.c @@ -96,12 +96,9 @@ #ifdef FASTIO #define rtapi_inb inb #define rtapi_outb outb -#ifdef RTAPI /* for ULAPI, sys/io.h defines these functs */ -#include -#endif +#include "rtapi_io.h" #endif -#ifdef MODULE /* module information */ MODULE_AUTHOR("Martin Kuhnle"); MODULE_DESCRIPTION("Test Driver for ISA-LED Board for EMC HAL"); @@ -109,7 +106,6 @@ MODULE_LICENSE("GPL"); /* static char *cfg = 0; */ /* config string RTAPI_MP_STRING(cfg, "config string"); */ -#endif /* MODULE */ /*********************************************************************** * STRUCTURES AND GLOBAL VARIABLES * diff --git a/src/hal/drivers/hal_speaker.c b/src/hal/drivers/hal_speaker.c index cf87926..2c4fe77 100644 --- a/src/hal/drivers/hal_speaker.c +++ b/src/hal/drivers/hal_speaker.c @@ -80,7 +80,7 @@ #ifdef FASTIO #define rtapi_inb inb #define rtapi_outb outb -#include +#include "rtapi_io.h" #endif #ifdef MODULE @@ -103,7 +103,7 @@ RTAPI_MP_STRING(cfg, "config string"); */ typedef struct { hal_bit_t *signals[8]; - uint8_t last; + int last; } speaker_t; /* pointer to array of speaker_t structs in shared memory, 1 per port */ @@ -119,8 +119,8 @@ static int num_ports; /* number of ports configured */ static void write_port(void *arg, long period) { - uint8_t v = 0; - uint8_t oldval; + int v = 0; + int oldval; int i; speaker_t *port; port = arg; diff --git a/src/hal/drivers/hal_stg.c b/src/hal/drivers/hal_stg.c index 0b9e87b..f5e908b 100644 --- a/src/hal/drivers/hal_stg.c +++ b/src/hal/drivers/hal_stg.c @@ -143,8 +143,9 @@ #error This is a realtime component only! #endif -#include #include "rtapi.h" /* RTAPI realtime OS API */ +#include "rtapi_io.h" +#include "rtapi_errno.h" #include "rtapi_app.h" /* RTAPI realtime module decls */ #include "hal.h" /* HAL public API decls */ #include "hal_stg.h" /* STG related defines */ diff --git a/src/hal/drivers/hal_tiro.c b/src/hal/drivers/hal_tiro.c index f430f4a..6163b99 100644 --- a/src/hal/drivers/hal_tiro.c +++ b/src/hal/drivers/hal_tiro.c @@ -74,7 +74,7 @@ #define rtapi_inb inb #define rtapi_outb outb #ifdef RTAPI /* for ULAPI, sys/io.h defines these functs */ -#include +#include "rtapi_io.h" #endif #endif diff --git a/src/hal/drivers/hal_vti.c b/src/hal/drivers/hal_vti.c index 393ddb2..0b756fb 100644 --- a/src/hal/drivers/hal_vti.c +++ b/src/hal/drivers/hal_vti.c @@ -159,9 +159,10 @@ #error This is a realtime component only! #endif -#include #include "rtapi.h" /* RTAPI realtime OS API */ +#include "rtapi_io.h" #include "rtapi_app.h" /* RTAPI realtime module decls */ +#include "rtapi_string.h" #include #include "hal.h" /* HAL public API decls */ #include "hal_vti.h" /* VTI related defines */ diff --git a/src/hal/drivers/hal_vti.h b/src/hal/drivers/hal_vti.h index ebcf76a..a9b6d74 100644 --- a/src/hal/drivers/hal_vti.h +++ b/src/hal/drivers/hal_vti.h @@ -66,45 +66,45 @@ /* Structures used by the PCI card */ struct encoder { - u16 Counter[4]; - u8 Status; // 0x08 - u8 dummy; // dummy space - u16 Reset; // 0x0a - u8 reserved[3]; // dummy space 0x0c - 0x0f - u16 Interrupt; // 0x10 - u16 DAC; // 0x12 - u16 DIO; // 0x14 + __u16 Counter[4]; + __u8 Status; // 0x08 + __u8 dummy; // dummy space + __u16 Reset; // 0x0a + __u8 reserved[3]; // dummy space 0x0c - 0x0f + __u16 Interrupt; // 0x10 + __u16 DAC; // 0x12 + __u16 DIO; // 0x14 }; struct timer { - u8 reserved[0x2c]; - u8 ctc0; // 8254 Counter 0 - u8 ctc1; // 8254 Counter 1 - u8 ctc2; // 8254 Counter 2 - u8 control; // 8254 command register + __u8 reserved[0x2c]; + __u8 ctc0; // 8254 Counter 0 + __u8 ctc1; // 8254 Counter 1 + __u8 ctc2; // 8254 Counter 2 + __u8 control; // 8254 command register }; struct dac { - u8 reserved1[0x13f]; // dummy space - u16 dac[4]; - u16 dac_adj[4]; - u16 mode; - u16 update; - u16 reset; - u8 dummy[0x2a]; // dummy space - u8 DIO[0x10]; // Digital IO channels - u16 config0; // Direction configs for channels 00-63 - u16 config1; // Direction configs for channels 64-127 - u16 status; + __u8 reserved1[0x13f]; // dummy space + __u16 dac[4]; + __u16 dac_adj[4]; + __u16 mode; + __u16 update; + __u16 reset; + __u8 dummy[0x2a]; // dummy space + __u8 DIO[0x10]; // Digital IO channels + __u16 config0; // Direction configs for channels 00-63 + __u16 config1; // Direction configs for channels 64-127 + __u16 status; }; -/* IndustryPack mappings - Need to check IF u8 or u16, also check boundary address*/ +/* IndustryPack mappings - Need to check IF __u8 or __u16, also check boundary address*/ struct ip { - u8 ID[0x40]; // IndustryPack ID - The first (12*2) addresses used for ID info + __u8 ID[0x40]; // IndustryPack ID - The first (12*2) addresses used for ID info // consult P20 of vip-4encdac.pdf for more info. - u16 IP_int; // Interrupt status - u8 reserved[0x3e]; // dummy space - u16 IO[0x30]; // IndustryPack IO - Only need the first 0x30 address. + __u16 IP_int; // Interrupt status + __u8 reserved[0x3e]; // dummy space + __u16 IO[0x30]; // IndustryPack IO - Only need the first 0x30 address. // Again, consult manual - Might it be better to use another struct here ?? // and also for the ID stuff.... }; diff --git a/src/hal/drivers/pci_8255.c b/src/hal/drivers/pci_8255.c index 0ec9ab7..6d2f160 100644 --- a/src/hal/drivers/pci_8255.c +++ b/src/hal/drivers/pci_8255.c @@ -2,6 +2,7 @@ #include "rtapi_app.h" #include "hal.h" #include "rtapi_string.h" +#include "rtapi_io.h" #define MAX 16 @@ -40,7 +41,7 @@ static void read_all(struct state *inst, long period); static void extra_cleanup(void); -#include +#include "rtapi_io.h" #define SHIFT 4 static inline void WRITE(int value, hal_u32_t base, int offset) { // int *mem = (int*) base; diff --git a/src/hal/drivers/pluto_common.h b/src/hal/drivers/pluto_common.h index d76b09a..02c115b 100644 --- a/src/hal/drivers/pluto_common.h +++ b/src/hal/drivers/pluto_common.h @@ -54,6 +54,7 @@ static inline long extend(long old, int newlow, int nbits) { return candidate1; } + static inline void EPP_DIR_WRITE(void) { } static inline void EPP_DIR_READ(void) { } static inline void ADDR(int w) { diff --git a/src/hal/drivers/serport.comp b/src/hal/drivers/serport.comp index 74f14f7..b8c3daf 100644 --- a/src/hal/drivers/serport.comp +++ b/src/hal/drivers/serport.comp @@ -46,8 +46,8 @@ function write nofp; ;; MODULE_LICENSE("GPL"); -#include #include +#include #define MAX 8 int io[MAX] = {0,}; diff --git a/src/par.comp b/src/par.comp new file mode 100644 index 0000000..97e730f --- /dev/null +++ b/src/par.comp @@ -0,0 +1,10 @@ +component par; +pin in bit enable; +function _; +option singleton; +;; +if(enable) { + rtapi_outb(0x0, 0x378+2); + rtapi_outb(0, 0x378); + rtapi_outb(0xff, 0x378); +} diff --git a/src/par.hal b/src/par.hal new file mode 100644 index 0000000..a816f7a --- /dev/null +++ b/src/par.hal @@ -0,0 +1,4 @@ +loadrt threads period1=500000 name1=thread +loadrt par +addf par thread +start diff --git a/src/rtapi/rtapi_bitops.h b/src/rtapi/rtapi_bitops.h index 2b2a9b5..2acc427 100644 --- a/src/rtapi/rtapi_bitops.h +++ b/src/rtapi/rtapi_bitops.h @@ -282,3 +282,4 @@ static __inline__ int test_and_clear_bit(unsigned long nr, #error The header file is not usable and rtapi does not yet have support for your CPU #endif #endif +#undef ADDR diff --git a/src/rtapi/rtapi_io.h b/src/rtapi/rtapi_io.h new file mode 100644 index 0000000..30c59f3 --- /dev/null +++ b/src/rtapi/rtapi_io.h @@ -0,0 +1,10 @@ +#ifndef RTAPI_IO_H +#define RTAPI_IO_H + +#ifdef SIM +#include +#else +#include +#endif + +#endif -- 1.5.2.5