freemyipod r419 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r418‎ | r419 | r420 >
Date:22:51, 8 January 2011
Author:theseven
Status:new
Tags:
Comment:
Fix iPod Classic LCD problems
Modified paths:
  • /apps/installer-classic/bootstub/bootstub.S (modified) (history)
  • /embios/trunk/loader/ipodclassic/main.S (modified) (history)
  • /embios/trunk/target/ipodnano3g/lcd.c (modified) (history)
  • /umsboot/target/ipodclassic/lcd.c (modified) (history)

Diff [purge]

Index: apps/installer-classic/bootstub/bootstub.S
@@ -425,6 +425,7 @@
426426 .hword 0xc000
427427 lcddata_2:
428428 lcddata_3:
 429+ .hword 0xc010
429430 .hword 0x4008
430431 .hword 0x0808
431432 .hword 0x8110
@@ -772,11 +773,10 @@
773774 bne lcdbyteseq
774775 movne r0, r0,lsl#4
775776 bne udelay
776 - tst r8, #0x20
777777 adr r1, _stubend + 4
778 - ldreq r6, val_80100db0
 778+ ldr r6, val_80100db0
779779 ldr r0, _stubend
780 - streq r6, [r4]
 780+ str r6, [r4]
781781 add r0, r1, r0
782782 mov r2, #0x08000000
783783 movepayloadloop:
Index: umsboot/target/ipodclassic/lcd.c
@@ -60,7 +60,7 @@
6161 static void lcd_send_data(uint16_t data)
6262 {
6363 while (LCDSTATUS & 0x10);
64 - LCDWDATA = data;
 64+ LCDWDATA = (data & 0xff) | ((data & 0x7f00) << 1);
6565 }
6666
6767 static uint32_t lcd_detect()
Index: embios/trunk/target/ipodnano3g/lcd.c
@@ -61,7 +61,7 @@
6262 static void lcd_send_data(uint16_t data)
6363 {
6464 while (LCDSTATUS & 0x10);
65 - LCDWDATA = data;
 65+ LCDWDATA = (data & 0xff) | ((data & 0x7f00) << 1);
6666 }
6767
6868 static uint32_t lcd_detect()
@@ -142,7 +142,7 @@
143143 {
144144 displaylcd_sync();
145145 uint32_t type = lcd_detect();
146 - if (type == 3)
 146+ if (type & 2)
147147 {
148148 lcd_send_cmd(0x7);
149149 lcd_send_data(0x172);
Index: embios/trunk/loader/ipodclassic/main.S
@@ -446,6 +446,7 @@
447447 .hword 0xc000
448448 lcddata_2:
449449 lcddata_3:
 450+ .hword 0xc010
450451 .hword 0x4008
451452 .hword 0x0808
452453 .hword 0x8110
@@ -599,6 +600,78 @@
600601 .hword 0x0173
601602 .hword 0xc000
602603
 604+ .code 16
 605+
 606+thumb_nrv2e_d8:
 607+ mov r7,r2
 608+ mov r4,#1; neg r5,r4 @ r5= -1 initial condition
 609+ lsl r4,#31 @ 1<<31: refill next time
 610+ mov r6,#5
 611+ lsl r6,#8 @ 0x500 @ nrv2e M2_MAX_OFFSET
 612+ b top_n2e
 613+
 614+nrv2e_done:
 615+ blx flushcache
 616+ bx r7
 617+
 618+get1_n2e: @ In: Carry set [from adding 0x80000000 (1<<31) to itself]
 619+ ldrb r4,[r0] @ zero-extend next byte
 620+ adc r4,r4 @ double and insert CarryIn as low bit
 621+ add r0,#1
 622+ lsl r4,#24 @ move to top byte, and set CarryOut from old bit 8
 623+ mov pc,lr @ return, stay in current (THUMB) mode
 624+
 625+lit_n2e:
 626+ ldrb r3,[r0]; add r0,#1
 627+ strb r3,[r2]; add r2,#1
 628+top_n2e:
 629+ add r4,r4; mov lr,pc; beq get1_n2e; bcs lit_n2e
 630+ mov r1,#1; b getoff_n2e
 631+
 632+off_n2e:
 633+ sub r1,#1
 634+ add r4,r4; mov lr,pc; beq get1_n2e; adc r1,r1
 635+getoff_n2e:
 636+ add r4,r4; mov lr,pc; beq get1_n2e; adc r1,r1
 637+ add r4,r4; mov lr,pc; beq get1_n2e; bcc off_n2e
 638+
 639+ sub r3,r1,#3 @ set Carry
 640+ mov r1,#0 @ Carry unaffected
 641+ blo offprev_n2e @ r1 was 2; tests Carry only
 642+ lsl r3,#8
 643+ ldrb r5,[r0]; add r0,#1 @ low 7+1 r4
 644+ orr r5,r3
 645+ mvn r5,r5; beq nrv2e_done @ r5= ~r5
 646+ asr r5,#1; bcs lenlast_n2e
 647+ b lenmore_n2e
 648+
 649+offprev_n2e:
 650+ add r4,r4; mov lr,pc; beq get1_n2e; bcs lenlast_n2e
 651+lenmore_n2e:
 652+ mov r1,#1
 653+ add r4,r4; mov lr,pc; beq get1_n2e; bcs lenlast_n2e
 654+len_n2e:
 655+ add r4,r4; mov lr,pc; beq get1_n2e; adc r1,r1
 656+ add r4,r4; mov lr,pc; beq get1_n2e; bcc len_n2e
 657+ add r1,#6-2
 658+ b gotlen_n2e
 659+
 660+lenlast_n2e:
 661+ add r4,r4; mov lr,pc; beq get1_n2e; adc r1,r1 @ 0,1,2,3
 662+ add r1,#2
 663+gotlen_n2e: @ 'cmn': add the inputs, set condition codes, discard the sum
 664+ cmn r6,r5; bcs near_n2e @ within M2_MAX_OFFSET
 665+ add r1,#1 @ too far away, so minimum match length is 3
 666+near_n2e:
 667+ ldrb r3,[r2] @ force cacheline allocate
 668+copy_n2e:
 669+ ldrb r3,[r2,r5]
 670+ strb r3,[r2]; add r2,#1
 671+ sub r1,#1; bne copy_n2e
 672+ b top_n2e
 673+
 674+ .code 32
 675+
603676 font:
604677 .byte 0, 0, 0, 0, 0
605678 .byte 0, 0, 95, 0, 0
@@ -696,78 +769,6 @@
697770 .byte 0, 65, 54, 8, 0
698771 .byte 2, 1, 2, 4, 2
699772
700 - .code 16
701 - .align 1
702 -
703 -thumb_nrv2e_d8:
704 - mov r7,r2
705 - mov r4,#1; neg r5,r4 @ r5= -1 initial condition
706 - lsl r4,#31 @ 1<<31: refill next time
707 - mov r6,#5
708 - lsl r6,#8 @ 0x500 @ nrv2e M2_MAX_OFFSET
709 - b top_n2e
710 -
711 -nrv2e_done:
712 - blx flushcache
713 - bx r7
714 -
715 -get1_n2e: @ In: Carry set [from adding 0x80000000 (1<<31) to itself]
716 - ldrb r4,[r0] @ zero-extend next byte
717 - adc r4,r4 @ double and insert CarryIn as low bit
718 - add r0,#1
719 - lsl r4,#24 @ move to top byte, and set CarryOut from old bit 8
720 - mov pc,lr @ return, stay in current (THUMB) mode
721 -
722 -lit_n2e:
723 - ldrb r3,[r0]; add r0,#1
724 - strb r3,[r2]; add r2,#1
725 -top_n2e:
726 - add r4,r4; mov lr,pc; beq get1_n2e; bcs lit_n2e
727 - mov r1,#1; b getoff_n2e
728 -
729 -off_n2e:
730 - sub r1,#1
731 - add r4,r4; mov lr,pc; beq get1_n2e; adc r1,r1
732 -getoff_n2e:
733 - add r4,r4; mov lr,pc; beq get1_n2e; adc r1,r1
734 - add r4,r4; mov lr,pc; beq get1_n2e; bcc off_n2e
735 -
736 - sub r3,r1,#3 @ set Carry
737 - mov r1,#0 @ Carry unaffected
738 - blo offprev_n2e @ r1 was 2; tests Carry only
739 - lsl r3,#8
740 - ldrb r5,[r0]; add r0,#1 @ low 7+1 r4
741 - orr r5,r3
742 - mvn r5,r5; beq nrv2e_done @ r5= ~r5
743 - asr r5,#1; bcs lenlast_n2e
744 - b lenmore_n2e
745 -
746 -offprev_n2e:
747 - add r4,r4; mov lr,pc; beq get1_n2e; bcs lenlast_n2e
748 -lenmore_n2e:
749 - mov r1,#1
750 - add r4,r4; mov lr,pc; beq get1_n2e; bcs lenlast_n2e
751 -len_n2e:
752 - add r4,r4; mov lr,pc; beq get1_n2e; adc r1,r1
753 - add r4,r4; mov lr,pc; beq get1_n2e; bcc len_n2e
754 - add r1,#6-2
755 - b gotlen_n2e
756 -
757 -lenlast_n2e:
758 - add r4,r4; mov lr,pc; beq get1_n2e; adc r1,r1 @ 0,1,2,3
759 - add r1,#2
760 -gotlen_n2e: @ 'cmn': add the inputs, set condition codes, discard the sum
761 - cmn r6,r5; bcs near_n2e @ within M2_MAX_OFFSET
762 - add r1,#1 @ too far away, so minimum match length is 3
763 -near_n2e:
764 - ldrb r3,[r2] @ force cacheline allocate
765 -copy_n2e:
766 - ldrb r3,[r2,r5]
767 - strb r3,[r2]; add r2,#1
768 - sub r1,#1; bne copy_n2e
769 - b top_n2e
770 -
771 - .code 32
772773 .align 2
773774
774775 foundfile:
@@ -1074,11 +1075,10 @@
10751076 bne lcdbyteseq
10761077 movne r0, r0,lsl#4
10771078 bne udelay
1078 - tst r8, #0x20
10791079 mov r10, #0x22000000
1080 - ldreq r6, val_80100db0
 1080+ ldr r6, val_80100db0
10811081 orr r10, r10, #0x10000
1082 - streq r6, [r4]
 1082+ str r6, [r4]
10831083 add r11, r10, #0x25800
10841084 mov r0, #-1
10851085 fillbuff:
@@ -1101,7 +1101,7 @@
11021102 bl sendlcdd
11031103 add r0, r9, #0x11
11041104 bl sendlcdc
1105 - sub r0, r9, #0xc1
 1105+ add r0, r9, #0x3f
11061106 bl sendlcdd
11071107 add r0, r9, #0x12
11081108 bl sendlcdc