diff options
author | Denys Dmytriyenko <denis@denix.org> | 2009-03-17 14:32:59 -0400 |
---|---|---|
committer | Denys Dmytriyenko <denis@denix.org> | 2009-03-17 14:32:59 -0400 |
commit | 709c4d66e0b107ca606941b988bad717c0b45d9b (patch) | |
tree | 37ee08b1eb308f3b2b6426d5793545c38396b838 /recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602 | |
parent | fa6cd5a3b993f16c27de4ff82b42684516d433ba (diff) | |
download | openembedded-709c4d66e0b107ca606941b988bad717c0b45d9b.tar.gz |
rename packages/ to recipes/ per earlier agreement
See links below for more details:
http://thread.gmane.org/gmane.comp.handhelds.openembedded/21326
http://thread.gmane.org/gmane.comp.handhelds.openembedded/21816
Signed-off-by: Denys Dmytriyenko <denis@denix.org>
Acked-by: Mike Westerhof <mwester@dls.net>
Acked-by: Philip Balister <philip@balister.org>
Acked-by: Khem Raj <raj.khem@gmail.com>
Acked-by: Marcin Juszkiewicz <hrw@openembedded.org>
Acked-by: Koen Kooi <koen@openembedded.org>
Acked-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
Diffstat (limited to 'recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602')
35 files changed, 69873 insertions, 0 deletions
diff --git a/recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/1764-1.patch b/recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/1764-1.patch new file mode 100644 index 0000000000..0b660f3521 --- /dev/null +++ b/recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/1764-1.patch @@ -0,0 +1,16 @@ +__arch_strncpy_from_user needs to be exported if you build the framebuffer console driver as a module. + +Cheers, + +Ian. + +--- linux-2.6-bkpxa.orig/arch/arm/kernel/armksyms.c 2004-02-27 10:35:29.000000000 +0000 ++++ linux-2.6-bkpxa/arch/arm/kernel/armksyms.c 2004-02-27 14:55:02.000000000 +0000 +@@ -187,6 +187,7 @@ + EXPORT_SYMBOL(__arch_copy_to_user); + EXPORT_SYMBOL(__arch_clear_user); + EXPORT_SYMBOL(__arch_strnlen_user); ++EXPORT_SYMBOL(__arch_strncpy_from_user); + + /* consistent area handling */ + EXPORT_SYMBOL(consistent_alloc); diff --git a/recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/CPAR050218.patch b/recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/CPAR050218.patch new file mode 100644 index 0000000000..a0b866219b --- /dev/null +++ b/recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/CPAR050218.patch @@ -0,0 +1,422 @@ +--- 050125/include/asm-arm/proc-armv/ptrace.h Tue Jan 25 00:22:44 2005 ++++ 050218/include/asm-arm/proc-armv/ptrace.h Thu Feb 17 16:13:54 2005 +@@ -40,6 +40,10 @@ + + struct pt_regs { + long uregs[18]; ++#if defined(CONFIG_CPU_PXA27X) ++ long cpar; ++ long mmx[ 16*2 + 6 + 1 ]; ++#endif + }; + + #define ARM_cpsr uregs[16] +--- 050125/include/asm-arm/sigcontext.h Tue Jan 25 00:22:42 2005 ++++ 050218/include/asm-arm/sigcontext.h Thu Feb 17 18:16:28 2005 +@@ -28,6 +28,10 @@ + unsigned long arm_pc; + unsigned long arm_cpsr; + unsigned long fault_address; ++#if defined(CONFIG_CPU_PXA27X) ++ unsigned long arm_cpar; ++ unsigned long arm_mmx[ 16*2 + 6 + 1 ]; ++#endif + }; + + +--- 050125/include/asm-arm/elf.h Tue Jan 25 00:54:49 2005 ++++ 050218/include/asm-arm/elf.h Thu Feb 17 16:19:02 2005 +@@ -1,6 +1,8 @@ + #ifndef __ASMARM_ELF_H + #define __ASMARM_ELF_H + ++#include <linux/config.h> ++ + /* + * ELF register definitions.. + */ +@@ -14,6 +16,7 @@ + + #define EM_ARM 40 + #define EF_ARM_APCS26 0x08 ++#define EF_ARM_SOFT_FLOAT 0x200 + + #define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t)) + typedef elf_greg_t elf_gregset_t[ELF_NGREG]; +--- 050125/arch/arm/kernel/entry-armv.S Tue Jan 25 00:21:45 2005 ++++ 050218/arch/arm/kernel/entry-armv.S Fri Feb 18 07:29:34 2005 +@@ -271,7 +271,7 @@ + tst \irqstat, #IRQ_MASK_DOORBELLHOST + movne \irqnr, #IRQ_DOORBELLHOST + bne 1001f +- ++ + tst \irqstat, #IRQ_MASK_I2OINPOST + movne \irqnr, #IRQ_I2OINPOST + bne 1001f +@@ -494,12 +494,12 @@ + + #elif defined(CONFIG_ARCH_L7200) + #include <asm/hardware.h> +- ++ + .equ irq_base_addr, IO_BASE_2 + + .macro disable_fiq + .endm +- ++ + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + mov \irqstat, #irq_base_addr @ Virt addr IRQ regs + add \irqstat, \irqstat, #0x00001000 @ Status reg +@@ -589,7 +589,7 @@ + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp +- ++ + /* Read all interrupts pending... */ + ldr \irqnr, =IO_ADDRESS(PLAT_PERIPHERAL_BASE) + OMAHA_INTPND + ldr \irqstat, [\irqnr] /* INTPND */ +@@ -607,7 +607,7 @@ + .endm + + .macro irq_prio_table +- .endm ++ .endm + + #elif defined(CONFIG_ARCH_CLPS711X) + +@@ -654,23 +654,23 @@ + + .macro irq_prio_table + .endm +- ++ + #elif defined (CONFIG_ARCH_CAMELOT) + #include <asm/arch/platform.h> + #undef IRQ_MODE /* same name defined in asm/proc/ptrace.h */ + #include <asm/arch/int_ctrl00.h> +- ++ + .macro disable_fiq + .endm + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp +- ++ + ldr \irqstat, =INT_ID(IO_ADDRESS(EXC_INT_CTRL00_BASE)) +- ldr \irqnr,[\irqstat] ++ ldr \irqnr,[\irqstat] + cmp \irqnr,#0 + subne \irqnr,\irqnr,#1 + +- ++ + .endm + + .macro irq_prio_table +@@ -910,7 +910,7 @@ + mov pc, r7 @ check, if this is a relevant code + cmp r0, #0 @ check return value + beq 1f @ else let linux do what it has to do +-2: ++2: + #endif + #ifndef CONFIG_KGDB + adrsvc al, r9, 1f @ r9 = normal FP return +@@ -977,6 +977,9 @@ + stmia r5, {r2 - r4} @ Save USR pc, cpsr, old_r0 + stmdb r5, {sp, lr}^ + alignment_trap r7, r7, __temp_abt ++#ifdef CONFIG_CPU_PXA27X ++ save_user_mmx ++#endif + zero_fp + mov r0, r2 @ remove once everyones in sync + #ifdef MULTI_CPU +@@ -1001,6 +1004,9 @@ + stmia r8, {r5 - r7} @ save pc, psr, old_r0 + stmdb r8, {sp, lr}^ + alignment_trap r4, r7, __temp_irq ++#ifdef CONFIG_CPU_PXA27X ++ save_user_mmx ++#endif + zero_fp + get_current_task tsk + #ifdef CONFIG_PREEMPT +@@ -1039,6 +1045,9 @@ + stmia r8, {r5 - r7} @ Save USR pc, cpsr, old_r0 + stmdb r8, {sp, lr}^ @ Save user sp, lr + alignment_trap r4, r7, __temp_und ++#ifdef CONFIG_CPU_PXA27X ++ save_user_mmx ++#endif + zero_fp + tst r6, #T_BIT @ Thumb mode + bne fpundefinstr +@@ -1068,6 +1077,9 @@ + stmia r8, {r5 - r7} @ Save USR pc, cpsr, old_r0 + stmdb r8, {sp, lr}^ @ Save sp_usr lr_usr + alignment_trap r4, r7, __temp_abt ++#ifdef CONFIG_CPU_PXA27X ++ save_user_mmx ++#endif + zero_fp + mov r0, #MODE_SVC + msr cpsr_c, r0 @ Enable interrupts +@@ -1394,7 +1406,7 @@ + stmfd sp!, {r4, r5} + #endif + mrc p15, 0, r2, c3, c0 +- str r2, [sp, #-4]! ++ str r2, [sp, #-4]! + + ldr r2, [r0] + str sp, [r2] +--- 050125/arch/arm/kernel/entry-header.S Tue Jan 25 00:21:45 2005 ++++ 050218/arch/arm/kernel/entry-header.S Thu Feb 17 20:15:24 2005 +@@ -42,9 +42,44 @@ + @ Stack format (ensured by USER_* and SVC_*) + @ + #ifdef CONFIG_CPU_32 +-#define S_FRAME_SIZE 72 +-#define S_OLD_R0 68 +-#define S_PSR 64 ++#ifdef CONFIG_CPU_PXA27X ++ #define S_MMX 80 ++ ++ #define MMX_WR0 (0x00) ++ #define MMX_WR1 (0x08) ++ #define MMX_WR2 (0x10) ++ #define MMX_WR3 (0x18) ++ #define MMX_WR4 (0x20) ++ #define MMX_WR5 (0x28) ++ #define MMX_WR6 (0x30) ++ #define MMX_WR7 (0x38) ++ #define MMX_WR8 (0x40) ++ #define MMX_WR9 (0x48) ++ #define MMX_WR10 (0x50) ++ #define MMX_WR11 (0x58) ++ #define MMX_WR12 (0x60) ++ #define MMX_WR13 (0x68) ++ #define MMX_WR14 (0x70) ++ #define MMX_WR15 (0x78) ++ #define MMX_WCSSF (0x80) ++ #define MMX_WCASF (0x84) ++ #define MMX_WCGR0 (0x88) ++ #define MMX_WCGR1 (0x8C) ++ #define MMX_WCGR2 (0x90) ++ #define MMX_WCGR3 (0x94) ++ ++ #define MMX_SIZE (0x98) ++ ++ #define S_FRAME_SIZE (76+4+MMX_SIZE) ++ ++ #define S_CPAR 72 ++ #define S_OLD_R0 68 ++ #define S_PSR 64 ++#else ++ #define S_FRAME_SIZE 72 ++ #define S_OLD_R0 68 ++ #define S_PSR 64 ++#endif + #else + #define S_FRAME_SIZE 68 + #define S_OLD_R0 64 +@@ -88,6 +123,43 @@ + set_cpsr_c \temp, #MODE_SVC + .endm + ++#ifdef CONFIG_CPU_PXA27X ++ .macro save_user_mmx ++ mrc p15, 0, r0, c15, c1, 0 ++ str r0, [sp, #S_CPAR] @ Save CPAR ++ cmp r0, #3 ++ bne 1f ++ add r0,sp,#S_MMX @ StoreMMX ++ bic r0, r0, #7 ++ wstrw wCSSF, [r0, #MMX_WCSSF] ++ wstrw wCASF, [r0, #MMX_WCASF] ++ wstrw wCGR0, [r0, #MMX_WCGR0] ++ wstrw wCGR1, [r0, #MMX_WCGR1] ++ wstrw wCGR2, [r0, #MMX_WCGR2] ++ wstrw wCGR3, [r0, #MMX_WCGR3] ++ wstrd wR0, [r0, #MMX_WR0] ++ wstrd wR1, [r0, #MMX_WR1] ++ wstrd wR2, [r0, #MMX_WR2] ++ wstrd wR3, [r0, #MMX_WR3] ++ wstrd wR4, [r0, #MMX_WR4] ++ wstrd wR5, [r0, #MMX_WR5] ++ wstrd wR6, [r0, #MMX_WR6] ++ wstrd wR7, [r0, #MMX_WR7] ++ wstrd wR8, [r0, #MMX_WR8] ++ wstrd wR9, [r0, #MMX_WR9] ++ wstrd wR10, [r0, #MMX_WR10] ++ wstrd wR11, [r0, #MMX_WR11] ++ wstrd wR12, [r0, #MMX_WR12] ++ wstrd wR13, [r0, #MMX_WR13] ++ wstrd wR14, [r0, #MMX_WR14] ++ wstrd wR15, [r0, #MMX_WR15] ++1: ++ mov r0, #1 ++ mcr p15, 0, r0, c15, c1, 0 @ CP0 Only. ++ ldr r0, [sp] @ Restore R0 ++ .endm ++#endif ++ + .macro save_user_regs + sub sp, sp, #S_FRAME_SIZE + stmia sp, {r0 - r12} @ Calling r0 - r12 +@@ -97,12 +169,44 @@ + str lr, [sp, #S_PC] @ Save calling PC + str r8, [sp, #S_PSR] @ Save CPSR + str r0, [sp, #S_OLD_R0] @ Save OLD_R0 ++ save_user_mmx + .endm + + /* + * Must be called with IRQs already disabled. + */ + .macro restore_user_regs ++#ifdef CONFIG_CPU_PXA27X ++ ldr r1, [sp, #S_CPAR] ++ mcr p15, 0, r1, c15, c1, 0 ++ cmp r1, #3 ++ bne 2f ++ add r1,sp,#S_MMX @ LoadMMX ++ bic r1, r1, #7 ++ wldrd wR0, [r1, #MMX_WR0] ++ wldrd wR1, [r1, #MMX_WR1] ++ wldrd wR2, [r1, #MMX_WR2] ++ wldrd wR3, [r1, #MMX_WR3] ++ wldrd wR4, [r1, #MMX_WR4] ++ wldrd wR5, [r1, #MMX_WR5] ++ wldrd wR6, [r1, #MMX_WR6] ++ wldrd wR7, [r1, #MMX_WR7] ++ wldrd wR8, [r1, #MMX_WR8] ++ wldrd wR9, [r1, #MMX_WR9] ++ wldrd wR10, [r1, #MMX_WR10] ++ wldrd wR11, [r1, #MMX_WR11] ++ wldrd wR12, [r1, #MMX_WR12] ++ wldrd wR13, [r1, #MMX_WR13] ++ wldrd wR14, [r1, #MMX_WR14] ++ wldrd wR15, [r1, #MMX_WR15] ++ wldrw wCSSF, [r1, #MMX_WCSSF] ++ wldrw wCASF, [r1, #MMX_WCASF] ++ wldrw wCGR0, [r1, #MMX_WCGR0] ++ wldrw wCGR1, [r1, #MMX_WCGR1] ++ wldrw wCGR2, [r1, #MMX_WCGR2] ++ wldrw wCGR3, [r1, #MMX_WCGR3] ++2: ++#endif + ldr r1, [sp, #S_PSR] @ Get calling cpsr + ldr lr, [sp, #S_PC]! @ Get PC + msr spsr, r1 @ save in spsr_svc +@@ -116,6 +220,37 @@ + * Must be called with IRQs already disabled. + */ + .macro fast_restore_user_regs ++#ifdef CONFIG_CPU_PXA27X ++ ldr r1, [sp, #S_OFF + S_CPAR] ++ mcr p15, 0, r1, c15, c1, 0 ++ cmp r1, #3 ++ bne 3f ++ add r1,sp,#S_OFF + S_MMX @ LoadMMX ++ bic r1, r1, #7 ++ wldrd wR0, [r1, #MMX_WR0] ++ wldrd wR1, [r1, #MMX_WR1] ++ wldrd wR2, [r1, #MMX_WR2] ++ wldrd wR3, [r1, #MMX_WR3] ++ wldrd wR4, [r1, #MMX_WR4] ++ wldrd wR5, [r1, #MMX_WR5] ++ wldrd wR6, [r1, #MMX_WR6] ++ wldrd wR7, [r1, #MMX_WR7] ++ wldrd wR8, [r1, #MMX_WR8] ++ wldrd wR9, [r1, #MMX_WR9] ++ wldrd wR10, [r1, #MMX_WR10] ++ wldrd wR11, [r1, #MMX_WR11] ++ wldrd wR12, [r1, #MMX_WR12] ++ wldrd wR13, [r1, #MMX_WR13] ++ wldrd wR14, [r1, #MMX_WR14] ++ wldrd wR15, [r1, #MMX_WR15] ++ wldrw wCSSF, [r1, #MMX_WCSSF] ++ wldrw wCASF, [r1, #MMX_WCASF] ++ wldrw wCGR0, [r1, #MMX_WCGR0] ++ wldrw wCGR1, [r1, #MMX_WCGR1] ++ wldrw wCGR2, [r1, #MMX_WCGR2] ++ wldrw wCGR3, [r1, #MMX_WCGR3] ++3: ++#endif + ldr r1, [sp, #S_OFF + S_PSR] @ get calling cpsr + ldr lr, [sp, #S_OFF + S_PC]! @ get pc + msr spsr, r1 @ save in spsr_svc +--- 050125/arch/arm/kernel/signal.c Tue Jan 25 00:21:45 2005 ++++ 050218/arch/arm/kernel/signal.c Thu Feb 17 18:22:10 2005 +@@ -198,6 +198,13 @@ + { + int err = 0; + ++#if defined(CONFIG_CPU_PXA27X) ++ int _m; ++ __get_user_error(regs->cpar, &sc->arm_cpar, err); ++ for( _m=0; _m<16*2 + 6 + 1; ++_m ) { ++ __get_user_error(regs->mmx[ _m ], &sc->arm_mmx[ _m ], err); ++ } ++#endif + __get_user_error(regs->ARM_r0, &sc->arm_r0, err); + __get_user_error(regs->ARM_r1, &sc->arm_r1, err); + __get_user_error(regs->ARM_r2, &sc->arm_r2, err); +@@ -312,6 +319,13 @@ + { + int err = 0; + ++#if defined(CONFIG_CPU_PXA27X) ++ int _m; ++ __put_user_error(regs->cpar, &sc->arm_cpar, err); ++ for( _m=0; _m<16*2 + 6 + 1; ++_m ) { ++ __put_user_error(regs->mmx[ _m ], &sc->arm_mmx[ _m ], err); ++ } ++#endif + __put_user_error(regs->ARM_r0, &sc->arm_r0, err); + __put_user_error(regs->ARM_r1, &sc->arm_r1, err); + __put_user_error(regs->ARM_r2, &sc->arm_r2, err); +--- 050125/arch/arm/Makefile Tue Jan 25 00:21:44 2005 ++++ 050218/arch/arm/Makefile Thu Feb 17 09:38:40 2005 +@@ -69,7 +69,8 @@ + + ifeq ($(CONFIG_ARCH_SHARP_SL),y) + CROSS_COMPILE = arm-linux- +-arch-y :=-D__LINUX_ARM_ARCH__=4 -march=armv4 -Wa,-mxscale ++#arch-y :=-D__LINUX_ARM_ARCH__=4 -march=armv4 -Wa,-mxscale ++arch-y :=-D__LINUX_ARM_ARCH__=4 -Wa,-mcpu=iwmmxt + tune-y :=-mtune=strongarm + endif + +@@ -212,7 +213,7 @@ + MACHINE = omaha + endif + +-ifeq ($(CONFIG_XIP_KERNEL),y) ++ifeq ($(CONFIG_XIP_KERNEL),y) + DATAADDR := $(TEXTADDR) + # Replace phys addr with virt addr while keeping offset from base. + # Virt base addr also defined in include/asm-arm/arch-*/hardware.h +--- 050125/fs/binfmt_elf.c Tue Jan 25 00:22:37 2005 ++++ 050218/fs/binfmt_elf.c Thu Feb 17 08:52:54 2005 +@@ -815,6 +815,15 @@ + ELF_PLAT_INIT(regs); + #endif + ++#if defined(CONFIG_CPU_PXA27X) ++ if( elf_ex.e_flags & EF_ARM_SOFT_FLOAT ) { ++ regs->cpar = 0x03; //CP0 CP1 Used. ++ } ++ else { ++ regs->cpar = 0x01; //CP0 Only. ++ } ++#endif ++ + start_thread(regs, elf_entry, bprm->p); + if (current->ptrace & PT_PTRACED) + send_sig(SIGTRAP, current, 0); diff --git a/recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/P01-C3000-clockup_050221.patch b/recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/P01-C3000-clockup_050221.patch new file mode 100644 index 0000000000..d193f23733 --- /dev/null +++ b/recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/P01-C3000-clockup_050221.patch @@ -0,0 +1,202 @@ +diff -Nur c3000_org/linux/arch/arm/config.in c3000_work/linux/arch/arm/config.in +--- c3000_org/linux/arch/arm/config.in 2004-08-21 09:48:07.000000000 +0900 ++++ c3000_work/linux/arch/arm/config.in 2005-02-21 21:41:40.000000000 +0900 +@@ -195,7 +195,7 @@ + dep_bool ' SHARP Spitz' CONFIG_ARCH_PXA_SPITZ $CONFIG_ARCH_PXA_BOXER + dep_bool ' Using Trial 0' CONFIG_SPITZ_TR0 $CONFIG_ARCH_PXA_SPITZ + dep_bool ' Using Trial 0.5' CONFIG_SPITZ_TR0_5 $CONFIG_ARCH_PXA_SPITZ +-dep_bool ' SHARP Tosa' CONFIG_ARCH_PXA_TOSA ++dep_bool ' SHARP Tosa' CONFIG_ARCH_PXA_TOSA $CONFIG_ARCH_PXA + dep_bool ' SHARP Tosa skipping' CONFIG_ARCH_PXA_TOSA_SKIP $CONFIG_ARCH_PXA_TOSA + + if [ "$CONFIG_SABINAL_DISCOVERY" = "y" -o "$CONFIG_ARCH_PXA_POODLE" = "y" -o \ +@@ -475,6 +475,9 @@ + if [ "$CONFIG_ARCH_PXA_SPITZ" = "y" ]; then + define_bool CONFIG_CPU_PXA27X y + fi ++ if [ "$CONFIG_ARCH_PXA_SPITZ" = "y" ]; then ++ bool 'Use clock change(cccr_change) enable (EXPERIMENTAL)' CONFIG_SL_CCCR_CHANGE ++ fi + if [ "$CONFIG_ARCH_SHARP_SL" = "y" ]; then + define_bool CONFIG_BATT y + fi +@@ -557,7 +560,7 @@ + # bool ' Real-Time Scheduling support' CONFIG_RTSCHED + define_bool CONFIG_RTSCHED y + if [ "$CONFIG_RTSCHED" = "y" ]; then +- int ' MAX PTHREAD (int)' CONFIG_RTH_PTHREAD_MAX 128 ++ int ' MAX PTHREAD (int)' CONFIG_RTH_PTHREAD_MAX 128 + hex ' RT MEMORY SIZE (hex)' CONFIG_RT_MEM_SIZE 80000 + bool ' Real-Time Calibrate support' CONFIG_RTHAL_CALIBRATION + if [ "$CONFIG_RTHAL_CALIBRATION" != "y" ]; then +@@ -615,7 +618,7 @@ + hex 'Compressed ROM boot loader BSS address' CONFIG_ZBOOT_ROM_BSS 0 + else + define_hex CONFIG_ZBOOT_ROM_TEXT 0 +- define_hex CONFIG_ZBOOT_ROM_BSS 0 ++ define_hex CONFIG_ZBOOT_ROM_BSS 0 + fi + + if [ "$CONFIG_ARCH_SA1100" = "y" -o \ +diff -Nur c3000_org/linux/arch/arm/mach-pxa/sharpsl_apm.c c3000_work/linux/arch/arm/mach-pxa/sharpsl_apm.c +--- c3000_org/linux/arch/arm/mach-pxa/sharpsl_apm.c 2004-11-16 15:31:06.000000000 +0900 ++++ c3000_work/linux/arch/arm/mach-pxa/sharpsl_apm.c 2005-02-21 21:44:13.000000000 +0900 +@@ -130,6 +130,11 @@ + extern int HWR_flag; + #endif + ++#if defined(CONFIG_SL_CCCR_CHANGE) ++extern unsigned int CCCR_ValAdr_high; ++struct proc_dir_entry *proc_zaurus; ++#endif ++ + #if defined(CONFIG_SABINAL_DISCOVERY) + #define SHARPSL_AC_LINE_STATUS (( ASIC3_GPIO_PSTS_D & AC_IN )? APM_AC_OFFLINE : APM_AC_ONLINE) + #define BACKPACK_IN_DETECT() ( ASIC3_GPIO_PSTS_D & BACKPACK_DETECT ) /* 0: exist , 1: not in */ +@@ -974,6 +979,63 @@ + + EXPORT_SYMBOL(lock_FCS); + ++#if defined(CONFIG_SL_CCCR_CHANGE) ++ ++void write_cccr(int cccr) ++{ ++ printk("Change CCCR = %x.\n",cccr); ++ CCCR_ValAdr_high = cccr; ++ sharpsl_chg_freq = cccr; ++ cpu_xscale_sl_change_speed_high(); ++ cccr_reg = CCCR; ++ printk("Changed CCCR = %x.\n",cccr_reg); ++ return; ++} ++ ++int read_cccr(void) ++{ ++ return CCCR_ValAdr_high; ++} ++ ++static ssize_t cccr_change_read_params(struct file *file, char *buf, ++ size_t nbytes, loff_t *ppos) ++{ ++ char outputbuf[32]; ++ int count; ++ ++ if (*ppos>0) /* Assume reading completed in previous read*/ ++ return 0; ++ count = sprintf(outputbuf, "0x%08X\n", read_cccr()); ++ count++; ++ *ppos += count; ++ if (count>nbytes)/* Assume output can be read at one time */ ++ return -EINVAL; ++ if (copy_to_user(buf, outputbuf, count+1)) ++ return -EFAULT; ++ return count; ++} ++ ++static ssize_t cccr_change_write_params(struct file *file, const char *buf, ++ size_t nbytes, loff_t *ppos) ++{ ++ unsigned int param=0; ++ ++ sscanf(buf,"%x",¶m); ++ if (param) { ++ write_cccr(param); ++ } ++ return nbytes; ++} ++ ++static struct file_operations proc_cccr_change_params_operations = { ++ read:cccr_change_read_params, ++ write:cccr_change_write_params, ++}; ++ ++EXPORT_SYMBOL(read_cccr); ++EXPORT_SYMBOL(write_cccr); ++#endif ++ + #ifdef CONFIG_APM_CPU_IDLE + #ifdef SHARPSL_NEW_IDLE + static int save_icmr; +@@ -2786,6 +2848,7 @@ + struct proc_dir_entry *apm_proc; + struct proc_dir_entry *lock_fcs_proc; + struct proc_dir_entry *power_mode_proc; ++ struct proc_dir_entry *cccr_change_proc; + + apm_info.bios = apm_bios_info; + if (apm_info.bios.version == 0) { +@@ -2822,6 +2885,9 @@ + printk("FCS : CCCR = %x\n",cccr_reg); + #if defined(CONFIG_CPU_PXA27X) + sharpsl_chg_freq = cccr_reg; ++#if defined(CONFIG_SL_CCCR_CHANGE) ++ CCCR_ValAdr_high = sharpsl_chg_freq; ++#endif + #endif + #endif + +@@ -2902,6 +2968,19 @@ + power_mode_proc->proc_fops = &proc_power_mode_params_operations; + } + ++#if defined(CONFIG_SL_CCCR_CHANGE) ++ proc_zaurus = proc_mkdir("zaurus", NULL); ++ if (proc_zaurus == NULL) { ++ unregister_chrdev(228, "zaurus"); ++ printk(KERN_ERR "proc: can't create /proc/zaurus\n"); ++ return -ENOMEM; ++ } ++ ++ cccr_change_proc = create_proc_entry("zaurus/CCCR", 0, NULL); ++ if (cccr_change_proc) { ++ cccr_change_proc->proc_fops = &proc_cccr_change_params_operations; ++ } ++#endif + kernel_thread(apm_thread, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND | SIGCHLD); + + #if defined(CONFIG_SABINAL_DISCOVERY) || defined(CONFIG_ARCH_PXA_TOSA) +diff -Nur c3000_org/linux/arch/arm/mach-pxa/sharpsl_suspend.S c3000_work/linux/arch/arm/mach-pxa/sharpsl_suspend.S +--- c3000_org/linux/arch/arm/mach-pxa/sharpsl_suspend.S 2004-11-09 14:30:36.000000000 +0900 ++++ c3000_work/linux/arch/arm/mach-pxa/sharpsl_suspend.S 2005-02-21 21:41:40.000000000 +0900 +@@ -64,7 +64,7 @@ + + sleep_param: .word 0 @ virtual address of parameter array + sleep_param_p: .word 0 @ physical address of parameter array +- ++ + IC_BASE: .word io_p2v(0x40D00000) + + +@@ -1109,6 +1109,9 @@ + + #else /* CONFIG_CPU_PXA27X */ + ++#if defined(CONFIG_SL_CCCR_CHANGE) ++ .global CCCR_ValAdr_high ++#endif + CCCR_ValAdr_high: .word 0x02000210 + MSC0_ValAdr_high: .word 0x7ff02DD8 + MSC1_ValAdr_high: .word 0x7ff434D4 +@@ -1305,8 +1308,12 @@ + stmfd sp!, {r0, r1, r2, r3, r4, lr} + + ldr r0, CMR_BASE ++#if defined(CONFIG_SL_CCCR_CHANGE) ++ ldr r1, CCCR_ValAdr_high ++#else + ldr r1, CCCR_ValAdr_208 +- str r1, [r0, #CMR_CCCR] ++#endif ++ str r1, [r0, #CMR_CCCR] + + ldr r0, MD_BASE + ldr r4, MDREFR_ValAdr_208 +@@ -1333,7 +1340,7 @@ + + .align 5 + .text +- ++ + ENTRY(pxa27x_get_ccnt) + mrc p14, 0, r0, c1, c1, 0 + mov pc, lr @ return diff --git a/recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/P02++050226.patch b/recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/P02++050226.patch new file mode 100644 index 0000000000..d9c94e5ac1 --- /dev/null +++ b/recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/P02++050226.patch @@ -0,0 +1,221 @@ +--- BASE/arch/arm/mach-pxa/pxa27x_power.c Sat Feb 26 01:35:47 2005 ++++ 050226/arch/arm/mach-pxa/pxa27x_power.c Sat Feb 26 02:01:45 2005 +@@ -152,6 +152,10 @@ + + #if defined(CONFIG_CHANGE_CORE_VOLT) + static unsigned char current_core_voltage = 0x1a; ++static unsigned char core_voltage_value = 0; ++extern unsigned int CCCR_ValAdr_high; ++#include <linux/sem.h> ++static DECLARE_MUTEX(core_voltage_sem); + #endif + + void PrintParamTable(void); +@@ -397,9 +401,9 @@ + } + #endif //DEBUG + ++#if !defined(CONFIG_CHANGE_CORE_VOLT) + static void cpu_xscale_voltage_low(void) + { +- + pwr_i2c_open(); + pwr_i2c_write( 0x0c, 0x13 ); // 1.00V - SlewRate 1 + //pwr_i2c_write( 0x0c, 0x12 ); // 0.95V - SlewRate 1 +@@ -409,38 +413,90 @@ + static void cpu_xscale_voltage_high(void) + { + pwr_i2c_open(); +-#if defined(CONFIG_CHANGE_CORE_VOLT) +- pwr_i2c_write( 0x0c, current_core_voltage ); +- pwr_i2c_close(); +- printk("current voltage %x\n", current_core_voltage ); +-#else + pwr_i2c_write( 0x0c, 0x1a ); // 1.35V - SlewRate 1 + pwr_i2c_close(); +-#endif + } ++#endif + + #if defined(CONFIG_CHANGE_CORE_VOLT) ++static void cpu_xscale_voltage_change(unsigned char value) ++{ ++ if(core_voltage_value!=value) { ++ core_voltage_value = value; ++ pwr_i2c_open(); ++ pwr_i2c_write( 0x0c, current_core_voltage ); ++ pwr_i2c_close(); ++ } ++} ++ ++void cpu_xscale_voltage_high(void) ++{ ++ down(&core_voltage_sem); ++ cpu_xscale_voltage_change(current_core_voltage); ++ up(&core_voltage_sem); ++} + void cpu_xscale_voltage_write(unsigned char value) + { + if (value > 0x10 ) + return; + value += 0x10; ++ down(&core_voltage_sem); ++ core_voltage_value = value; + pwr_i2c_open(); + pwr_i2c_write( 0x0c, value ); + pwr_i2c_close(); + current_core_voltage = value; ++ up(&core_voltage_sem); + printk("current voltage %x\n", current_core_voltage ); + + } ++ ++void cpu_xscale_sl_change_speed_high(void) ++{ ++ down(&core_voltage_sem); ++ cpu_xscale_voltage_change(current_core_voltage); ++ _cpu_xscale_sl_change_speed_high(); ++ up(&core_voltage_sem); ++} ++void cpu_xscale_sl_change_speed_low(void) ++{ ++ down(&core_voltage_sem); ++ _cpu_xscale_sl_change_speed_low(); ++ cpu_xscale_voltage_change(0x13); ++ up(&core_voltage_sem); ++} ++void cpu_xscale_sl_change_speed_91(void) ++{ ++ down(&core_voltage_sem); ++ _cpu_xscale_sl_change_speed_91(); ++ core_voltage_value = 0x13; ++ pwr_i2c_open(); ++ pwr_i2c_write( 0x0c, core_voltage_value ); ++ pwr_i2c_close(); ++ up(&core_voltage_sem); ++} ++void cpu_xscale_sl_change_speed_208(void) ++{ ++ down(&core_voltage_sem); ++ core_voltage_value = current_core_voltage; ++ pwr_i2c_open(); ++ pwr_i2c_write( 0x0c, core_voltage_value ); ++ pwr_i2c_close(); ++ _cpu_xscale_sl_change_speed_208(); ++ up(&core_voltage_sem); ++} ++ + #endif + + #if defined(DEBUG) || defined(CONFIG_CHANGE_CORE_VOLT) + unsigned char cpu_xscale_voltage_read(void) + { + unsigned char value=0xff; ++ down(&core_voltage_sem); + pwr_i2c_open(); + pwr_i2c_read( 0x0c, &value ); + pwr_i2c_close(); ++ up(&core_voltage_sem); + return value; + } + #endif +@@ -520,7 +576,7 @@ + sys_ctx.oier = OIER; + + #if defined(CONFIG_CPU_PXA27X) +- if ( CCCR != 0x02000210 ) { ++ if ( CCCR != CCCR_ValAdr_high ) { //0x02000210 ) { + cpu_xscale_sl_change_speed_high(); + } + #endif +@@ -571,8 +627,10 @@ + cpu_xscale_sl_disable_fastbus_mode(); + udelay(1); + cpu_xscale_sl_change_speed_91(); ++#if !defined(CONFIG_CHANGE_CORE_VOLT) + cpu_xscale_voltage_low(); + #endif ++#endif + + /* Scoop suspend */ + sharpsl_check_scoop_reg(); +@@ -790,7 +848,9 @@ + SCP2_REG_GPWR = sys_ctx.scp2_gpwr; + + #if defined(PXA27X_SUSPEND) ++#if !defined(CONFIG_CHANGE_CORE_VOLT) + cpu_xscale_voltage_high(); ++#endif + cpu_xscale_sl_change_speed_208(); + udelay(1); + cpu_xscale_sl_enable_fastbus_mode(); +--- BASE/arch/arm/mach-pxa/sharpsl_apm.c Sat Feb 26 01:35:52 2005 ++++ 050226/arch/arm/mach-pxa/sharpsl_apm.c Sat Feb 26 01:54:16 2005 +@@ -143,6 +143,7 @@ + #if defined(CONFIG_CHANGE_CORE_VOLT) + extern unsigned char cpu_xscale_voltage_read(void); + extern void cpu_xscale_voltage_write(unsigned char); ++extern void cpu_xscale_voltage_high(void); + #endif + + #if defined(CONFIG_SABINAL_DISCOVERY) +@@ -1389,6 +1390,9 @@ + + #if defined(CONFIG_CPU_PXA27X) + #if defined(CONFIG_FB_SHARPSL_PXA) ++#if defined(CONFIG_CHANGE_CORE_VOLT) ++ cpu_xscale_voltage_high(); ++#endif + while (1) { + if (!(LCCR0 & 0x1) || (GPLR(GPIO74_LCD_FCLK) & + GPIO_bit(GPIO74_LCD_FCLK))) +--- BASE/arch/arm/mach-pxa/sharpsl_suspend.S Sat Feb 26 01:35:42 2005 ++++ 050226/arch/arm/mach-pxa/sharpsl_suspend.S Sat Feb 26 01:54:16 2005 +@@ -1119,7 +1119,11 @@ + MDREFR_ValAdr_high_pre: .word 0x001BC00B + MDREFR_ValAdr_high: .word 0x001BC030 + ++#if defined(CONFIG_CHANGE_CORE_VOLT) ++ENTRY(_cpu_xscale_sl_change_speed_high) ++#else + ENTRY(cpu_xscale_sl_change_speed_high) ++#endif + stmfd sp!, {r0, r1, r2, r3, r4, lr} + + ldr r0, CMR_BASE +@@ -1168,7 +1172,11 @@ + @MDREFR_ValAdr_low: .word 0x0019C017 + MDREFR_ValAdr_low: .word 0x001BC017 + ++#if defined(CONFIG_CHANGE_CORE_VOLT) ++ENTRY(_cpu_xscale_sl_change_speed_low) ++#else + ENTRY(cpu_xscale_sl_change_speed_low) ++#endif + stmfd sp!, {r0, r1, r2, r3, r4, lr} + + ldr r0, CMR_BASE +@@ -1261,7 +1269,11 @@ + MDREFR_ValAdr_91_pre: .word 0x001BC00B + MDREFR_ValAdr_91: .word 0x001BC013 + ++#if defined(CONFIG_CHANGE_CORE_VOLT) ++ENTRY(_cpu_xscale_sl_change_speed_91) ++#else + ENTRY(cpu_xscale_sl_change_speed_91) ++#endif + stmfd sp!, {r0, r1, r2, r3, r4, lr} + + ldr r0, CMR_BASE +@@ -1304,7 +1316,11 @@ + MSC2_ValAdr_208: .word 0x7FF034D4 + MDREFR_ValAdr_208: .word 0x001BC00B + ++#if defined(CONFIG_CHANGE_CORE_VOLT) ++ENTRY(_cpu_xscale_sl_change_speed_208) ++#else + ENTRY(cpu_xscale_sl_change_speed_208) ++#endif + stmfd sp!, {r0, r1, r2, r3, r4, lr} + + ldr r0, CMR_BASE diff --git a/recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/P02-C3000-voltage_050221.patch b/recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/P02-C3000-voltage_050221.patch new file mode 100644 index 0000000000..1663304aae --- /dev/null +++ b/recipes/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/P02-C3000-voltage_050221.patch @@ -0,0 +1,179 @@ +diff -Nur c3000_pre/linux/arch/arm/config.in c3000_work/linux/arch/arm/config.in +--- c3000_pre/linux/arch/arm/config.in 2005-02-21 21:41:40.000000000 +0900 ++++ c3000_work/linux/arch/arm/config.in 2005-02-21 22:25:37.000000000 +0900 +@@ -478,6 +478,9 @@ + if [ "$CONFIG_ARCH_PXA_SPITZ" = "y" ]; then + bool 'Use clock change(cccr_change) enable (EXPERIMENTAL)' CONFIG_SL_CCCR_CHANGE + fi ++ if [ "$CONFIG_SL_CCCR_CHANGE" = "y" ]; then ++ bool 'Core voltage change enable (EXPERIMENTAL)' CONFIG_CHANGE_CORE_VOLT ++ fi
@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
.highlight .sa { color: #e6db74 } /* Literal.String.Affix */
.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
.highlight .sc { color: #e6db74 } /* Literal.String.Char */
.highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */
.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
.highlight .se { color: #ae81ff } /* Literal.String.Escape */
.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
.highlight .si { color: #e6db74 } /* Literal.String.Interpol */
.highlight .sx { color: #e6db74 } /* Literal.String.Other */
.highlight .sr { color: #e6db74 } /* Literal.String.Regex */
.highlight .s1 { color: #e6db74 } /* Literal.String.Single */
.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #a6e22e } /* Name.Function.Magic */
.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
.highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */
.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
}
@media (prefers-color-scheme: light) {
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
}
# ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
##########################################################################
#
# Copyright (C) 2005-2006 Michael 'Mickey' Lauer <mickey@Vanille.de>
# Copyright (C) 2005-2006 Vanille Media
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
##########################################################################
#
# Thanks to:
# * Holger Freyther <zecke@handhelds.org>
# * Justin Patrin <papercrane@reversefold.com>
#
##########################################################################
"""
BitBake Shell
IDEAS:
* list defined tasks per package
* list classes
* toggle force
* command to reparse just one (or more) bbfile(s)
* automatic check if reparsing is necessary (inotify?)
* frontend for bb file manipulation
* more shell-like features:
- output control, i.e. pipe output into grep, sort, etc.
- job control, i.e. bring running commands into background and foreground
* start parsing in background right after startup
* ncurses interface
PROBLEMS:
* force doesn't always work
* readline completion for commands with more than one parameters
"""
##########################################################################
# Import and setup global variables
##########################################################################
from __future__ import print_function
from functools import reduce
try:
set
except NameError:
from sets import Set as set
import sys, os, readline, socket, httplib, urllib, commands, popen2, shlex, Queue, fnmatch
from bb import data, parse, build, cache, taskdata, runqueue, providers as Providers
__version__ = "0.5.3.1"
__credits__ = """BitBake Shell Version %s (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
Type 'help' for more information, press CTRL-D to exit.""" % __version__
cmds = {}
leave_mainloop = False
last_exception = None
cooker = None
parsed = False
debug = os.environ.get( "BBSHELL_DEBUG", "" )
##########################################################################
# Class BitBakeShellCommands
##########################################################################
class BitBakeShellCommands:
"""This class contains the valid commands for the shell"""
def __init__( self, shell ):
"""Register all the commands"""
self._shell = shell
for attr in BitBakeShellCommands.__dict__:
if not attr.startswith( "_" ):
if attr.endswith( "_" ):
command = attr[:-1].lower()
else:
command = attr[:].lower()
method = getattr( BitBakeShellCommands, attr )
debugOut( "registering command '%s'" % command )
# scan number of arguments
usage = getattr( method, "usage", "" )
if usage != "<...>":
numArgs = len( usage.split() )
else:
numArgs = -1
shell.registerCommand( command, method, numArgs, "%s %s" % ( command, usage ), method.__doc__ )
def _checkParsed( self ):
if not parsed:
print("SHELL: This command needs to parse bbfiles...")
self.parse( None )
def _findProvider( self, item ):
self._checkParsed()
# Need to use taskData for this information
preferred = data.getVar( "PREFERRED_PROVIDER_%s" % item, cooker.configuration.data, 1 )
if not preferred: preferred = item
try:
lv, lf, pv, pf = Providers.findBestProvider(preferred, cooker.configuration.data, cooker.status)
except KeyError:
if item in cooker.status.providers:
pf = cooker.status.providers[item][0]
else:
pf = None
return pf
def alias( self, params ):
"""Register a new name for a command"""
new, old = params
if not old in cmds:
print("ERROR: Command '%s' not known" % old)
else:
cmds[new] = cmds[old]
print("OK")
alias.usage = "<alias> <command>"
def buffer( self, params ):
"""Dump specified output buffer"""
index = params[0]
print(self._shell.myout.buffer( int( index ) ))
buffer.usage = "<index>"
def buffers( self, params ):
"""Show the available output buffers"""
commands = self._shell.myout.bufferedCommands()
if not commands:
print("SHELL: No buffered commands available yet. Start doing something.")
else:
print("="*35, "Available Output Buffers", "="*27)
for index, cmd in enumerate( commands ):
print("| %s %s" % ( str( index ).ljust( 3 ), cmd ))
print("="*88)
def build( self, params, cmd = "build" ):
"""Build a providee"""
global last_exception
globexpr = params[0]
self._checkParsed()
names = globfilter( cooker.status.pkg_pn, globexpr )
if len( names ) == 0: names = [ globexpr ]
print("SHELL: Building %s" % ' '.join( names ))
td = taskdata.TaskData(cooker.configuration.abort)
localdata = data.createCopy(cooker.configuration.data)
data.update_data(localdata)
data.expandKeys(localdata)
try:
tasks = []
for name in names:
td.add_provider(localdata, cooker.status, name)
providers = td.get_provider(name)
if len(providers) == 0:
raise Providers.NoProvider
tasks.append([name, "do_%s" % cmd])
td.add_unresolved(localdata, cooker.status)
rq = runqueue.RunQueue(cooker, localdata, cooker.status, td, tasks)
rq.prepare_runqueue()
rq.execute_runqueue()
except Providers.NoProvider:
print("ERROR: No Provider")
last_exception = Providers.NoProvider
except runqueue.TaskFailure as fnids:
last_exception = runqueue.TaskFailure
except build.FuncFailed as e:
print("ERROR: Couldn't build '%s'" % names)
last_exception = e
build.usage = "<providee>"
def clean( self, params ):
"""Clean a providee"""
self.build( params, "clean" )
clean.usage = "<providee>"
def compile( self, params ):
"""Execute 'compile' on a providee"""
self.build( params, "compile" )
compile.usage = "<providee>"
def configure( self, params ):
"""Execute 'configure' on a providee"""
self.build( params, "configure" )
configure.usage = "<providee>"
def install( self, params ):
"""Execute 'install' on a providee"""
self.build( params, "install" )
install.usage = "<providee>"
def edit( self, params ):
"""Call $EDITOR on a providee"""
name = params[0]
bbfile = self._findProvider( name )
if bbfile is not None:
os.system( "%s %s" % ( os.environ.get( "EDITOR", "vi" ), bbfile ) )
else:
print("ERROR: Nothing provides '%s'" % name)
edit.usage = "<providee>"
def environment( self, params ):
"""Dump out the outer BitBake environment"""
cooker.showEnvironment()
def exit_( self, params ):
"""Leave the BitBake Shell"""
debugOut( "setting leave_mainloop to true" )
global leave_mainloop
leave_mainloop = True
def fetch( self, params ):
"""Fetch a providee"""
self.build( params, "fetch" )
fetch.usage = "<providee>"
def fileBuild( self, params, cmd = "build" ):
"""Parse and build a .bb file"""
global last_exception
name = params[0]
bf = completeFilePath( name )
print("SHELL: Calling '%s' on '%s'" % ( cmd, bf ))
try:
cooker.buildFile(bf, cmd)
except parse.ParseError:
print("ERROR: Unable to open or parse '%s'" % bf)
except build.FuncFailed as e:
print("ERROR: Couldn't build '%s'" % name)
last_exception = e
fileBuild.usage = "<bbfile>"
def fileClean( self, params ):
"""Clean a .bb file"""
self.fileBuild( params, "clean" )
fileClean.usage = "<bbfile>"
def fileEdit( self, params ):
"""Call $EDITOR on a .bb file"""
name = params[0]
os.system( "%s %s" % ( os.environ.get( "EDITOR", "vi" ), completeFilePath( name ) ) )
fileEdit.usage = "<bbfile>"
def fileRebuild( self, params ):
"""Rebuild (clean & build) a .bb file"""
self.fileBuild( params, "rebuild" )
fileRebuild.usage = "<bbfile>"
def fileReparse( self, params ):
"""(re)Parse a bb file"""
bbfile = params[0]
print("SHELL: Parsing '%s'" % bbfile)
parse.update_mtime( bbfile )
cooker.parser.reparse(bbfile)
if False: #fromCache:
print("SHELL: File has not been updated, not reparsing")
else:
print("SHELL: Parsed")
fileReparse.usage = "<bbfile>"
def abort( self, params ):
"""Toggle abort task execution flag (see bitbake -k)"""
cooker.configuration.abort = not cooker.configuration.abort
print("SHELL: Abort Flag is now '%s'" % repr( cooker.configuration.abort ))
def force( self, params ):
"""Toggle force task execution flag (see bitbake -f)"""
cooker.configuration.force = not cooker.configuration.force
print("SHELL: Force Flag is now '%s'" % repr( cooker.configuration.force ))
def help( self, params ):
"""Show a comprehensive list of commands and their purpose"""
print("="*30, "Available Commands", "="*30)
for cmd in sorted(cmds):
function, numparams, usage, helptext = cmds[cmd]
print("| %s | %s" % (usage.ljust(30), helptext))
print("="*78)
def lastError( self, params ):
"""Show the reason or log that was produced by the last BitBake event exception"""
if last_exception is None:
print("SHELL: No Errors yet (Phew)...")
else:
reason, event = last_exception.args
print("SHELL: Reason for the last error: '%s'" % reason)
if ':' in reason:
msg, filename = reason.split( ':' )
filename = filename.strip()
print("SHELL: Dumping log file for last error:")
try:
print(open( filename ).read())
except IOError:
print("ERROR: Couldn't open '%s'" % filename)
def match( self, params ):
"""Dump all files or providers matching a glob expression"""
what, globexpr = params
if what == "files":
self._checkParsed()
for key in globfilter( cooker.status.pkg_fn, globexpr ): print(key)
elif what == "providers":
self._checkParsed()
for key in globfilter( cooker.status.pkg_pn, globexpr ): print(key)
else:
print("Usage: match %s" % self.print_.usage)
match.usage = "<files|providers> <glob>"
def new( self, params ):
"""Create a new .bb file and open the editor"""
dirname, filename = params
packages = '/'.join( data.getVar( "BBFILES", cooker.configuration.data, 1 ).split('/')[:-2] )
fulldirname = "%s/%s" % ( packages, dirname )
if not os.path.exists( fulldirname ):
print("SHELL: Creating '%s'" % fulldirname)
os.mkdir( fulldirname )
if os.path.exists( fulldirname ) and os.path.isdir( fulldirname ):
if os.path.exists( "%s/%s" % ( fulldirname, filename ) ):
print("SHELL: ERROR: %s/%s already exists" % ( fulldirname, filename ))
return False
print("SHELL: Creating '%s/%s'" % ( fulldirname, filename ))
newpackage = open( "%s/%s" % ( fulldirname, filename ), "w" )
print("""DESCRIPTION = ""
SECTION = ""
AUTHOR = ""
HOMEPAGE = ""
MAINTAINER = ""
LICENSE = "GPL"
PR = "r0"
SRC_URI = ""
#inherit base
#do_configure() {
#
#}
#do_compile() {
#
#}
#do_stage() {
#
#}
#do_install() {
#
#}
""", file=newpackage)
newpackage.close()
os.system( "%s %s/%s" % ( os.environ.get( "EDITOR" ), fulldirname, filename ) )
new.usage = "<directory> <filename>"
def package( self, params ):
"""Execute 'package' on a providee"""
self.build( params, "package" )
package.usage = "<providee>"
def pasteBin( self, params ):
"""Send a command + output buffer to the pastebin at http://rafb.net/paste"""
index = params[0]
contents = self._shell.myout.buffer( int( index ) )
sendToPastebin( "output of " + params[0], contents )
pasteBin.usage = "<index>"
def pasteLog( self, params ):
"""Send the last event exception error log (if there is one) to http://rafb.net/paste"""
if last_exception is None:
print("SHELL: No Errors yet (Phew)...")
else:
reason, event = last_exception.args
print("SHELL: Reason for the last error: '%s'" % reason)
if ':' in reason:
msg, filename = reason.split( ':' )
filename = filename.strip()
print("SHELL: Pasting log file to pastebin...")
file = open( filename ).read()
sendToPastebin( "contents of " + filename, file )
def patch( self, params ):
"""Execute 'patch' command on a providee"""
self.build( params, "patch" )
patch.usage = "<providee>"
def parse( self, params ):
"""(Re-)parse .bb files and calculate the dependency graph"""
cooker.status = cache.CacheData(cooker.caches_array)
ignore = data.getVar("ASSUME_PROVIDED", cooker.configuration.data, 1) or ""
cooker.status.ignored_dependencies = set( ignore.split() )
cooker.handleCollections( data.getVar("BBFILE_COLLECTIONS", cooker.configuration.data, 1) )
(filelist, masked) = cooker.collect_bbfiles()
cooker.parse_bbfiles(filelist, masked, cooker.myProgressCallback)
cooker.buildDepgraph()
global parsed
parsed = True
print()
def reparse( self, params ):
"""(re)Parse a providee's bb file"""
bbfile = self._findProvider( params[0] )
if bbfile is not None:
print("SHELL: Found bbfile '%s' for '%s'" % ( bbfile, params[0] ))
self.fileReparse( [ bbfile ] )
else:
print("ERROR: Nothing provides '%s'" % params[0])
reparse.usage = "<providee>"
def getvar( self, params ):
"""Dump the contents of an outer BitBake environment variable"""
var = params[0]
value = data.getVar( var, cooker.configuration.data, 1 )
print(value)
getvar.usage = "<variable>"
def peek( self, params ):
"""Dump contents of variable defined in providee's metadata"""
name, var = params
bbfile = self._findProvider( name )
if bbfile is not None:
the_data = cache.Cache.loadDataFull(bbfile, cooker.configuration.data)
value = the_data.getVar( var, 1 )
print(value)
else:
print("ERROR: Nothing provides '%s'" % name)
peek.usage = "<providee> <variable>"
def poke( self, params ):
"""Set contents of variable defined in providee's metadata"""
name, var, value = params
bbfile = self._findProvider( name )
if bbfile is not None:
print("ERROR: Sorry, this functionality is currently broken")
#d = cooker.pkgdata[bbfile]
#data.setVar( var, value, d )
# mark the change semi persistant
#cooker.pkgdata.setDirty(bbfile, d)
#print "OK"
else:
print("ERROR: Nothing provides '%s'" % name)
poke.usage = "<providee> <variable> <value>"
def print_( self, params ):
"""Dump all files or providers"""
what = params[0]
if what == "files":
self._checkParsed()
for key in cooker.status.pkg_fn: print(key)
elif what == "providers":
self._checkParsed()
for key in cooker.status.providers: print(key)
else:
print("Usage: print %s" % self.print_.usage)
print_.usage = "<files|providers>"
def python( self, params ):
"""Enter the expert mode - an interactive BitBake Python Interpreter"""
sys.ps1 = "EXPERT BB>>> "
sys.ps2 = "EXPERT BB... "
import code
interpreter = code.InteractiveConsole( dict( globals() ) )
interpreter.interact( "SHELL: Expert Mode - BitBake Python %s\nType 'help' for more information, press CTRL-D to switch back to BBSHELL." % sys.version )
def showdata( self, params ):
"""Execute 'showdata' on a providee"""
cooker.showEnvironment(None, params)
showdata.usage = "<providee>"
def setVar( self, params ):
"""Set an outer BitBake environment variable"""
var, value = params
data.setVar( var, value, cooker.configuration.data )
print("OK")
setVar.usage = "<variable> <value>"
def rebuild( self, params ):
"""Clean and rebuild a .bb file or a providee"""
self.build( params, "clean" )
self.build( params, "build" )
rebuild.usage = "<providee>"
def shell( self, params ):
"""Execute a shell command and dump the output"""
if params != "":
print(commands.getoutput( " ".join( params ) ))
shell.usage = "<...>"
def stage( self, params ):
"""Execute 'stage' on a providee"""
self.build( params, "populate_staging" )
stage.usage = "<providee>"
def status( self, params ):
"""<just for testing>"""
print("-" * 78)
print("building list = '%s'" % cooker.building_list)
print("build path = '%s'" % cooker.build_path)
print("consider_msgs_cache = '%s'" % cooker.consider_msgs_cache)
print("build stats = '%s'" % cooker.stats)
if last_exception is not None: print("last_exception = '%s'" % repr( last_exception.args ))
print("memory output contents = '%s'" % self._shell.myout._buffer)
def test( self, params ):
"""<just for testing>"""
print("testCommand called with '%s'" % params)
def unpack( self, params ):
"""Execute 'unpack' on a providee"""
self.build( params, "unpack" )
unpack.usage = "<providee>"
def which( self, params ):
"""Computes the providers for a given providee"""
# Need to use taskData for this information
item = params[0]
self._checkParsed()
preferred = data.getVar( "PREFERRED_PROVIDER_%s" % item, cooker.configuration.data, 1 )
if not preferred: preferred = item
try:
lv, lf, pv, pf = Providers.findBestProvider(preferred, cooker.configuration.data, cooker.status)
except KeyError:
lv, lf, pv, pf = (None,)*4
try:
providers = cooker.status.providers[item]
except KeyError:
print("SHELL: ERROR: Nothing provides", preferred)
else:
for provider in providers:
if provider == pf: provider = " (***) %s" % provider
else: provider = " %s" % provider
print(provider)
which.usage = "<providee>"
##########################################################################
# Common helper functions
##########################################################################
def completeFilePath( bbfile ):
"""Get the complete bbfile path"""
if not cooker.status: return bbfile
if not cooker.status.pkg_fn: return bbfile
for key in cooker.status.pkg_fn:
if key.endswith( bbfile ):
return key
return bbfile
def sendToPastebin( desc, content ):
"""Send content to http://oe.pastebin.com"""
mydata = {}
mydata["lang"] = "Plain Text"
mydata["desc"] = desc
mydata["cvt_tabs"] = "No"
mydata["nick"] = "%s@%s" % ( os.environ.get( "USER", "unknown" ), socket.gethostname() or "unknown" )
mydata["text"] = content
params = urllib.urlencode( mydata )
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
host = "rafb.net"
conn = httplib.HTTPConnection( "%s:80" % host )
conn.request("POST", "/paste/paste.php", params, headers )
response = conn.getresponse()
conn.close()
if response.status == 302:
location = response.getheader( "location" ) or "unknown"
print("SHELL: Pasted to http://%s%s" % ( host, location ))
else:
print("ERROR: %s %s" % ( response.status, response.reason ))
def completer( text, state ):
"""Return a possible readline completion"""
debugOut( "completer called with text='%s', state='%d'" % ( text, state ) )
if state == 0:
line = readline.get_line_buffer()
if " " in line:
line = line.split()
# we are in second (or more) argument
if line[0] in cmds and hasattr( cmds[line[0]][0], "usage" ): # known command and usage
u = getattr( cmds[line[0]][0], "usage" ).split()[0]
if u == "<variable>":
allmatches = cooker.configuration.data.keys()
elif u == "<bbfile>":
if cooker.status.pkg_fn is None: allmatches = [ "(No Matches Available. Parsed yet?)" ]
else: allmatches = [ x.split("/")[-1] for x in cooker.status.pkg_fn ]
elif u == "<providee>":
if cooker.status.pkg_fn is None: allmatches = [ "(No Matches Available. Parsed yet?)" ]
else: allmatches = cooker.status.providers.iterkeys()
else: allmatches = [ "(No tab completion available for this command)" ]
else: allmatches = [ "(No tab completion available for this command)" ]
else:
# we are in first argument
allmatches = cmds.iterkeys()
completer.matches = [ x for x in allmatches if x[:len(text)] == text ]
#print "completer.matches = '%s'" % completer.matches
if len( completer.matches ) > state:
return completer.matches[state]
else:
return None
def debugOut( text ):
if debug:
sys.stderr.write( "( %s )\n" % text )
def columnize( alist, width = 80 ):
"""
A word-wrap function that preserves existing line breaks
and most spaces in the text. Expects that existing line
breaks are posix newlines (\n).
"""
return reduce(lambda line, word, width=width: '%s%s%s' %
(line,
' \n'[(len(line[line.rfind('\n')+1:])
+ len(word.split('\n', 1)[0]
) >= width)],
word),
alist
)
def globfilter( names, pattern ):
return fnmatch.filter( names, pattern )
##########################################################################
# Class MemoryOutput
##########################################################################
class MemoryOutput:
"""File-like output class buffering the output of the last 10 commands"""
def __init__( self, delegate ):
self.delegate = delegate
self._buffer = []
self.text = []
self._command = None
def startCommand( self, command ):
self._command = command
self.text = []
def endCommand( self ):
if self._command is not None:
if len( self._buffer ) == 10: del self._buffer[0]
self._buffer.append( ( self._command, self.text ) )
def removeLast( self ):
if self._buffer:
del self._buffer[ len( self._buffer ) - 1 ]
self.text = []
self._command = None
def lastBuffer( self ):
if self._buffer:
return self._buffer[ len( self._buffer ) -1 ][1]
def bufferedCommands( self ):
return [ cmd for cmd, output in self._buffer ]
def buffer( self, i ):
if i < len( self._buffer ):
return "BB>> %s\n%s" % ( self._buffer[i][0], "".join( self._buffer[i][1] ) )
else: return "ERROR: Invalid buffer number. Buffer needs to be in (0, %d)" % ( len( self._buffer ) - 1 )
def write( self, text ):
if self._command is not None and text != "BB>> ": self.text.append( text )
if self.delegate is not None: self.delegate.write( text )
def flush( self ):
return self.delegate.flush()
def fileno( self ):
return self.delegate.fileno()
def isatty( self ):
return self.delegate.isatty()
##########################################################################
# Class BitBakeShell
##########################################################################
class BitBakeShell:
def __init__( self ):
"""Register commands and set up readline"""
self.commandQ = Queue.Queue()
self.commands = BitBakeShellCommands( self )
self.myout = MemoryOutput( sys.stdout )
self.historyfilename = os.path.expanduser( "~/.bbsh_history" )
self.startupfilename = os.path.expanduser( "~/.bbsh_startup" )
readline.set_completer( completer )
readline.set_completer_delims( " " )
readline.parse_and_bind("tab: complete")
try:
readline.read_history_file( self.historyfilename )
except IOError:
pass # It doesn't exist yet.
print(__credits__)
def cleanup( self ):
"""Write readline history and clean up resources"""
debugOut( "writing command history" )
try:
readline.write_history_file( self.historyfilename )
except:
print("SHELL: Unable to save command history")
def registerCommand( self, command, function, numparams = 0, usage = "", helptext = "" ):
"""Register a command"""
if usage == "": usage = command
if helptext == "": helptext = function.__doc__ or "<not yet documented>"
cmds[command] = ( function, numparams, usage, helptext )
def processCommand( self, command, params ):
"""Process a command. Check number of params and print a usage string, if appropriate"""
debugOut( "processing command '%s'..." % command )
try:
function, numparams, usage, helptext = cmds[command]
except KeyError:
print("SHELL: ERROR: '%s' command is not a valid command." % command)
self.myout.removeLast()
else:
if (numparams != -1) and (not len( params ) == numparams):
print("Usage: '%s'" % usage)
return
result = function( self.commands, params )
debugOut( "result was '%s'" % result )
def processStartupFile( self ):
"""Read and execute all commands found in $HOME/.bbsh_startup"""
if os.path.exists( self.startupfilename ):
startupfile = open( self.startupfilename, "r" )
for cmdline in startupfile:
debugOut( "processing startup line '%s'" % cmdline )
if not cmdline:
continue
if "|" in cmdline:
print("ERROR: '|' in startup file is not allowed. Ignoring line")
continue
self.commandQ.put( cmdline.strip() )
def main( self ):
"""The main command loop"""
while not leave_mainloop:
try:
if self.commandQ.empty():
sys.stdout = self.myout.delegate
cmdline = raw_input( "BB>> " )
sys.stdout = self.myout
else:
cmdline = self.commandQ.get()
if cmdline:
allCommands = cmdline.split( ';' )
for command in allCommands:
pipecmd = None
#
# special case for expert mode
if command == 'python':
sys.stdout = self.myout.delegate
self.processCommand( command, "" )
sys.stdout = self.myout
else:
self.myout.startCommand( command )
if '|' in command: # disable output
command, pipecmd = command.split( '|' )
delegate = self.myout.delegate
self.myout.delegate = None
tokens = shlex.split( command, True )
self.processCommand( tokens[0], tokens[1:] or "" )
self.myout.endCommand()
if pipecmd is not None: # restore output
self.myout.delegate = delegate
pipe = popen2.Popen4( pipecmd )
pipe.tochild.write( "\n".join( self.myout.lastBuffer() ) )
pipe.tochild.close()
sys.stdout.write( pipe.fromchild.read() )
#
except EOFError:
print()
return
except KeyboardInterrupt:
print()
##########################################################################
# Start function - called from the BitBake command line utility
##########################################################################
def start( aCooker ):
global cooker
cooker = aCooker
bbshell = BitBakeShell()
bbshell.processStartupFile()
bbshell.main()
bbshell.cleanup()
if __name__ == "__main__":
print("SHELL: Sorry, this program should only be called by BitBake.")
|