Resent-Date: Mon, 21 Dec 1998 10:30:50 +0100 (MET) From: zippel@fh-brandenburg.de (Roman Zippel) Subject: experimental patches 2.1.131 To: linux-m68k@phil.uni-sb.de Date: Mon, 21 Dec 1998 10:30:02 +0100 (MET) Resent-From: linux-m68k@phil.uni-sb.de Hi, These patches include lots of experimental stuff, so I can only say that they work on my machine and it's very likely that they break everything else :). So I need comments especially for non-Amigas and 020/030 cpus. First a short list of changes: - remove CONFIG_OPTIMIZE_0?0 completly - make more use of the config include feature - include some os support for the math emu stuff - major update of the interrupt code (includes realtime interrupt) - kbd_reset_setup() is a function in init/main.c, we defined it as pointer (unused anyway so a dummy function now) - another head.S cleanup (this includes some minor memory management updates) - using m68k_defs.h a bit more more (it's really removed now and should always be generated, after applying the patch you might still have to remove it by hand or do a make clean) - moving of some declaration into amigadep.h and allow to use real function calls instead of function pointers if only compiled for a single machine (I needed/wanted that future for the realtime stuff) - some serial stuff changes to support realtime interrupts (side effect: maximum of the builtin serial port is now 115200 baud :) ) - first version of the atomic interface (it will change again as this lacks any support for Sparc/SMP), also needed for the realtime stuff. Now some more comments about this. Basically everything is built around the realtime interrupt support, which is only supported on the amiga by now, besides that it includes the head.S changes, some math emu os support for David and some small bug fixes. Because of the realtime interrupts the general interrupt code got a major update, which should make it very easy for most machines. The general interrupt code does now only manage the interrupt handler, there it now also supports user vector interrupts and chained handlers. All there is left to do now in the machine specific code is to install the entry code into the vector table (process_int() is dead now). Just look into asm/irq.h for this, there are some more comments about this. There is still a default entry in entry.S (to be exactly there are 4 versions of it). More tricky is the realtime support. Here the interrupts are never turned off by sti() instead a counter is incremented. If interrupts occur in that time only realtime interrupts are executed immediatly, soft interrupts are instead executed together with the bottom half handlers, either at the end of the interrupt or when interrupts are allowed again. To delay the interrupt execution the interrupt source must be turned off that is best done by some machine specific code in the interrupt entry code. If that is not possible there should be the (not yet implemented) possibility to set some flag to let interrupt handler execute later and the entry code modifies the saved status register on the stack to the current interupt level to prevent reentrancy. With some sane interrupt priorities this should work quite good. Anyway the first real user of this is the amiga serial support, that works even with 115200 now, the only problem that is left every 5 second I get a error, but that is independent of the direction and speed and transmitting is still nonrealtime, so I must do some more tests on this, but of course I'm interested in comments of results on other machines. I made a lot of changes head.S, most of them are documented there. The only real problem I have here (besides it must be tested on other machines) is the mac stuff especially the mapping of videomemory, where I don't completly understand the magic. Anyway if it's that a problem it's possible to create a temporary mapping and to free or move it later. The mmu printing code is completly broken now, I didn't need it, so I didn't fix it, do other need it? Anyway as the mmu can be turned off completly without transparent translation register now, it's free for any use now, even the 030 tt register is supported (but untested of course), it seems the mac could need it :). I added a new kernel option "timer=ciaa|ciab" to choose which timer to use for the system timer (e.g. to avoid the high priority timer ciab). But it doesn't seem to work yet, as soon as ide tries to probe for the drives everything stands (this is already before request_irq()). Maybe someones remembers my perl request a few weeks ago, if you do now a "make checkconfig" you know what I mean. Hmm, I hope I didn't forgot anything important, these patches are not meant yet for final integration and there are still some debugging prints on, but maybe someone needs something to hack over christmas :-). I'm going home at wednesday and I will be a bit offline for the rest of the year, but I'm of course happy to answer any question to all the stuff till then. If someone wants only to test a part of it, it should be possible to left out the new head.S, but head.S itself requires the changes under m68k/mm/, since the new map_chunk() and the kpointer stuff doesn't rely on information from head.S anymore. bye, Roman Index: linux-2.1/Documentation/Configure.help diff -u linux-2.1/Documentation/Configure.help:1.1.1.18.2.3 linux-2.1/Documentation/Configure.help:1.1.1.18.2.3.2.1 --- linux-2.1/Documentation/Configure.help:1.1.1.18.2.3 Sat Dec 19 18:51:07 1998 +++ linux-2.1/Documentation/Configure.help Sat Dec 19 21:28:01 1998 @@ -9596,26 +9596,10 @@ MC68EC040 will not work, as it does not include an MMU (Memory Management Unit). -Use -m68040 flag for 68040 specific optimizations -CONFIG_OPTIMIZE_040 - If you will only be running this kernel on a 68040-series processor, - this will make the kernel run somewhat faster. However, it will no - longer run on a 68020 or 68030, no matter whether you included 68020 - and 68030 support or not. Say N unless the only processor you are - compiling support for is the 68040 (or 68LC040). - 68060 support CONFIG_M68060 If you anticipate running this kernel on a computer with a MC68060 processor, say Y. Otherwise, say N. - -Use -m68060 flag for 68060 specific optimizations -CONFIG_OPTIMIZE_060 - If you will only be running this kernel on a 68060-series processor, - this will make the kernel run somewhat faster. However, it will no - longer run on a 68020, 68030 or 68040, no matter whether you - included support for those processors or not. Say N unless the only - processor you are compiling support for is the 68060. Advanced processor options CONFIG_ADVANCED_CPU Index: linux-2.1/arch/m68k/Makefile diff -u linux-2.1/arch/m68k/Makefile:1.1.1.1.6.3 linux-2.1/arch/m68k/Makefile:1.1.1.1.6.3.2.2 --- linux-2.1/arch/m68k/Makefile:1.1.1.1.6.3 Sat Dec 19 18:51:09 1998 +++ linux-2.1/arch/m68k/Makefile Sun Dec 20 01:29:09 1998 @@ -29,14 +29,21 @@ # without -fno-strength-reduce the 53c7xx.c driver fails ;-( CFLAGS += -pipe -fno-strength-reduce -ffixed-a2 -ifdef CONFIG_OPTIMIZE_040 +# enable processor switch if compiled only for a single cpu +ifndef CONFIG_M68020 +ifndef CONFIG_M68030 + +ifndef CONFIG_M68060 CFLAGS := $(CFLAGS) -m68040 endif -ifdef CONFIG_OPTIMIZE_060 +ifndef CONFIG_M68040 CFLAGS := $(CFLAGS) -m68060 endif +endif +endif + ifdef CONFIG_KGDB # If configured for kgdb support, include debugging infos and keep the # frame pointer @@ -115,8 +122,7 @@ endif archclean: - rm -f vmlinux.gz - rm -f kernel/m68k_defs.h kernel/m68k_defs.d + rm -f vmlinux.gz arch/m68k/kernel/m68k_defs.[hd] archmrproper: Index: linux-2.1/arch/m68k/config.in diff -u linux-2.1/arch/m68k/config.in:1.1.1.7.4.3 linux-2.1/arch/m68k/config.in:1.1.1.7.4.3.2.2 --- linux-2.1/arch/m68k/config.in:1.1.1.7.4.3 Sat Dec 19 18:51:10 1998 +++ linux-2.1/arch/m68k/config.in Sun Dec 20 01:29:10 1998 @@ -22,12 +22,15 @@ comment 'Platform dependent setup' bool 'Amiga support' CONFIG_AMIGA +if [ "$CONFIG_AMIGA" = "y" ]; then + define_bool CONFIG_APUS n +fi bool 'Atari support' CONFIG_ATARI if [ "$CONFIG_ATARI" = "y" ]; then bool ' Hades support' CONFIG_HADES if [ "$CONFIG_HADES" = "y" ]; then define_bool CONFIG_PCI y - fi + fi fi bool 'Macintosh support' CONFIG_MAC if [ "$CONFIG_MAC" = "y" ]; then @@ -44,6 +47,7 @@ if [ "$CONFIG_HP300" = "y" ]; then bool 'DIO bus support' CONFIG_DIO fi +define_bool CONFIG_SUN3 n if [ "$CONFIG_PCI" = "y" ]; then bool 'Backward-compatible /proc/pci' CONFIG_PCI_OLD_PROC fi @@ -53,6 +57,12 @@ bool '68030 support' CONFIG_M68030 bool '68040 support' CONFIG_M68040 bool '68060 support' CONFIG_M68060 +if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then + bool 'Math emulation support' CONFIG_MATH_EMU + if [ "$CONFIG_MATH_EMU" = "y" ]; then + bool 'Math emulation only kernel' CONFIG_MATH_EMU_ONLY + fi +fi bool 'Advanced configuration options' CONFIG_ADVANCED if [ "$CONFIG_ADVANCED" = "y" ]; then bool 'Use read-modify-write instructions' CONFIG_RMW_INSNS @@ -60,6 +70,7 @@ if [ "$CONFIG_M68060" = "y" ]; then bool 'Use write-through caching for 68060 supervisor accesses' CONFIG_060_WRITETHROUGH fi + bool 'Enable realtime interrupts' CONFIG_RT_INTERRUPT fi endmenu Index: linux-2.1/arch/m68k/amiga/amiga_ksyms.c diff -u linux-2.1/arch/m68k/amiga/amiga_ksyms.c:1.1.1.3.6.2 linux-2.1/arch/m68k/amiga/amiga_ksyms.c:1.1.1.3.6.2.2.1 --- linux-2.1/arch/m68k/amiga/amiga_ksyms.c:1.1.1.3.6.2 Sat Dec 19 18:51:11 1998 +++ linux-2.1/arch/m68k/amiga/amiga_ksyms.c Sat Dec 19 21:28:06 1998 @@ -1,10 +1,19 @@ -#include #include #include #include +#include #include #include +#include +#ifdef CONFIG_EXPERIMENTAL +#include +#endif +#include +#ifdef CONFIG_ADVANCED +#include +#endif + extern volatile u_short amiga_audio_min_period; extern u_short amiga_audio_period; @@ -29,4 +38,7 @@ EXPORT_SYMBOL(pcmcia_access_speed); EXPORT_SYMBOL(pcmcia_write_enable); EXPORT_SYMBOL(pcmcia_write_disable); +#endif +#ifdef CONFIG_RT_INTERRUPT +EXPORT_SYMBOL(amiga_do_irqrequest); #endif Index: linux-2.1/arch/m68k/amiga/amiints.c diff -u linux-2.1/arch/m68k/amiga/amiints.c:1.1.1.3.6.2 linux-2.1/arch/m68k/amiga/amiints.c:1.1.1.3.6.2.2.2 --- linux-2.1/arch/m68k/amiga/amiints.c:1.1.1.3.6.2 Sat Dec 19 18:51:12 1998 +++ linux-2.1/arch/m68k/amiga/amiints.c Sun Dec 20 01:29:11 1998 @@ -25,39 +25,47 @@ #include #include #include +#include #include +#include #include #include +#include #include #include #include #include +#include +#include +#ifdef CONFIG_ADVANCED +#include +#endif + extern int cia_request_irq(struct ciabase *base,int irq, void (*handler)(int, void *, struct pt_regs *), unsigned long flags, const char *devname, void *dev_id); extern void cia_free_irq(struct ciabase *base, unsigned int irq, void *dev_id); -extern void cia_init_IRQ(struct ciabase *base); -extern int cia_get_irq_list(struct ciabase *base, char *buf); - -/* irq node variables for amiga interrupt sources */ -static irq_node_t *ami_irq_list[AMI_STD_IRQS]; +extern void cia_init_IRQ(void); unsigned short ami_intena_vals[AMI_STD_IRQS] = { - IF_VERTB, IF_COPER, IF_AUD0, IF_AUD1, IF_AUD2, IF_AUD3, IF_BLIT, - IF_DSKSYN, IF_DSKBLK, IF_RBF, IF_TBE, IF_SOFT, IF_PORTS, IF_EXTER + IF_TBE, IF_DSKBLK, IF_SOFT, IF_PORTS, IF_COPPER, IF_VERTB, IF_BLIT, + IF_AUD0, IF_AUD1, IF_AUD2, IF_AUD3, IF_RBF, IF_DSKSYN, IF_EXTER }; -static const unsigned char ami_servers[AMI_STD_IRQS] = { - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 +static const unsigned char ami_servers[AMI_IRQS] = { + 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static short ami_ablecount[AMI_IRQS]; -static void ami_badint(int irq, void *dev_id, struct pt_regs *fp) -{ - num_spurious += 1; -} +static void ami_int1(int irq, void *dev_id, struct pt_regs *fp); +static void ami_int2(int irq, void *dev_id, struct pt_regs *fp); +static void ami_int3(int irq, void *dev_id, struct pt_regs *fp); +static void ami_int4(int irq, void *dev_id, struct pt_regs *fp); +static void ami_int5(int irq, void *dev_id, struct pt_regs *fp); +static void ami_int6(int irq, void *dev_id, struct pt_regs *fp); /* * void amiga_init_IRQ(void) @@ -70,26 +78,15 @@ * the amiga IRQ handling routines. */ -__initfunc(void amiga_init_IRQ(void)) +void __init amiga_init_IRQ(void) { int i; - /* initialize handlers */ - for (i = 0; i < AMI_STD_IRQS; i++) { - if (ami_servers[i]) { - ami_irq_list[i] = NULL; - } else { - ami_irq_list[i] = new_irq_node(); - ami_irq_list[i]->handler = ami_badint; - ami_irq_list[i]->flags = IRQ_FLG_STD; - ami_irq_list[i]->dev_id = NULL; - ami_irq_list[i]->devname = NULL; - ami_irq_list[i]->next = NULL; - } - } for (i = 0; i < AMI_IRQS; i++) ami_ablecount[i] = 0; + vectors[VEC_INT7] = nmi_handler; + /* turn off PCMCIA interrupts */ if (AMIGAHW_PRESENT(PCMCIA)) pcmcia_disable_irq(); @@ -98,70 +95,23 @@ custom.intena = 0x7fff; custom.intreq = 0x7fff; custom.intena = IF_SETCLR | IF_INTEN; - - cia_init_IRQ(&ciaa_base); - cia_init_IRQ(&ciab_base); -} - -static inline void amiga_insert_irq(irq_node_t **list, irq_node_t *node) -{ - unsigned long flags; - irq_node_t *cur; - - if (!node->dev_id) - printk("%s: Warning: dev_id of %s is zero\n", - __FUNCTION__, node->devname); - - save_flags(flags); - cli(); - - cur = *list; - - if (node->flags & IRQ_FLG_FAST) { - node->flags &= ~IRQ_FLG_SLOW; - while (cur && cur->flags & IRQ_FLG_FAST) { - list = &cur->next; - cur = cur->next; - } - } else if (node->flags & IRQ_FLG_SLOW) { - while (cur) { - list = &cur->next; - cur = cur->next; - } - } else { - while (cur && !(cur->flags & IRQ_FLG_SLOW)) { - list = &cur->next; - cur = cur->next; - } - } - node->next = cur; - *list = node; + request_irq(IRQ_AMIGA_AUTO_1, ami_int1, IRQ_FLG_REALTIME, + "int1 handler", NULL); + request_irq(IRQ_AMIGA_AUTO_2, ami_int2, IRQ_FLG_REALTIME, + "int2 handler", NULL); + request_irq(IRQ_AMIGA_AUTO_3, ami_int3, IRQ_FLG_REALTIME, + "int3 handler", NULL); + request_irq(IRQ_AMIGA_AUTO_4, ami_int4, IRQ_FLG_REALTIME, + "int4 handler", NULL); + request_irq(IRQ_AMIGA_AUTO_5, ami_int5, IRQ_FLG_REALTIME, + "int5 handler", NULL); + request_irq(IRQ_AMIGA_AUTO_6, ami_int6, IRQ_FLG_REALTIME, + "int6 handler", NULL); - restore_flags(flags); + cia_init_IRQ(); } -static inline void amiga_delete_irq(irq_node_t **list, void *dev_id) -{ - unsigned long flags; - irq_node_t *node; - - save_flags(flags); - cli(); - - for (node = *list; node; list = &node->next, node = *list) { - if (node->dev_id == dev_id) { - *list = node->next; - /* Mark it as free. */ - node->handler = NULL; - restore_flags(flags); - return; - } - } - restore_flags(flags); - printk ("%s: tried to remove invalid irq\n", __FUNCTION__); -} - /* * amiga_request_irq : add an interrupt service routine for a particular * machine specific interrupt source. @@ -171,17 +121,25 @@ int amiga_request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *), unsigned long flags, const char *devname, void *dev_id) { - irq_node_t *node; + unsigned int vec; + int res; if (irq >= AMI_IRQS) { printk ("%s: Unknown IRQ %d from %s\n", __FUNCTION__, irq, devname); return -ENXIO; } + + printk("irq: %x-%s (%x,%x)\n", irq, devname, flags, dev_id); + if (irq >= IRQ_AMIGA_AUTO) { + vec = irq - IRQ_AMIGA_AUTO + VEC_SPUR; - if (irq >= IRQ_AMIGA_AUTO) - return sys_request_irq(irq - IRQ_AMIGA_AUTO, handler, - flags, devname, dev_id); + res = sys_request_irq(vec, handler, flags, devname, dev_id); + if (!res) + vectors[vec] = amiga_inthandler; + return res; + } + if (irq >= IRQ_AMIGA_CIAB) return cia_request_irq(&ciab_base, irq - IRQ_AMIGA_CIAB, handler, flags, devname, dev_id); @@ -190,51 +148,48 @@ return cia_request_irq(&ciaa_base, irq - IRQ_AMIGA_CIAA, handler, flags, devname, dev_id); - if (ami_servers[irq]) { - if (!(node = new_irq_node())) - return -ENOMEM; - node->handler = handler; - node->flags = flags; - node->dev_id = dev_id; - node->devname = devname; - node->next = NULL; - amiga_insert_irq(&ami_irq_list[irq], node); - } else { - if (!(ami_irq_list[irq]->flags & IRQ_FLG_STD)) { - if (ami_irq_list[irq]->flags & IRQ_FLG_LOCK) { - printk("%s: IRQ %d from %s is not replaceable\n", - __FUNCTION__, irq, ami_irq_list[irq]->devname); - return -EBUSY; - } - if (!(flags & IRQ_FLG_REPLACE)) { - printk("%s: %s can't replace IRQ %d from %s\n", - __FUNCTION__, devname, irq, ami_irq_list[irq]->devname); - return -EBUSY; - } - } - ami_irq_list[irq]->handler = handler; - ami_irq_list[irq]->flags = flags; - ami_irq_list[irq]->dev_id = dev_id; - ami_irq_list[irq]->devname = devname; - } - - /* enable the interrupt */ - if (irq < IRQ_AMIGA_PORTS && !ami_ablecount[irq]) - custom.intena = IF_SETCLR | ami_intena_vals[irq]; + vec = irq + VEC_USER; + if (ami_servers[irq]) + res = sys_request_listirq(vec, handler, flags, devname, dev_id); + else + res = sys_request_irq(vec, handler, flags, devname, dev_id); + + if (!res) { +#ifdef CONFIG_RT_INTERRUPT + if (flags & IRQ_FLG_REALTIME) + amiga_rtintmask |= 1 << irq; + else + amiga_slowintmask |= 1 << irq; + flush_icache_range((unsigned long)&amiga_slowintmask, + ((unsigned long)&amiga_rtintmask)+2); + printk("mask: %x,%x\n", amiga_rtintmask, amiga_slowintmask); +#endif + /* enable the interrupt */ + if (!ami_ablecount[irq]) + custom.intena = IF_SETCLR | ami_intena_vals[irq]; + } return 0; } void amiga_free_irq(unsigned int irq, void *dev_id) { + unsigned int vec; + if (irq >= AMI_IRQS) { printk ("%s: Unknown IRQ %d\n", __FUNCTION__, irq); return; } - if (irq >= IRQ_AMIGA_AUTO) - sys_free_irq(irq - IRQ_AMIGA_AUTO, dev_id); + if (irq >= IRQ_AMIGA_AUTO) { + vec = irq - IRQ_AMIGA_AUTO + VEC_SPUR; + sys_free_irq(vec, dev_id); + vectors[vec] = bad_interrupt; + + return; + } + if (irq >= IRQ_AMIGA_CIAB) { cia_free_irq(&ciab_base, irq - IRQ_AMIGA_CIAB, dev_id); return; @@ -245,21 +200,23 @@ return; } - if (ami_servers[irq]) { - amiga_delete_irq(&ami_irq_list[irq], dev_id); - /* if server list empty, disable the interrupt */ - if (!ami_irq_list[irq] && irq < IRQ_AMIGA_PORTS) - custom.intena = ami_intena_vals[irq]; - } else { - if (ami_irq_list[irq]->dev_id != dev_id) - printk("%s: removing probably wrong IRQ %d from %s\n", - __FUNCTION__, irq, ami_irq_list[irq]->devname); - ami_irq_list[irq]->handler = ami_badint; - ami_irq_list[irq]->flags = IRQ_FLG_STD; - ami_irq_list[irq]->dev_id = NULL; - ami_irq_list[irq]->devname = NULL; + vec = irq + VEC_USER; + sys_free_irq(vec, dev_id); + + /* if list empty, disable the interrupt */ +#ifndef CONFIG_RT_INTERRUPT + if (!userirq_list[irq]) custom.intena = ami_intena_vals[irq]; - } +#else + if (!userirq_list[irq]) + amiga_rtintmask &= ~(1 << irq); + if (!userirq_softlist[irq]) + amiga_slowintmask &= ~(1 << irq); + flush_icache_range((unsigned long)&amiga_slowintmask, + ((unsigned long)&amiga_rtintmask)+2); + if (!userirq_list[irq] && !userirq_softlist[irq]) + custom.intena = ami_intena_vals[irq]; +#endif } /* @@ -336,123 +293,80 @@ custom.intena = ami_intena_vals[irq]; } -inline void amiga_do_irq(int irq, struct pt_regs *fp) -{ - kstat.irqs[0][SYS_IRQS + irq]++; - ami_irq_list[irq]->handler(irq, ami_irq_list[irq]->dev_id, fp); -} - -void amiga_do_irq_list(int irq, struct pt_regs *fp, struct irq_server *server) -{ - irq_node_t *node, *slow_nodes; - unsigned short flags; - - kstat.irqs[0][SYS_IRQS + irq]++; - if (server->count++) - server->reentrance = 1; - /* serve first fast and normal handlers */ - for (node = ami_irq_list[irq]; - node && (!(node->flags & IRQ_FLG_SLOW)); - node = node->next) - node->handler(irq, node->dev_id, fp); - custom.intreq = ami_intena_vals[irq]; - if (!node) { - server->count--; - return; - } - save_flags(flags); - restore_flags((flags & ~0x0700) | (fp->sr & 0x0700)); - /* if slow handlers exists, serve them now */ - slow_nodes = node; - for (;;) { - for (; node; node = node->next) - node->handler(irq, node->dev_id, fp); - /* if reentrance occured, serve slow handlers again */ - custom.intena = ami_intena_vals[irq]; - if (!server->reentrance) { - server->count--; - custom.intena = IF_SETCLR | ami_intena_vals[irq]; - return; - } - server->reentrance = 0; - custom.intena = IF_SETCLR | ami_intena_vals[irq]; - node = slow_nodes; - } -} - /* * The builtin Amiga hardware interrupt handlers. */ static void ami_int1(int irq, void *dev_id, struct pt_regs *fp) { - unsigned short ints = custom.intreqr & custom.intenar; - /* if serial transmit buffer empty, interrupt */ - if (ints & IF_TBE) { + if (irq & IF_TBE) { custom.intreq = IF_TBE; amiga_do_irq(IRQ_AMIGA_TBE, fp); } /* if floppy disk transfer complete, interrupt */ - if (ints & IF_DSKBLK) { + if (irq & IF_DSKBLK) { custom.intreq = IF_DSKBLK; amiga_do_irq(IRQ_AMIGA_DSKBLK, fp); } /* if software interrupt set, interrupt */ - if (ints & IF_SOFT) { + if (irq & IF_SOFT) { custom.intreq = IF_SOFT; amiga_do_irq(IRQ_AMIGA_SOFT, fp); } } -static void ami_int3(int irq, void *dev_id, struct pt_regs *fp) +static void ami_int2(int irq, void *dev_id, struct pt_regs *fp) { - unsigned short ints = custom.intreqr & custom.intenar; - static struct irq_server server = {0, 0}; + custom.intreq = IF_PORTS; + amiga_do_irq_list(IRQ_AMIGA_PORTS, fp); +} +static void ami_int3(int irq, void *dev_id, struct pt_regs *fp) +{ /* if a blitter interrupt */ - if (ints & IF_BLIT) { + if (irq & IF_BLIT) { custom.intreq = IF_BLIT; amiga_do_irq(IRQ_AMIGA_BLIT, fp); } /* if a copper interrupt */ - if (ints & IF_COPER) { - custom.intreq = IF_COPER; + if (irq & IF_COPPER) { + custom.intreq = IF_COPPER; amiga_do_irq(IRQ_AMIGA_COPPER, fp); } /* if a vertical blank interrupt */ - if (ints & IF_VERTB) - amiga_do_irq_list(IRQ_AMIGA_VERTB, fp, &server); + if (irq & IF_VERTB) { + custom.intreq = IF_VERTB; + amiga_do_irq_list(IRQ_AMIGA_VERTB, fp); + } } static void ami_int4(int irq, void *dev_id, struct pt_regs *fp) { - unsigned short ints = custom.intreqr & custom.intenar; - /* if audio 0 interrupt */ - if (ints & IF_AUD0) { + if (irq & IF_AUD0) { custom.intreq = IF_AUD0; amiga_do_irq(IRQ_AMIGA_AUD0, fp); } /* if audio 1 interrupt */ - if (ints & IF_AUD1) { + if (irq & IF_AUD1) { custom.intreq = IF_AUD1; amiga_do_irq(IRQ_AMIGA_AUD1, fp); } /* if audio 2 interrupt */ - if (ints & IF_AUD2) { + if (irq & IF_AUD2) { custom.intreq = IF_AUD2; amiga_do_irq(IRQ_AMIGA_AUD2, fp); } /* if audio 3 interrupt */ - if (ints & IF_AUD3) { + if (irq & IF_AUD3) { custom.intreq = IF_AUD3; amiga_do_irq(IRQ_AMIGA_AUD3, fp); } @@ -460,64 +374,93 @@ static void ami_int5(int irq, void *dev_id, struct pt_regs *fp) { - unsigned short ints = custom.intreqr & custom.intenar; - /* if serial receive buffer full interrupt */ - if (ints & IF_RBF) { + if (irq & IF_RBF) { /* acknowledge of IF_RBF must be done by the serial interrupt */ amiga_do_irq(IRQ_AMIGA_RBF, fp); } /* if a disk sync interrupt */ - if (ints & IF_DSKSYN) { + if (irq & IF_DSKSYN) { custom.intreq = IF_DSKSYN; amiga_do_irq(IRQ_AMIGA_DSKSYN, fp); } } -static void ami_int7(int irq, void *dev_id, struct pt_regs *fp) +static void ami_int6(int irq, void *dev_id, struct pt_regs *fp) { - panic ("level 7 interrupt received\n"); + custom.intreq = IF_EXTER; + amiga_do_irq_list(IRQ_AMIGA_EXTER, fp); } - -void (*amiga_default_handler[SYS_IRQS])(int, void *, struct pt_regs *) = { - ami_badint, ami_int1, ami_badint, ami_int3, - ami_int4, ami_int5, ami_badint, ami_int7 -}; -int amiga_get_irq_list(char *buf) +void amiga_do_irqrequest(void) { - int i, len = 0; - irq_node_t *node; - - for (i = 0; i < AMI_STD_IRQS; i++) { - if (!(node = ami_irq_list[i])) - continue; - if (node->flags & IRQ_FLG_STD) - continue; - len += sprintf(buf+len, "ami %2d: %10u ", i, - kstat.irqs[0][SYS_IRQS + i]); - do { - if (ami_servers[i]) { - if (node->flags & IRQ_FLG_FAST) - len += sprintf(buf+len, "F "); - else if (node->flags & IRQ_FLG_SLOW) - len += sprintf(buf+len, "S "); - else - len += sprintf(buf+len, " "); - } else { - if (node->flags & IRQ_FLG_LOCK) - len += sprintf(buf+len, "L "); - else - len += sprintf(buf+len, " "); - } - len += sprintf(buf+len, "%s\n", node->devname); - if ((node = node->next)) - len += sprintf(buf+len, " "); - } while (node); + unsigned int old_request, old_mask; +#ifdef CONFIG_APUS + unsigned int oldcount; +#else + unsigned char res; +#endif + int irq; + static struct pt_regs dummy_regs; + + if (local_irq_count[0]) { + printk("non rt safe int? (%p)\n", __builtin_return_address(0)); + soft_irq_count = ~0; + return; + } + if (local_bh_count[0]) { + soft_irq_count++; + return; } - len += cia_get_irq_list(&ciaa_base, buf+len); - len += cia_get_irq_list(&ciab_base, buf+len); - return len; + do { + soft_irq_count = 0; + hardirq_enter(0); + old_request = xchg(&rt_irqrequest, 0); + + old_mask = old_request; + custom.intreq = old_mask & (0x3fff & ~IF_RBF); + while ( old_request ) { +#ifdef CONFIG_APUS +#else + asm ("bfffo %1{#0,#32},%0; bfclr %1{%0,#1}" + : "=&d" (irq), "=d" (old_request) + : "1" (old_request): "cc"); + irq = 31 - irq; +#endif +#if 0 + { + char ch = 'a'+irq; + amiga_serial_console_write(NULL, &ch, 1); + } +#endif + if (ami_servers[irq]) + amiga_do_softirq_list(irq, &dummy_regs); + else + amiga_do_softirq(irq, &dummy_regs); + } + custom.intena = IF_SETCLR | (old_mask & 0x3fff); + if ((old_mask >>= AMI_STD_IRQS)) { + cia_able_irq(&ciaa_base, CIA_ICR_SETCLR | + (old_mask & CIA_ICR_ALL)); + if ((old_mask >>= CIA_IRQS)) + cia_able_irq(&ciab_base, CIA_ICR_SETCLR | old_mask); + } + hardirq_exit(0); + if (bh_active & bh_mask) + do_bottom_half(); + +#ifdef CONFIG_APUS + asm ("1: lwarx %0,0,%2; addi %0,%0,-1; " + " stwcx. %0,0,%2; bne 1b" + : "=&b" (oldcount), "=m" (soft_irq_count) + : "r" (&soft_irq_count): "cr0"); + } while (oldcount != ~0); +#else + asm ("subql #1,%1; scc %0" + : "=d" (res), "=m" (soft_irq_count) + : "1" (soft_irq_count): "cc"); + } while (res); +#endif } Index: linux-2.1/arch/m68k/amiga/cia.c diff -u linux-2.1/arch/m68k/amiga/cia.c:1.1.1.1.6.2 linux-2.1/arch/m68k/amiga/cia.c:1.1.1.1.6.2.2.2 --- linux-2.1/arch/m68k/amiga/cia.c:1.1.1.1.6.2 Sat Dec 19 18:51:13 1998 +++ linux-2.1/arch/m68k/amiga/cia.c Sun Dec 20 01:29:12 1998 @@ -20,25 +20,26 @@ #include #include #include +#include +#include +#ifdef CONFIG_ADVANCED +#include +#endif + struct ciabase { volatile struct CIA *cia; - u_char icr_mask, icr_data; + int cia_irq; u_short int_mask; - int handler_irq, cia_irq, server_irq; - char *name; - struct irq_server server; - irq_handler_t irq_list[CIA_IRQS]; + u_char allocmask, pad; + u_char icr_mask, icr_data; + u_char rtmask, slowmask; } ciaa_base = { - &ciaa, 0, 0, IF_PORTS, - IRQ_AMIGA_AUTO_2, IRQ_AMIGA_CIAA, - IRQ_AMIGA_PORTS, - "CIAA handler", {0, 0} + &ciaa, IRQ_AMIGA_CIAA, + IF_PORTS, CIA_ICR_ALL, 0, 0, 0, 0, 0 }, ciab_base = { - &ciab, 0, 0, IF_EXTER, - IRQ_AMIGA_AUTO_6, IRQ_AMIGA_CIAB, - IRQ_AMIGA_EXTER, - "CIAB handler", {0, 0} + &ciab, IRQ_AMIGA_CIAB, + IF_EXTER, CIA_ICR_ALL, 0, 0, 0, 0, 0 }; /* @@ -66,23 +67,17 @@ unsigned char cia_able_irq(struct ciabase *base, unsigned char mask) { - u_char old, tmp; - int i; + u_char old; old = base->icr_mask; base->icr_data |= base->cia->icr; + mask &= CIA_ICR_SETCLR | base->allocmask; base->cia->icr = mask; if (mask & CIA_ICR_SETCLR) base->icr_mask |= mask; else base->icr_mask &= ~mask; base->icr_mask &= CIA_ICR_ALL; - for (i = 0, tmp = 1; i < CIA_IRQS; i++, tmp <<= 1) { - if ((tmp & base->icr_mask) && !base->irq_list[i].handler) { - base->icr_mask &= ~tmp; - base->cia->icr = tmp; - } - } if (base->icr_data & base->icr_mask) custom.intreq = IF_SETCLR | base->int_mask; return old; @@ -92,102 +87,100 @@ void (*handler)(int, void *, struct pt_regs *), unsigned long flags, const char *devname, void *dev_id) { + unsigned int vec; + int res; u_char mask; - if (!(base->irq_list[irq].flags & IRQ_FLG_STD)) { - if (base->irq_list[irq].flags & IRQ_FLG_LOCK) { - printk("%s: IRQ %i from %s is not replaceable\n", - __FUNCTION__, base->cia_irq + irq, - base->irq_list[irq].devname); - return -EBUSY; - } - if (!(flags & IRQ_FLG_REPLACE)) { - printk("%s: %s can't replace IRQ %i from %s\n", __FUNCTION__, - devname, base->cia_irq + irq, - base->irq_list[irq].devname); - return -EBUSY; - } - } - base->irq_list[irq].handler = handler; - base->irq_list[irq].flags = flags; - base->irq_list[irq].dev_id = dev_id; - base->irq_list[irq].devname = devname; + vec = VEC_USER + base->cia_irq + irq; + res = sys_request_irq(vec, handler, flags, devname, dev_id); - /* enable the interrupt */ - mask = 1 << irq; - cia_set_irq(base, mask); - cia_able_irq(base, CIA_ICR_SETCLR | mask); + if (!res) { + mask = 1 << irq; +#ifdef CONFIG_RT_INTERRUPT + if (!(flags & IRQ_FLG_REALTIME)) + base->slowmask |= mask; + else + base->rtmask |=mask; +#endif + /* enable the interrupt */ + base->allocmask |= mask; + cia_set_irq(base, mask); + cia_able_irq(base, CIA_ICR_SETCLR | mask); + } return 0; } void cia_free_irq(struct ciabase *base, unsigned int irq, void *dev_id) { - if (base->irq_list[irq].dev_id != dev_id) - printk("%s: removing probably wrong IRQ %i from %s\n", - __FUNCTION__, base->cia_irq + irq, - base->irq_list[irq].devname); + unsigned int vec; + u_char mask; - base->irq_list[irq].handler = NULL; - base->irq_list[irq].flags = IRQ_FLG_STD; + vec = VEC_USER + base->cia_irq + irq; + sys_free_irq(vec, dev_id); - cia_able_irq(base, 1 << irq); + mask = 1 << irq; +#ifndef CONFIG_RT_INTERRUPT + if (!userirq_list[base->cia_irq + irq]) { + cia_able_irq(base, mask); + base->allocmask &= ~mask; + } +#else + if (!userirq_list[base->cia_irq + irq]) + base->rtmask &= ~mask; + if (!userirq_softlist[base->cia_irq + irq]) + base->slowmask &= ~mask; + if (!userirq_list[base->cia_irq + irq] && + !userirq_softlist[base->cia_irq + irq]) { + cia_able_irq(base, mask); + base->allocmask &= ~mask; + } +#endif } static void cia_handler(int irq, void *dev_id, struct pt_regs *fp) { struct ciabase *base = (struct ciabase *)dev_id; - int mach_irq, i; unsigned char ints; +#ifdef CONFIG_RT_INTERRUPT + unsigned char softints; +#endif - mach_irq = base->cia_irq; - irq = SYS_IRQS + mach_irq; ints = cia_set_irq(base, CIA_ICR_ALL); +#ifdef CONFIG_RT_INTERRUPT + if ((softints = ints & base->slowmask)) { + rt_irqrequest |= softints << base->cia_irq; + cia_able_irq(base, softints); + } + ints &= base->rtmask; +#endif custom.intreq = base->int_mask; - for (i = 0; i < CIA_IRQS; i++, irq++, mach_irq++) { - if (ints & 1) { - kstat.irqs[0][irq]++; - base->irq_list[i].handler(mach_irq, base->irq_list[i].dev_id, fp); + if ( ints ) { + unsigned int irq = base->cia_irq + CIA_IRQS - 1; + irq_node_t **list = &userirq_list[irq]; + unsigned int *stat = &kstat.irqs[0][irq + AUTO_IRQ_NR]; + for (ints <<= 3; ints; ints <<= 1) { + if ( ints & 0x80 ) { + (*stat)++; + (*list)->handler(irq, (*list)->dev_id, fp); + } + stat--; list--; irq--; } - ints >>= 1; } - amiga_do_irq_list(base->server_irq, fp, &base->server); } -__initfunc(void cia_init_IRQ(struct ciabase *base)) +void __init cia_init_IRQ(void) { - int i; - - /* init isr handlers */ - for (i = 0; i < CIA_IRQS; i++) { - base->irq_list[i].handler = NULL; - base->irq_list[i].flags = IRQ_FLG_STD; - } - /* clear any pending interrupt and turn off all interrupts */ - cia_set_irq(base, CIA_ICR_ALL); - cia_able_irq(base, CIA_ICR_ALL); + cia_set_irq(&ciaa_base, CIA_ICR_ALL); + cia_able_irq(&ciaa_base, CIA_ICR_ALL); + cia_set_irq(&ciab_base, CIA_ICR_ALL); + cia_able_irq(&ciab_base, CIA_ICR_ALL); + ciaa_base.allocmask = ciab_base.allocmask = 0; /* install CIA handler */ - request_irq(base->handler_irq, cia_handler, IRQ_FLG_LOCK, base->name, base); + request_irq(IRQ_AMIGA_PORTS, cia_handler, IRQ_FLG_REALTIME | IRQ_FLG_FAST, + "ciaa handler", &ciaa_base); + request_irq(IRQ_AMIGA_EXTER, cia_handler, IRQ_FLG_REALTIME | IRQ_FLG_FAST, + "ciab handler", &ciab_base); - custom.intena = IF_SETCLR | base->int_mask; -} - -int cia_get_irq_list(struct ciabase *base, char *buf) -{ - int i, j, len = 0; - - j = base->cia_irq; - for (i = 0; i < CIA_IRQS; i++) { - if (!(base->irq_list[i].flags & IRQ_FLG_STD)) { - len += sprintf(buf+len, "cia %2d: %10d ", j + i, - kstat.irqs[0][SYS_IRQS + j + i]); - if (base->irq_list[i].flags & IRQ_FLG_LOCK) - len += sprintf(buf+len, "L "); - else - len += sprintf(buf+len, " "); - len += sprintf(buf+len, "%s\n", base->irq_list[i].devname); - } - } - return len; } Index: linux-2.1/arch/m68k/amiga/config.c diff -u linux-2.1/arch/m68k/amiga/config.c:1.1.1.4.6.2 linux-2.1/arch/m68k/amiga/config.c:1.1.1.4.6.2.2.1 --- linux-2.1/arch/m68k/amiga/config.c:1.1.1.4.6.2 Sat Dec 19 18:51:14 1998 +++ linux-2.1/arch/m68k/amiga/config.c Sat Dec 19 21:28:09 1998 @@ -48,46 +48,15 @@ extern char m68k_debug_device[]; -static void amiga_sched_init(void (*handler)(int, void *, struct pt_regs *)); -/* amiga specific keyboard functions */ -extern int amiga_keyb_init(void); -extern int amiga_kbdrate (struct kbd_repeat *); -extern void amiga_kbd_reset_setup(char*, int); -/* amiga specific irq functions */ -extern void amiga_init_IRQ (void); -extern void (*amiga_default_handler[]) (int, void *, struct pt_regs *); -extern int amiga_request_irq (unsigned int irq, - void (*handler)(int, void *, struct pt_regs *), - unsigned long flags, const char *devname, - void *dev_id); -extern void amiga_free_irq (unsigned int irq, void *dev_id); -extern void amiga_enable_irq (unsigned int); -extern void amiga_disable_irq (unsigned int); -static void amiga_get_model(char *model); -static int amiga_get_hardware_list(char *buffer); -extern int amiga_get_irq_list (char *); -/* amiga specific timer functions */ -static unsigned long amiga_gettimeoffset (void); -static void a3000_gettod (int *, int *, int *, int *, int *, int *); -static void a2000_gettod (int *, int *, int *, int *, int *, int *); -static int amiga_hwclk (int, struct hwclk_time *); -static int amiga_set_clock_mmss (unsigned long); -extern void amiga_mksound( unsigned int count, unsigned int ticks ); -#ifdef CONFIG_AMIGA_FLOPPY -extern void amiga_floppy_setup(char *, int *); -#endif -static void amiga_reset (void); +int amiga_cia_timer __initdata = 1; + static int amiga_wait_key (struct console *co); -extern void amiga_init_sound(void); static void amiga_savekmsg_init(void); -static void amiga_mem_console_write(struct console *co, const char *b, +static void amiga_mem_console_write(struct console *co, const char *s, unsigned int count); void amiga_serial_console_write(struct console *co, const char *s, unsigned int count); static void amiga_debug_init(void); -#ifdef CONFIG_HEARTBEAT -static void amiga_heartbeat(int on); -#endif static struct console amiga_console_driver = { "debug", @@ -174,7 +143,7 @@ * Identify builtin hardware */ -__initfunc(static void amiga_identify(void)) +static void __init amiga_identify(void) { /* Fill in some default values, if necessary */ if (amiga_eclock == 0) @@ -335,24 +304,23 @@ * Setup the Amiga configuration info */ -__initfunc(void config_amiga(void)) +void __init config_amiga(void) { amiga_debug_init(); amiga_identify(); +#ifndef NO_MACH_DEFS mach_sched_init = amiga_sched_init; mach_keyb_init = amiga_keyb_init; mach_kbdrate = amiga_kbdrate; - kbd_reset_setup = amiga_kbd_reset_setup; mach_init_IRQ = amiga_init_IRQ; - mach_default_handler = &amiga_default_handler; mach_request_irq = amiga_request_irq; mach_free_irq = amiga_free_irq; enable_irq = amiga_enable_irq; disable_irq = amiga_disable_irq; +#endif mach_get_model = amiga_get_model; mach_get_hardware_list = amiga_get_hardware_list; - mach_get_irq_list = amiga_get_irq_list; mach_gettimeoffset = amiga_gettimeoffset; if (AMIGAHW_PRESENT(A3000_CLK)){ mach_gettod = a3000_gettod; @@ -448,42 +416,63 @@ static unsigned short jiffy_ticks; -__initfunc(static void amiga_sched_init(void (*timer_routine)(int, void *, - struct pt_regs *))) +void __init amiga_sched_init(void (*timer_routine)(int, void *, + struct pt_regs *)) { jiffy_ticks = (amiga_eclock+HZ/2)/HZ; + + /* turn off timer A, continuous mode, from Eclk */ + if (amiga_cia_timer) { + ciab.cra &= 0xC0; + ciab.talo = jiffy_ticks % 256; + ciab.tahi = jiffy_ticks / 256; + } else { + ciaa.cra &= 0xC0; + ciaa.talo = jiffy_ticks % 256; + ciaa.tahi = jiffy_ticks / 256; + } - ciab.cra &= 0xC0; /* turn off timer A, continuous mode, from Eclk */ - ciab.talo = jiffy_ticks % 256; - ciab.tahi = jiffy_ticks / 256; - - /* install interrupt service routine for CIAB Timer A - * - * Please don't change this to use ciaa, as it interferes with the - * SCSI code. We'll have to take a look at this later + /* install timer interrupt service routine + * default is to use CIAB to avoid problems with scsi drivers, + * but it can be changed to CIAA to give the serial interrupt + * more time. */ - request_irq(IRQ_AMIGA_CIAB_TA, timer_routine, IRQ_FLG_LOCK, - "timer", NULL); + request_irq(amiga_cia_timer ? IRQ_AMIGA_CIAB_TA : IRQ_AMIGA_CIAA_TA, + timer_routine, IRQ_FLG_LOCK, "timer", NULL); /* start timer */ - ciab.cra |= 0x11; + if (amiga_cia_timer) + ciab.cra |= 0x11; + else + ciaa.cra |= 0x11; } #define TICK_SIZE 10000 /* This is always executed with interrupts disabled. */ -static unsigned long amiga_gettimeoffset (void) +unsigned long amiga_gettimeoffset (void) { unsigned short hi, lo, hi2; unsigned long ticks, offset = 0; - /* read CIA B timer A current value */ - hi = ciab.tahi; - lo = ciab.talo; - hi2 = ciab.tahi; - - if (hi != hi2) { - lo = ciab.talo; - hi = hi2; + /* read CIA timer A current value */ + if (amiga_cia_timer) { + hi = ciab.tahi; + lo = ciab.talo; + hi2 = ciab.tahi; + + if (hi != hi2) { + lo = ciab.talo; + hi = hi2; + } + } else { + hi = ciaa.tahi; + lo = ciaa.talo; + hi2 = ciaa.tahi; + + if (hi != hi2) { + lo = ciaa.talo; + hi = hi2; + } } ticks = hi << 8 | lo; @@ -499,8 +488,8 @@ return ticks + offset; } -static void a3000_gettod (int *yearp, int *monp, int *dayp, - int *hourp, int *minp, int *secp) +void a3000_gettod (int *yearp, int *monp, int *dayp, + int *hourp, int *minp, int *secp) { volatile struct tod3000 *tod = TOD_3000; @@ -516,8 +505,8 @@ tod->cntrl1 = TOD3000_CNTRL1_FREE; } -static void a2000_gettod (int *yearp, int *monp, int *dayp, - int *hourp, int *minp, int *secp) +void a2000_gettod (int *yearp, int *monp, int *dayp, + int *hourp, int *minp, int *secp) { volatile struct tod2000 *tod = TOD_2000; @@ -543,7 +532,7 @@ tod->cntrl1 &= ~TOD2000_CNTRL1_HOLD; } -static int amiga_hwclk(int op, struct hwclk_time *t) +int amiga_hwclk(int op, struct hwclk_time *t) { if (AMIGAHW_PRESENT(A3000_CLK)) { volatile struct tod3000 *tod = TOD_3000; @@ -628,7 +617,7 @@ return 0; } -static int amiga_set_clock_mmss (unsigned long nowtime) +int amiga_set_clock_mmss (unsigned long nowtime) { short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60; @@ -703,10 +692,9 @@ console_print (buf); } -static NORET_TYPE void amiga_reset( void ) - ATTRIB_NORET; +NORET_TYPE void amiga_reset( void ) ATTRIB_NORET; -static void amiga_reset (void) +void amiga_reset (void) { unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040); unsigned long jmp_addr = virt_to_phys(&&jmp_addr_label); @@ -816,13 +804,18 @@ } void amiga_serial_console_write(struct console *co, const char *s, - unsigned int count) + unsigned int count) { + unsigned long flags; + + __save_flags(flags); + __cli(); while (count--) { if (*s == '\n') amiga_serial_putc('\r'); amiga_serial_putc(*s++); } + __restore_flags(flags); } #ifdef CONFIG_SERIAL_CONSOLE @@ -882,7 +875,7 @@ } #endif -__initfunc(static void amiga_debug_init(void)) +static void __init amiga_debug_init(void) { if (!strcmp( m68k_debug_device, "ser" )) { /* no initialization required (?) */ @@ -892,7 +885,7 @@ } #ifdef CONFIG_HEARTBEAT -static void amiga_heartbeat(int on) +void amiga_heartbeat(int on) { if (on) ciaa.pra &= ~2; @@ -905,7 +898,7 @@ * Amiga specific parts of /proc */ -static void amiga_get_model(char *model) +void amiga_get_model(char *model) { strcpy(model, "Amiga "); if (amiga_model >= AMI_500 && amiga_model <= AMI_DRACO) @@ -913,7 +906,7 @@ } -static int amiga_get_hardware_list(char *buffer) +int amiga_get_hardware_list(char *buffer) { int len = 0; Index: linux-2.1/arch/m68k/atari/atakeyb.c diff -u linux-2.1/arch/m68k/atari/atakeyb.c:1.1.1.2.6.3 linux-2.1/arch/m68k/atari/atakeyb.c:1.1.1.2.6.3.2.1 --- linux-2.1/arch/m68k/atari/atakeyb.c:1.1.1.2.6.3 Sat Dec 19 18:51:15 1998 +++ linux-2.1/arch/m68k/atari/atakeyb.c Sat Dec 19 21:28:10 1998 @@ -861,8 +861,3 @@ return( 0 ); } - -/* for "kbd-reset" cmdline param */ -__initfunc(void atari_kbd_reset_setup(char *str, int *ints)) -{ -} Index: linux-2.1/arch/m68k/atari/config.c diff -u linux-2.1/arch/m68k/atari/config.c:1.1.1.3.6.2 linux-2.1/arch/m68k/atari/config.c:1.1.1.3.6.2.2.1 --- linux-2.1/arch/m68k/atari/config.c:1.1.1.3.6.2 Sat Dec 19 18:51:17 1998 +++ linux-2.1/arch/m68k/atari/config.c Sat Dec 19 21:28:13 1998 @@ -60,7 +60,6 @@ extern int atari_keyb_init(void); extern int atari_kbdrate (struct kbd_repeat *); extern void atari_kbd_leds (unsigned int); -extern void atari_kbd_reset_setup(char*, int); /* atari specific irq functions */ extern void atari_init_IRQ (void); extern int atari_request_irq (unsigned int irq, void (*handler)(int, void *, struct pt_regs *), @@ -251,7 +250,6 @@ mach_keyb_init = atari_keyb_init; mach_kbdrate = atari_kbdrate; mach_kbd_leds = atari_kbd_leds; - kbd_reset_setup = atari_kbd_reset_setup; mach_init_IRQ = atari_init_IRQ; mach_request_irq = atari_request_irq; mach_free_irq = atari_free_irq; Index: linux-2.1/arch/m68k/hp300/config.c diff -u linux-2.1/arch/m68k/hp300/config.c:1.1.1.2.6.2 linux-2.1/arch/m68k/hp300/config.c:1.1.1.2.6.2.2.1 --- linux-2.1/arch/m68k/hp300/config.c:1.1.1.2.6.2 Sat Dec 19 18:51:18 1998 +++ linux-2.1/arch/m68k/hp300/config.c Sat Dec 19 21:28:14 1998 @@ -55,11 +55,6 @@ { } -/* for "kbd-reset" cmdline param */ -__initfunc(void hp300_kbd_reset_setup(char *str, int i)) -{ -} - static void hp300_get_model(char *model) { strcpy(model, "HP9000/300"); @@ -74,7 +69,6 @@ mach_init_IRQ = hp300_init_IRQ; mach_request_irq = hp300_request_irq; mach_free_irq = hp300_free_irq; - kbd_reset_setup = hp300_kbd_reset_setup; mach_get_model = hp300_get_model; mach_get_irq_list = hp300_get_irq_list; mach_gettimeoffset = hp300_gettimeoffset; Index: linux-2.1/arch/m68k/ifpsp060/iskeleton.S diff -u linux-2.1/arch/m68k/ifpsp060/iskeleton.S:1.1.1.2.6.2 linux-2.1/arch/m68k/ifpsp060/iskeleton.S:1.1.1.2.6.2.2.1 --- linux-2.1/arch/m68k/ifpsp060/iskeleton.S:1.1.1.2.6.2 Sat Dec 19 18:51:19 1998 +++ linux-2.1/arch/m68k/ifpsp060/iskeleton.S Sat Dec 19 21:28:15 1998 @@ -36,6 +36,7 @@ #include #include +#include "../kernel/m68k_defs.h" |################################ @@ -69,12 +70,12 @@ .global _060_isp_done _060_isp_done: btst #0x5,%sp@ | supervisor bit set in saved SR? - beq Lnotkern + beq .Lnotkern rte -Lnotkern: +.Lnotkern: SAVE_ALL_INT GET_CURRENT(%d0) - tstl %curptr@(LTASK_NEEDRESCHED) + tstl %curptr@(TASK_NEEDRESCHED) jne SYMBOL_NAME(ret_from_exception) | deliver signals, | reschedule etc.. RESTORE_ALL Index: linux-2.1/arch/m68k/kernel/entry.S diff -u linux-2.1/arch/m68k/kernel/entry.S:1.1.1.5.6.2 linux-2.1/arch/m68k/kernel/entry.S:1.1.1.5.6.2.2.1 --- linux-2.1/arch/m68k/kernel/entry.S:1.1.1.5.6.2 Sat Dec 19 18:51:20 1998 +++ linux-2.1/arch/m68k/kernel/entry.S Sat Dec 19 21:28:16 1998 @@ -31,12 +31,28 @@ */ #include -#include #include #include +#include +#include #include #include +#include +#include +#include +#include +#ifdef CONFIG_ADVANCED +#include +#endif +#include +#ifdef CONFIG_EXPERIMENTAL +#include +#ifdef CONFIG_MATH_EMU +#include +#endif +#endif + #include "m68k_defs.h" .globl SYMBOL_NAME(system_call), SYMBOL_NAME(buserr), SYMBOL_NAME(trap) @@ -44,7 +60,6 @@ .globl SYMBOL_NAME(ret_from_signal) .globl SYMBOL_NAME(inthandler), SYMBOL_NAME(sys_call_table) .globl SYMBOL_NAME(sys_fork), SYMBOL_NAME(sys_clone) -.globl SYMBOL_NAME(ret_from_interrupt), SYMBOL_NAME(bad_interrupt) .text ENTRY(buserr) @@ -65,24 +80,24 @@ ENTRY(reschedule) | save top of frame - movel %sp,%curptr@(TS_ESP0) + movel %sp,%curptr@(TASK_TSS+TSS_ESP0) pea SYMBOL_NAME(ret_from_exception) jmp SYMBOL_NAME(schedule) badsys: - movel #-LENOSYS,LPT_OFF_D0(%sp) + movel #-ENOSYS,PT_D0(%sp) jra SYMBOL_NAME(ret_from_exception) do_trace: - movel #-LENOSYS,LPT_OFF_D0(%sp) | needed for strace + movel #-ENOSYS,PT_D0(%sp) | needed for strace subql #4,%sp SAVE_SWITCH_STACK jbsr SYMBOL_NAME(syscall_trace) RESTORE_SWITCH_STACK addql #4,%sp jbsr @(SYMBOL_NAME(sys_call_table),%d2:l:4)@(0) - movel %d0,%sp@(LPT_OFF_D0) | save the return value + movel %d0,%sp@(PT_D0) | save the return value subql #4,%sp | dummy return address SAVE_SWITCH_STACK jbsr SYMBOL_NAME(syscall_trace) @@ -98,34 +113,30 @@ GET_CURRENT(%d0) | save top of frame - movel %sp,%curptr@(TS_ESP0) + movel %sp,%curptr@(TASK_TSS+TSS_ESP0) cmpl #NR_syscalls,%d2 jcc badsys - btst #LPF_TRACESYS_BIT,%curptr@(LTASK_FLAGS+LPF_TRACESYS_OFF) + btst #PF_TRACESYS_BIT,%curptr@(TASK_FLAGS+PF_TRACESYS_OFF) jne do_trace jbsr @(SYMBOL_NAME(sys_call_table),%d2:l:4)@(0) - movel %d0,%sp@(LPT_OFF_D0) | save the return value + movel %d0,%sp@(PT_D0) | save the return value SYMBOL_NAME_LABEL(ret_from_exception) - btst #5,%sp@(LPT_OFF_SR) | check if returning to kernel + btst #5,%sp@(PT_SR) | check if returning to kernel bnes 2f | if so, skip resched, signals - | only allow interrupts when we are really the last one on the - | kernel stack, otherwise stack overflow can occur during - | heavy interupt load - andw #ALLOWINT,%sr - tstl %curptr@(LTASK_NEEDRESCHED) + tstl %curptr@(TASK_NEEDRESCHED) jne SYMBOL_NAME(reschedule) cmpl #SYMBOL_NAME(task),%curptr | task[0] cannot have signals jeq 2f | check for delayed trace - bclr #LPF_DTRACE_BIT,%curptr@(LTASK_FLAGS+LPF_DTRACE_OFF) + bclr #PF_DTRACE_BIT,%curptr@(TASK_FLAGS+PF_DTRACE_OFF) jne do_delayed_trace 5: - tstl %curptr@(LTASK_STATE) | state + tstl %curptr@(TASK_STATE) | state jne SYMBOL_NAME(reschedule) - tstl %curptr@(LTASK_SIGPENDING) + tstl %curptr@(TASK_SIGPENDING) jne Lsignal_return 2: RESTORE_ALL @@ -141,7 +152,7 @@ RESTORE_ALL do_delayed_trace: - bclr #7,%sp@(LPT_OFF_SR) | clear trace bit in SR + bclr #7,%sp@(PT_SR) | clear trace bit in SR pea 1 | send SIGTRAP movel %curptr,%sp@- pea LSIGTRAP @@ -151,46 +162,165 @@ jra 5b /* -** This is the main interrupt handler, responsible for calling process_int() +** This is the general autovector interrupt handler */ -SYMBOL_NAME_LABEL(inthandler) - SAVE_ALL_INT - GET_CURRENT(%d0) +.macro inthandler intnodes, firstvec, dolist addql #1,SYMBOL_NAME(local_irq_count) - | put exception # in d0 - bfextu %sp@(LPT_OFF_FORMATVEC){#4,#10},%d0 + save_all_int + get_current - movel %sp,%sp@- - movel %d0,%sp@- | put vector # on stack - jbsr SYMBOL_NAME(process_int)| process the IRQ - addql #8,%sp | pop parameters off stack +| extract exception vector, do some statistic and get int node + bfextu %sp@(PT_VECTOR){#4,#12},%d0 + movel %d0,%a0 + addql #1,%a0@(SYMBOL_NAME(kstat)+STAT_IRQ-VECOFF(\firstvec)) + movel %a0@(SYMBOL_NAME(\intnodes)-VECOFF(\firstvec)),%a0 -SYMBOL_NAME_LABEL(ret_from_interrupt) - subql #1,SYMBOL_NAME(local_irq_count) - jeq 1f -2: - RESTORE_ALL -1: -#if 1 - bfextu %sp@(LPT_OFF_SR){#5,#3},%d0 | Check for nested interrupt. -#if MAX_NOINT_IPL > 0 - cmpiw #MAX_NOINT_IPL,%d0 -#endif - jhi 2b +.if \dolist + jra 2f +ALIGN +1: movel %a0@(IRQ_NEXT),%d0 + jeq SYMBOL_NAME(ret_from_interrupt) + movel %d0,%a0 + addql #8,%sp + addql #4,%sp +.endif +| prepare stack (push frame pointer, dev_id & vector #) +2: pea %sp@ + movel %a0@(IRQ_DEVID),%sp@- + lsrl #2,%d0 + movel %d0,%sp@- +.if \dolist + pea %pc@(1b:w) +.else + pea %pc@(SYMBOL_NAME(ret_from_interrupt):w) +.endif + jbra @(IRQ_HANDLER,%a0)@(0) +.endm + +#ifdef NEED_AUTO_IRQ_STD_HANDLER +ENTRY(autoirq_handler) + inthandler autoirq_list, VEC_SPUR, 0 +#endif +#ifdef NEED_AUTO_IRQ_STD_LISTHANDLER +ENTRY(autoirq_listhandler) + inthandler autoirq_list, VEC_SPUR, 1 +#endif +#ifdef NEED_USER_IRQ_STD_HANDLER +ENTRY(userirq_handler) + inthandler userirq_list, VEC_USER, 0 +#endif +#ifdef NEED_USER_IRQ_STD_USERHANDLER +ENTRY(userirq_listhandler) + inthandler userirq_list, VEC_USER, 1 #endif - /* check if we need to do software interrupts */ - movel SYMBOL_NAME(bh_active),%d0 +ENTRY(ret_from_interrupt) +| clean up stack + addql #8,%sp + addql #4,%sp + subql #1,SYMBOL_NAME(local_irq_count) +| check for pending interrupts + movew %sp@(PT_SR),%d0 + andw #0x0700,%d0 + jeq SYMBOL_NAME(do_softirq) +1: RESTORE_ALL + +| check for running software int +ENTRY(do_softirq) + addql #1,SYMBOL_NAME(soft_irq_count) + jcc 1b +| we are last int on stack so we can reduce int mask + andw #0xf8ff,%sr + +1: movel SYMBOL_NAME(bh_active),%d0 andl SYMBOL_NAME(bh_mask),%d0 - jeq SYMBOL_NAME(ret_from_exception) + jeq 2f + jbsr SYMBOL_NAME(do_bottom_half) + +| check if there was an interrupt, so we have to redo the soft ints +2: subql #1,SYMBOL_NAME(soft_irq_count) + jcs SYMBOL_NAME(ret_from_exception) + clrl SYMBOL_NAME(soft_irq_count) + jbra 1b +#ifdef CONFIG_AMIGA +/* +** Special Amiga interrupt handler +*/ +.globl SYMBOL_NAME(amiga_inthandler) +.globl SYMBOL_NAME(amiga_irqstat),SYMBOL_NAME(amiga_intnodes) + +ENTRY(amiga_inthandler) + addql #1,SYMBOL_NAME(local_irq_count) + save_all_int + get_current + +| extract exception vector, do some statistic and get int node + bfextu %sp@(PT_VECTOR){#4,#12},%d1 + movel %d1,%a0 + addql #1,%a0@(SYMBOL_NAME(kstat)+STAT_IRQ-VECOFF(VEC_SPUR)) + movel %a0@(SYMBOL_NAME(autoirq_list)-VECOFF(VEC_SPUR)),%a0 + +| amiga vector int handler get the req mask instead of irq vector + lea CUSTOMBASE,%a1 + movew %a1@(C_INTREQR),%d0 + andw %a1@(C_INTENAR),%d0 + +#ifdef CONFIG_RT_INTERRUPT +.globl SYMBOL_NAME(amiga_slowintmask),SYMBOL_NAME(amiga_rtintmask) + +| disable slow ints and modify req mask + movew %d0,%d1 +.equ SYMBOL_NAME(amiga_slowintmask),.+2 + andw #0:w,%d1 + jeq 1f + orw %d1,SYMBOL_NAME(rt_irqrequest+2) +| movew %d1,%a1@(C_INTREQ) + movew %d1,%a1@(C_INTENA) +.equ SYMBOL_NAME(amiga_rtintmask),.+2 +1: andw #0:w,%d0 + jeq SYMBOL_NAME(amiga_fastret_from_irq) +#endif /* CONFIG_RT_INTERRUPT */ + +| prepare stack (push frame pointer, dev_id & req mask) + pea %sp@ + movel %a0@(IRQ_DEVID),%sp@- + movel %d0,%sp@- + pea %pc@(SYMBOL_NAME(amiga_ret_from_irq):w) + jbra @(IRQ_HANDLER,%a0)@(0) + +#ifdef CONFIG_RT_INTERRUPT +ENTRY(amiga_ret_from_irq) + addql #8,%sp + addql #4,%sp + +SYMBOL_NAME_LABEL(amiga_fastret_from_irq) + subql #1,SYMBOL_NAME(local_irq_count) +| check for pending interrupts + movew %sp@(PT_SR),%d0 + andw #0x0700,%d0 + jeq SYMBOL_NAME(amiga_do_softirq) +1: restore_all + +ENTRY(amiga_do_softirq) +| check for running soft int + addql #1,SYMBOL_NAME(soft_irq_count) + jcc 1b +| we are last int on stack so we can reduce int mask + andw #0xf8ff,%sr pea SYMBOL_NAME(ret_from_exception) - jra SYMBOL_NAME(do_bottom_half) + jbra SYMBOL_NAME(amiga_do_irqrequest) +#else +.equ SYMBOL_NAME(amiga_ret_from_irq),SYMBOL_NAME(ret_from_interrupt) +#endif /* CONFIG_RT_INTERRUPT */ +ENTRY(nmi_handler) + rte +#endif /* CONFIG_AMIGA */ /* Handler for uninitialized and spurious interrupts */ -SYMBOL_NAME_LABEL(bad_interrupt) +ENTRY(bad_interrupt) addql #1,SYMBOL_NAME(num_spurious) rte @@ -240,37 +370,36 @@ SYMBOL_NAME_LABEL(resume) /* - * Beware - when entering resume, offset of tss is in d1, - * prev (the current task) is in a0, next (the new task) - * is in a1 and d2.b is non-zero if the mm structure is - * shared between the tasks, so don't change these + * Beware - when entering resume, prev (the current task) is + * in a0, next (the new task) is in a1,so don't change these * registers until their contents are no longer needed. */ - /* offset of tss struct (processor state) from beginning - of task struct */ - addl %d1,%a0 - /* save sr */ - movew %sr,%a0@(LTSS_SR) + movew %sr,%a0@(TASK_TSS+TSS_SR) /* save fs (sfc,%dfc) (may be pointing to kernel memory) */ movec %sfc,%d0 - movew %d0,%a0@(LTSS_FS) + movew %d0,%a0@(TASK_TSS+TSS_FS) /* save usp */ /* it is better to use a movel here instead of a movew 8*) */ movec %usp,%d0 - movel %d0,%a0@(LTSS_USP) + movel %d0,%a0@(TASK_TSS+TSS_USP) /* save non-scratch registers on stack */ SAVE_SWITCH_STACK /* save current kernel stack pointer */ - movel %sp,%a0@(LTSS_KSP) + movel %sp,%a0@(TASK_TSS+TSS_KSP) +#ifndef CONFIG_MATH_EMU_ONLY +#ifdef CONFIG_MATH_EMU + tstl SYMBOL_NAME(m68k_fputype) + jeq 3f +#endif /* save floating point context */ - fsave %a0@(LTSS_FPCTXT+27*4) + fsave %a0@(TASK_TSS+TSS_FPSTATE) #if defined(CONFIG_M68060) #if !defined(CPU_M68060_ONLY) @@ -278,27 +407,28 @@ beqs 1f #endif /* The 060 FPU keeps status in bits 15-8 of the first longword */ - tstb %a0@(LTSS_FPCTXT+27*4+2) + tstb %a0@(TASK_TSS+TSS_FPSTATE+2) jeq 3f #if !defined(CPU_M68060_ONLY) jra 2f #endif #endif /* CONFIG_M68060 */ #if !defined(CPU_M68060_ONLY) -1: tstb %a0@(LTSS_FPCTXT+27*4) +1: tstb %a0@(TASK_TSS+TSS_FPSTATE) jeq 3f #endif -2: fmovemx %fp0-%fp7,%a0@(LTSS_FPCTXT) - fmoveml %fpcr/%fpsr/%fpiar,%a0@(LTSS_FPCTXT+24*4) +2: fmovemx %fp0-%fp7,%a0@(TASK_TSS+TSS_FPREG) + fmoveml %fpcr/%fpsr/%fpiar,%a0@(TASK_TSS+TSS_FPCNTL) 3: +#endif - /* get pointer to tss struct (a1 contains new task) */ + /* switch to new task (a1 contains new task) */ movel %a1,%curptr - addl %d1,%a1 /* Skip address space switching if they are the same. */ - tstb %d2 - jne 4f + movel %a0@(TASK_MM),%d0 + cmpl %a1@(TASK_MM),%d0 + jeq 4f #if defined(CPU_M68020_OR_M68030) && defined(CPU_M68040_OR_M68060) /* 68040 or 68060 ? */ @@ -316,7 +446,7 @@ movec %d0,%cacr /* switch the root pointer */ - pmove %a1@(LTSS_CRP),%crp + pmove %a1@(TASK_TSS+TSS_CRP),%crp #endif #if defined(CPU_M68020_OR_M68030) && defined(CPU_M68040_OR_M68060) @@ -333,7 +463,7 @@ pflushan /* switch the root pointer */ - movel %a1@(LTSS_CRP+4),%d0 + movel %a1@(TASK_TSS+TSS_CRP+4),%d0 movec %d0,%urp #if defined (CONFIG_M68060) @@ -353,43 +483,50 @@ 4: /* restore floating point context */ +#ifndef CONFIG_MATH_EMU_ONLY +#ifdef CONFIG_MATH_EMU + tstl SYMBOL_NAME(m68k_fputype) + jeq 4f +#endif #if defined(CONFIG_M68060) #if !defined(CPU_M68060_ONLY) btst #3,SYMBOL_NAME(m68k_cputype)+3 beqs 1f #endif /* The 060 FPU keeps status in bits 15-8 of the first longword */ - tstb %a1@(LTSS_FPCTXT+27*4+2) + tstb %a1@(TASK_TSS+TSS_FPSTATE+2) jeq 3f #if !defined(CPU_M68060_ONLY) jra 2f #endif #endif /* CONFIG_M68060 */ #if !defined(CPU_M68060_ONLY) -1: tstb %a1@(LTSS_FPCTXT+27*4) +1: tstb %a1@(TASK_TSS+TSS_FPSTATE) jeq 3f #endif -2: fmovemx %a1@(LTSS_FPCTXT),%fp0-%fp7 - fmoveml %a1@(LTSS_FPCTXT+24*4),%fpcr/%fpsr/%fpiar -3: frestore %a1@(LTSS_FPCTXT+27*4) +2: fmovemx %a1@(TASK_TSS+TSS_FPREG),%fp0-%fp7 + fmoveml %a1@(TASK_TSS+TSS_FPCNTL),%fpcr/%fpsr/%fpiar +3: frestore %a1@(TASK_TSS+TSS_FPSTATE) +4: +#endif /* restore the kernel stack pointer */ - movel %a1@(LTSS_KSP),%sp + movel %a1@(TASK_TSS+TSS_KSP),%sp /* restore non-scratch registers */ RESTORE_SWITCH_STACK /* restore user stack pointer */ - movel %a1@(LTSS_USP),%a0 + movel %a1@(TASK_TSS+TSS_USP),%a0 movel %a0,%usp /* restore fs (sfc,%dfc) */ - movew %a1@(LTSS_FS),%a0 + movew %a1@(TASK_TSS+TSS_FS),%a0 movec %a0,%sfc movec %a0,%dfc /* restore status register */ - movew %a1@(LTSS_SR),%sr + movew %a1@(TASK_TSS+TSS_SR),%sr rts Index: linux-2.1/arch/m68k/kernel/head.S diff -u linux-2.1/arch/m68k/kernel/head.S:1.1.1.1.6.2 linux-2.1/arch/m68k/kernel/head.S:1.1.1.1.6.2.2.3 --- linux-2.1/arch/m68k/kernel/head.S:1.1.1.1.6.2 Sat Dec 19 18:51:21 1998 +++ linux-2.1/arch/m68k/kernel/head.S Sun Dec 20 01:54:00 1998 @@ -7,9 +7,12 @@ ** ** 68040 fixes by Michael Rausch ** 68060 fixes by Roman Hodek +** MMU cleanup by Randy Thelen +** Final MMU cleanup by Roman Zippel ** ** Atari support by Andreas Schwab, using ideas of Robert de Vries ** and Bjoern Brauel +** VME Support by Richard Hirst ** ** 94/11/14 Andreas Schwab: put kernel at PAGESIZE ** 94/11/18 Andreas Schwab: remove identity mapping of STRAM for Atari @@ -18,6 +21,8 @@ ** 96/04/26 Guenther Kelleter: fixed identity mapping for Falcon with ** Magnum- and FX-alternate ram ** 98/04/25 Phil Blundell: added HP300 support +** 1998/08/30 David Kilzer: Added support for fbcon_font_desc structures +** for linux-2.1.115 ** ** This file is subject to the terms and conditions of the GNU General Public ** License. See the file README.legal in the main directory of this archive @@ -34,63 +39,281 @@ * Put us in supervisor state. * * The kernel setup code takes the following steps: - * Raise interrupt level - * Set up initial kernel memory mapping. - * This sets up a mapping of the 4M of memory the kernel - * is located in. It also does a mapping of any initial - * machine specific areas. - * Note that the kernel is located at virtual address 0x1000 == _start - * Enable cache memories - * Jump to kernel startup - * - * Register d6 contains the CPU flags and d4 the machine type - * from the boot_info information for most of this file. - * The upper word of d6 contains a bit for '040 or '060, since these two - * are quite similar for initial mm setup. Another bit in d6 allows - * distinction of the '060. The lower word of d6 contains the cache mode - * that should be applied to pages containing descriptors. This mode is - * non-cached/non-serialized for the '040 and cacheable/write-through for - * the '060. - * - * General register usage: - * a6 - start of unused memory - * new pages can be allocated from here - * a5 - mmu root table - * a4 - mmu pointer table - * a3 - mmu page tables - * a2 - points to the page table entry for a6 - * cache status can be changed (used for '0[46]0) - * you must increase a2 if alloc a new page - * d7 - used for debug output and some macros - * d6 - cpu type and cache mode - * d5 - physical start address of kernel - * d4 - machine type + * . Raise interrupt level + * . Set up initial kernel memory mapping. + * . This sets up a mapping of the 4M of memory the kernel is located in. + * . It also does a mapping of any initial machine specific areas. + * . Enable the MMU + * . Enable cache memories + * . Jump to kernel startup + * + * Much of the file restructuring was to accomplish: + * 1) Remove register dependency through-out the file. + * 2) Increase use of subroutines to perform functions + * 3) Increase readability of the code + * + * Of course, readability is a subjective issue, so it will never be + * argued that that goal was accomplished. It was merely a goal. + * A key way to help make code more readable is to give good + * documentation. So, the first thing you will find is exaustive + * write-ups on the structure of the file, and the features of the + * functional subroutines. + * + * General Structure: + * ------------------ + * Without a doubt the single largest chunk of head.S is spent + * mapping the kernel and I/O physical space into the logical range + * for the kernel. + * There are new subroutines and data structures to make MMU + * support cleaner and easier to understand. + * First, you will find a routine call "mmu_map" which maps + * a logical to a physical region for some length given a cache + * type on behalf of the caller. This routine makes writing the + * actual per-machine specific code very simple. + * A central part of the code, but not a subroutine in itself, + * is the mmu_init code which is broken down into mapping the kernel + * (the same for all machines) and mapping machine-specific I/O + * regions. + * Also, there will be a description of engaging the MMU and + * caches. + * You will notice that there is a chunk of code which + * can emit the entire MMU mapping of the machine. This is present + * only in debug modes and can be very helpful. + * Further, there is a new console driver in head.S that is + * also only engaged in debug mode. Currently, it's only supported + * on the Macintosh class of machines. However, it is hoped that + * others will plug-in support for specific machines. + * + * ###################################################################### + * + * mmu_map + * ------- + * mmu_map was written for two key reasons. First, it was clear + * that it was very difficult to read the previous code for mapping + * regions of memory. Second, the Macintosh required such extensive + * memory allocations that it didn't make sense to propogate the + * existing code any further. + * mmu_map requires some parameters: + * + * mmu_map (logical, physical, length, cache_type) + * + * While this essentially describes the function in the abstract, you'll + * find more indepth description of other parameters at the implementation site. + * + * mmu_get_root_table_entry + * ------------------------ + * mmu_get_ptr_table_entry + * ----------------------- + * mmu_get_page_table_entry + * ------------------------ + * + * These routines are used by other mmu routines to get a pointer into + * a table, if necessary a new table is allocated. These routines are working + * basically like pmd_alloc() and pte_alloc() in . The root + * table needs of course only to be allocated once in mmu_get_root_table_entry, + * so that here also some mmu specific initialization is done. The second page + * at the start of the kernel (the first page is unmapped later) is used for + * the kernel_pg_dir. It must be at a position known at link time (as it's used + * to initialize the init task struct) and since it's needs special cache + * settings, it's the easiest to use this page, the rest of the page is used + * for further pointer tables. + * mmu_get_page_table_entry allocates always a whole page for page tables, this + * means 1024 pages and so 4MB of memory can be mapped. It doesn't make sense + * to manage page tables in smaller pieces as nearly all mappings have that + * size. + * + * ###################################################################### + * + * + * ###################################################################### + * + * mmu_engage + * ---------- + * Thanks to a small helping routine enabling the mmu got quiet simple + * and there is only one way left. mmu_engage makes a complete a new mapping + * that only includes the absolute necessary to be able to jump to the final + * postion and to restore the original mapping. + * As this code doesn't need a transparent translation register anymore this + * means all registers are free to be used by machines that needs them for + * other purposes. + * + * ###################################################################### + * + * mmu_print + * --------- + * This algorithm will print out the page tables of the system as + * appropriate for an 030 or an 040. This is useful for debugging purposes + * and as such is enclosed in #ifdef MMU_PRINT/#endif clauses. + * !!! BROKEN !!! STILL NEEDED ??? + * + * ###################################################################### + * + * console_init + * ------------ + * The console is also able to be turned off. The console in head.S + * is specifically for debugging and can be very useful. It is surrounded by + * #ifdef CONSOLE/#endif clauses so it doesn't have to ship in known-good + * kernels. It's basic algorithm is to determine the size of the screen + * (in height/width and bit depth) and then use that information for + * displaying an 8x8 font or an 8x16 (widthxheight). I prefer the 8x8 for + * debugging so I can see more good data. But it was trivial to add support + * for both fonts, so I included it. + * Also, the algorithm for plotting pixels is abstracted so that in + * theory other platforms could add support for different kinds of frame + * buffers. This could be very useful. + * + * console_put_penguin + * ------------------- + * An important part of any Linux bring up is the penguin and there's + * nothing like getting the Penguin on the screen! This algorithm will work + * on any machine for which there is a console_plot_pixel. + * + * console_scroll + * -------------- + * My hope is that the scroll algorithm does the right thing on the + * various platforms, but it wouldn't be hard to add the test conditions + * and new code if it doesn't. + * + * console_putc + * ------------- + * + * ###################################################################### + * + * Register usage has greatly simplified within head.S. Every subroutine + * saves and restores all registers that it modifies (except it returns a + * value in there of course). So the only register that needs to be initialized + * is the stack pointer. + * All other init code and data is now placed in the init section, so it will + * be automatically freed at the end of the kernel initialization. + * + * ###################################################################### + * + * options + * ------- + * There are many options availble in a build of this file. I've + * taken the time to describe them here to save you the time of searching + * for them and trying to understand what they mean. + * + * CONFIG_xxx: These are the obvious machine configuration defines created + * during configuration. These are defined in include/linux/autoconf.h. + * + * CONSOLE: There is support for head.S console in this file. This + * console can talk to a Mac frame buffer, but could easily be extrapolated + * to extend it to support other platforms. + * + * TEST_MMU: This is a test harness for running on any given machine but + * getting an MMU dump for another class of machine. The classes of machines + * that can be tested are any of the makes (Atari, Amiga, Mac, VME, etc.) + * and any of the models (030, 040, 060, etc.). + * + * NOTE: TEST_MMU is NOT permanent! It is scheduled to be removed + * When head.S boots on Atari, Amiga, Macintosh, and VME + * machines. At that point the underlying logic will be + * believed to be solid enough to be trusted, and TEST_MMU + * can be dropped. Do note that that will clean up the + * head.S code significantly as large blocks of #if/#else + * clauses can be removed. + * + * MMU_NOCACHE_KERNEL: On the Macintosh platform there was an inquiry into + * determing why devices don't appear to work. A test case was to remove + * the cacheability of the kernel bits. + * + * MMU_PRINT: There is a routine built into head.S that can display the + * MMU data structures. It outputs its result through the serial_putc + * interface. So where ever that winds up driving data, that's where the + * mmu struct will appear. On the Macintosh that's typically the console. + * + * SERIAL_DEBUG: There are a series of putc() macro statements + * scattered through out the code to give progress of status to the + * person sitting at the console. This constant determines whether those + * are used. + * + * DEBUG: This is the standard DEBUG flag that can be set for building + * the kernel. It has the effect adding additional tests into + * the code. + * + * MMU_PRINT_PAGE_USAGE: + * Print the number of pages used by the MMU tables. + * + * FONT_6x11: + * FONT_8x8: + * FONT_8x16: + * In theory these could be determined at run time or handed + * over by the booter. But, let's be real, it's a fine hard + * coded value. (But, you will notice the code is run-time + * flexible!) A pointer to the font's struct fbcon_font_desc + * is kept locally in Lconsole_font. It is used to determine + * font size information dynamically. + * + * Atari constants: + * USE_PRINTER: Use the printer port for serial debug. + * USE_SCC_B: Use the SCC port A (Serial2) for serial debug. + * USE_SCC_A: Use the SCC port B (Modem2) for serial debug. + * USE_MFP: Use the ST-MFP port (Modem1) for serial debug. + * + * Macintosh constants: + * MAC_SERIAL_DEBUG: Turns on serial debug output for the Macintosh. + * MAC_USE_SCC_A: Use the SCC port A (modem) for serial debug. + * MAC_USE_SCC_B: Use the SCC port B (printer) for serial debug (default). */ #include #include +#include #include #include #include +#if defined(CONFIG_MAC) +#include