📄 apus_setup.c
字号:
"icbi 0,%0 \n\t" "isync \n\t" : : "r" (addr)); addr += L1_CACHE_BYTES; length -= L1_CACHE_BYTES; } __asm ("dcbf 0,%0\n\t" "sync \n\t" "icbi 0,%0 \n\t" "isync \n\t" : : "r" (addr));}/****************************************************** from setup.c */voidapus_restart(char *cmd){ cli(); APUS_WRITE(APUS_REG_LOCK, REGLOCK_BLACKMAGICK1|REGLOCK_BLACKMAGICK2); APUS_WRITE(APUS_REG_LOCK, REGLOCK_BLACKMAGICK1|REGLOCK_BLACKMAGICK3); APUS_WRITE(APUS_REG_LOCK, REGLOCK_BLACKMAGICK2|REGLOCK_BLACKMAGICK3); APUS_WRITE(APUS_REG_SHADOW, REGSHADOW_SELFRESET); APUS_WRITE(APUS_REG_RESET, REGRESET_AMIGARESET); for(;;);}voidapus_power_off(void){ for (;;);}voidapus_halt(void){ apus_restart(NULL);}/****************************************************** from setup.c/IDE */#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)/* * IDE stuff. */#if 0 /* no longer used -- paulus */voidapus_ide_fix_driveid(struct hd_driveid *id){ u_char *p = (u_char *)id; int i, j, cnt; u_char t; if (!MACH_IS_AMIGA && !MACH_IS_MAC) return; for (i = 0; i < num_driveid_types; i++) { cnt = driveid_types[i] & T_MASK_COUNT; switch (driveid_types[i] & T_MASK_TYPE) { case T_CHAR: p += cnt; break; case T_SHORT: for (j = 0; j < cnt; j++) { t = p[0]; p[0] = p[1]; p[1] = t; p += 2; } break; case T_INT: for (j = 0; j < cnt; j++) { t = p[0]; p[0] = p[3]; p[3] = t; t = p[1]; p[1] = p[2]; p[2] = t; p += 4; } break; case T_TEXT: for (j = 0; j < cnt; j += 2) { t = p[0]; p[0] = p[1]; p[1] = t; p += 2; } break; } }}#endif /* 0 */__initvoid apus_ide_init_hwif_ports (hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq){ if (data_port || ctrl_port) printk("apus_ide_init_hwif_ports: must not be called\n");}#endif/****************************************************** IRQ stuff */static unsigned int apus_irq_cannonicalize(unsigned int irq){ return irq;}int apus_get_irq_list(char *buf){#ifdef CONFIG_APUS extern int amiga_get_irq_list(char *buf); return amiga_get_irq_list (buf);#else return 0;#endif}/* IPL must be between 0 and 7 */static inline void apus_set_IPL(unsigned long ipl){ APUS_WRITE(APUS_IPL_EMU, IPLEMU_SETRESET | IPLEMU_DISABLEINT); APUS_WRITE(APUS_IPL_EMU, IPLEMU_IPLMASK); APUS_WRITE(APUS_IPL_EMU, IPLEMU_SETRESET | ((~ipl) & IPLEMU_IPLMASK)); APUS_WRITE(APUS_IPL_EMU, IPLEMU_DISABLEINT);}static inline unsigned long apus_get_IPL(void){ /* This returns the present IPL emulation level. */ unsigned long __f; APUS_READ(APUS_IPL_EMU, __f); return ((~__f) & IPLEMU_IPLMASK);}static inline unsigned long apus_get_prev_IPL(struct pt_regs* regs){ /* The value saved in mq is the IPL_EMU value at the time of interrupt. The lower bits are the current interrupt level, the upper bits the requested level. Thus, to restore the IPL level to the post-interrupt state, we will need to use the lower bits. */ unsigned long __f = regs->mq; return ((~__f) & IPLEMU_IPLMASK);}#ifdef CONFIG_APUSvoid free_irq(unsigned int irq, void *dev_id){ extern void amiga_free_irq(unsigned int irq, void *dev_id); amiga_free_irq (irq, dev_id);}int request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *), unsigned long irqflags, const char * devname, void *dev_id){ extern int amiga_request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *), unsigned long flags, const char *devname, void *dev_id); return amiga_request_irq (irq, handler, irqflags, devname, dev_id);}/* In Linux/m68k the sys_request_irq deals with vectors 0-7. That's what callers expect - but on Linux/APUS we actually use the IRQ_AMIGA_AUTO vectors (24-31), so we put this dummy function in between to adjust the vector argument (rather have cruft here than in the generic irq.c). */int sys_request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *), unsigned long irqflags, const char * devname, void *dev_id){ extern int request_sysirq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *), unsigned long irqflags, const char * devname, void *dev_id); return request_sysirq(irq+IRQ_AMIGA_AUTO, handler, irqflags, devname, dev_id);}#endifint apus_get_irq(struct pt_regs* regs){#ifdef CONFIG_APUS int level = apus_get_IPL();#ifdef __INTERRUPT_DEBUG printk("<%d:%d>", level, apus_get_prev_IPL(regs));#endif if (0 == level) return -8; if (7 == level) return -9; return level + IRQ_AMIGA_AUTO;#else return 0;#endif}void apus_post_irq(struct pt_regs* regs, int level){#ifdef __INTERRUPT_DEBUG printk("{%d}", apus_get_prev_IPL(regs));#endif /* Restore IPL to the previous value */ apus_set_IPL(apus_get_prev_IPL(regs));}/****************************************************** keyboard */static int apus_kbd_setkeycode(unsigned int scancode, unsigned int keycode){ return -EOPNOTSUPP;}static int apus_kbd_getkeycode(unsigned int scancode){ return scancode > 127 ? -EINVAL : scancode;}static int apus_kbd_translate(unsigned char keycode, unsigned char *keycodep, char raw_mode){ *keycodep = keycode; return 1;}static char apus_kbd_unexpected_up(unsigned char keycode){ return 0200;}static void apus_kbd_leds(unsigned char leds){}static void apus_kbd_init_hw(void){#ifdef CONFIG_APUS extern int amiga_keyb_init(void); amiga_keyb_init();#endif}/****************************************************** debugging *//* some serial hardware definitions */#define SDR_OVRUN (1<<15)#define SDR_RBF (1<<14)#define SDR_TBE (1<<13)#define SDR_TSRE (1<<12)#define AC_SETCLR (1<<15)#define AC_UARTBRK (1<<11)#define SER_DTR (1<<7)#define SER_RTS (1<<6)#define SER_DCD (1<<5)#define SER_CTS (1<<4)#define SER_DSR (1<<3)static __inline__ void ser_RTSon(void){ ciab.pra &= ~SER_RTS; /* active low */}int __debug_ser_out( unsigned char c ){ custom.serdat = c | 0x100; mb(); while (!(custom.serdatr & 0x2000)) barrier(); return 1;}unsigned char __debug_ser_in( void ){ unsigned char c; /* XXX: is that ok?? derived from amiga_ser.c... */ while( !(custom.intreqr & IF_RBF) ) barrier(); c = custom.serdatr; /* clear the interrupt, so that another character can be read */ custom.intreq = IF_RBF; return c;}int __debug_serinit( void ){ unsigned long flags; save_flags (flags); cli(); /* turn off Rx and Tx interrupts */ custom.intena = IF_RBF | IF_TBE; /* clear any pending interrupt */ custom.intreq = IF_RBF | IF_TBE; restore_flags (flags); /* * set the appropriate directions for the modem control flags, * and clear RTS and DTR */ ciab.ddra |= (SER_DTR | SER_RTS); /* outputs */ ciab.ddra &= ~(SER_DCD | SER_CTS | SER_DSR); /* inputs */ #ifdef CONFIG_KGDB /* turn Rx interrupts on for GDB */ custom.intena = IF_SETCLR | IF_RBF; ser_RTSon();#endif return 0;}void __debug_print_hex(unsigned long x){ int i; char hexchars[] = "0123456789ABCDEF"; for (i = 0; i < 8; i++) { __debug_ser_out(hexchars[(x >> 28) & 15]); x <<= 4; } __debug_ser_out('\n'); __debug_ser_out('\r');}void __debug_print_string(char* s){ unsigned char c; while((c = *s++)) __debug_ser_out(c); __debug_ser_out('\n'); __debug_ser_out('\r');}static void apus_progress(char *s, unsigned short value){ __debug_print_string(s);}/****************************************************** init *//* The number of spurious interrupts */volatile unsigned int num_spurious;#define NUM_IRQ_NODES 100static irq_node_t nodes[NUM_IRQ_NODES];extern void (*amiga_default_handler[AUTO_IRQS])(int, void *, struct pt_regs *);static const char *default_names[SYS_IRQS] = { "spurious int", "int1 handler", "int2 handler", "int3 handler", "int4 handler", "int5 handler", "int6 handler", "int7 handler"};irq_node_t *new_irq_node(void){ irq_node_t *node; short i; for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--) if (!node->handler) return node; printk ("new_irq_node: out of nodes\n"); return NULL;}extern void amiga_enable_irq(unsigned int irq);extern void amiga_disable_irq(unsigned int irq);struct hw_interrupt_type amiga_irqctrl = { " Amiga ", NULL, NULL, amiga_enable_irq, amiga_disable_irq, 0, 0};#define HARDWARE_MAPPED_SIZE (512*1024)unsigned long __init apus_find_end_of_memory(void){ int shadow = 0; unsigned long total; /* The memory size reported by ADOS excludes the 512KB reserved for PPC exception registers and possibly 512KB containing a shadow of the ADOS ROM. */ { unsigned long size = memory[0].size; /* If 2MB aligned, size was probably user specified. We can't tell anything about shadowing in this case so skip shadow assignment. */ if (0 != (size & 0x1fffff)){ /* Align to 512KB to ensure correct handling of both memfile and system specified sizes. */ size = ((size+0x0007ffff) & 0xfff80000); /* If memory is 1MB aligned, assume shadowing. */ shadow = !(size & 0x80000); } /* Add the chunk that ADOS does not see. by aligning the size to the nearest 2MB limit upwards. */ memory[0].size = ((size+0x001fffff) & 0xffe00000); } total = memory[0].size; /* Remove the memory chunks that are controlled by special Phase5 hardware. */ /* Remove the upper 512KB if it contains a shadow of the ADOS ROM. FIXME: It might be possible to disable this shadow HW. Check the booter (ppc_boot.c) */ if (shadow) total -= HARDWARE_MAPPED_SIZE; /* Remove the upper 512KB where the PPC exception vectors are mapped. */ total -= HARDWARE_MAPPED_SIZE; /* Linux/APUS only handles one block of memory -- the one on the PowerUP board. Other system memory is horrible slow in comparison. The user can use other memory for swapping using the z2ram device. */ ram_phys_base = memory[0].addr; return total;}static void __initapus_map_io(void){ /* Map PPC exception vectors. */ io_block_mapping(0xfff00000, 0xfff00000, 0x00020000, _PAGE_KERNEL); /* Map chip and ZorroII memory */ io_block_mapping(zTwoBase, 0x00000000, 0x01000000, _PAGE_IO);}__initvoid apus_init_IRQ(void){ int i; for ( i = 0 ; i < NR_IRQS ; i++ ) irq_desc[i].handler = &amiga_irqctrl; for (i = 0; i < NUM_IRQ_NODES; i++) nodes[i].handler = NULL; for (i = 0; i < AUTO_IRQS; i++) { if (amiga_default_handler[i] != NULL) sys_request_irq(i, amiga_default_handler[i], 0, default_names[i], NULL); } amiga_init_IRQ();}__initvoid platform_init(unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7){ extern int parse_bootinfo(const struct bi_record *); extern char _end[]; /* Parse bootinfo. The bootinfo is located right after the kernel bss */ parse_bootinfo((const struct bi_record *)&_end);#ifdef CONFIG_BLK_DEV_INITRD /* Take care of initrd if we have one. Use data from bootinfo to avoid the need to initialize PPC registers when kernel is booted via a PPC reset. */ if ( ramdisk.addr ) { initrd_start = (unsigned long) __va(ramdisk.addr); initrd_end = (unsigned long) __va(ramdisk.size + ramdisk.addr); }#endif /* CONFIG_BLK_DEV_INITRD */ ISA_DMA_THRESHOLD = 0x00ffffff; ppc_md.setup_arch = apus_setup_arch; ppc_md.show_cpuinfo = apus_show_cpuinfo; ppc_md.irq_cannonicalize = apus_irq_cannonicalize; ppc_md.init_IRQ = apus_init_IRQ; ppc_md.get_irq = apus_get_irq; #error Should use the ->end() member of irq_desc[x]. -- Cort /*ppc_md.post_irq = apus_post_irq;*/ #ifdef CONFIG_HEARTBEAT ppc_md.heartbeat = apus_heartbeat; ppc_md.heartbeat_count = 1;#endif#ifdef APUS_DEBUG __debug_serinit(); ppc_md.progress = apus_progress;#endif ppc_md.init = NULL; ppc_md.restart = apus_restart; ppc_md.power_off = apus_power_off; ppc_md.halt = apus_halt; ppc_md.time_init = NULL; ppc_md.set_rtc_time = apus_set_rtc_time; ppc_md.get_rtc_time = apus_get_rtc_time; ppc_md.calibrate_decr = apus_calibrate_decr; ppc_md.find_end_of_memory = apus_find_end_of_memory; ppc_md.setup_io_mappings = apus_map_io; ppc_md.nvram_read_val = NULL; ppc_md.nvram_write_val = NULL; /* These should not be used for the APUS yet, since it uses the M68K keyboard now. */ ppc_md.kbd_setkeycode = apus_kbd_setkeycode; ppc_md.kbd_getkeycode = apus_kbd_getkeycode; ppc_md.kbd_translate = apus_kbd_translate; ppc_md.kbd_unexpected_up = apus_kbd_unexpected_up; ppc_md.kbd_leds = apus_kbd_leds; ppc_md.kbd_init_hw = apus_kbd_init_hw;#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) ppc_ide_md.ide_init_hwif = apus_ide_init_hwif_ports;#endif }/*************************************************** coexistence */void __init adbdev_init(void){}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -