297
297
/* temporary store r3, r9 into r1, r10 */ ;\
298
298
l.addi r1,r3,0x0 ;\
299
299
l.addi r10,r9,0x0 ;\
300
- /* the string referenced by r3 must be low enough */ ;\
300
+ LOAD_SYMBOL_2_GPR(r9,_string_unhandled_exception) ;\
301
+ tophys (r3,r9) ;\
301
302
l.jal _emergency_print ;\
302
- l.ori r3,r0,lo(_string_unhandled_exception) ;\
303
+ l. nop ;\
303
304
l.mfspr r3,r0,SPR_NPC ;\
304
305
l.jal _emergency_print_nr ;\
305
- l.andi r3,r3,0x1f00 ;\
306
- /* the string referenced by r3 must be low enough */ ;\
306
+ l.andi r3,r3,0x1f00 ;\
307
+ LOAD_SYMBOL_2_GPR(r9,_string_epc_prefix) ;\
308
+ tophys (r3,r9) ;\
307
309
l.jal _emergency_print ;\
308
- l.ori r3,r0,lo(_string_epc_prefix) ;\
310
+ l. nop ;\
309
311
l.jal _emergency_print_nr ;\
310
- l.mfspr r3,r0,SPR_EPCR_BASE ;\
312
+ l.mfspr r3,r0,SPR_EPCR_BASE ;\
313
+ LOAD_SYMBOL_2_GPR(r9,_string_nl) ;\
314
+ tophys (r3,r9) ;\
311
315
l.jal _emergency_print ;\
312
- l.ori r3,r0,lo(_string_nl) ;\
316
+ l. nop ;\
313
317
/* end of printing */ ;\
314
318
l.addi r3,r1,0x0 ;\
315
319
l.addi r9,r10,0x0 ;\
@@ -1530,65 +1534,99 @@ trampoline_out:
1530
1534
l.jr r9
1531
1535
l.nop
1532
1536
1533
-
1534
1537
/*
1535
- * DSCR: prints a string referenced by r3.
1538
+ * DESC: Prints ASCII character stored in r7
1536
1539
*
1537
- * PRMS: r3 - address of the first character of null
1538
- * terminated string to be printed
1540
+ * PRMS: r7 - a 32-bit value with an ASCII character in the first byte
1541
+ * position.
1539
1542
*
1540
- * PREQ: UART at UART_BASE_ADD has to be initialized
1543
+ * PREQ: The UART at UART_BASE_ADD has to be initialized
1541
1544
*
1542
- * POST: caller should be aware that r3, r9 are changed
1545
+ * POST: internally used but restores:
1546
+ * r4 - to store UART_BASE_ADD
1547
+ * r5 - for loading OFF_TXFULL / THRE,TEMT
1548
+ * r6 - for storing bitmask (SERIAL_8250)
1543
1549
*/
1544
- ENTRY(_emergency_print )
1550
+ ENTRY(_emergency_putc )
1545
1551
EMERGENCY_PRINT_STORE_GPR4
1546
1552
EMERGENCY_PRINT_STORE_GPR5
1547
1553
EMERGENCY_PRINT_STORE_GPR6
1548
- EMERGENCY_PRINT_STORE_GPR7
1549
- 2:
1550
- l.lbz r7,0 (r3)
1551
- l.sfeq r7,r0
1552
- l.bf 9f
1553
- l.nop
1554
1554
1555
- // putc:
1556
1555
l.movhi r4,hi(UART_BASE_ADD)
1556
+ l.ori r4,r4,lo(UART_BASE_ADD)
1557
1557
1558
+ #if defined(CONFIG_SERIAL_8250)
1559
+ /* Check UART LSR THRE (hold) bit */
1558
1560
l.addi r6,r0,0x20
1559
1561
1: l.lbz r5,5 (r4)
1560
1562
l.andi r5,r5,0x20
1561
1563
l.sfeq r5,r6
1562
1564
l.bnf 1b
1563
- l.nop
1565
+ l.nop
1564
1566
1567
+ /* Write character */
1565
1568
l.sb 0 (r4),r7
1566
1569
1570
+ /* Check UART LSR THRE|TEMT (hold, empty) bits */
1567
1571
l.addi r6,r0,0x60
1568
1572
1: l.lbz r5,5 (r4)
1569
1573
l.andi r5,r5,0x60
1570
1574
l.sfeq r5,r6
1571
1575
l.bnf 1b
1572
- l.nop
1576
+ l.nop
1577
+ #endif
1578
+ EMERGENCY_PRINT_LOAD_GPR6
1579
+ EMERGENCY_PRINT_LOAD_GPR5
1580
+ EMERGENCY_PRINT_LOAD_GPR4
1581
+ l.jr r9
1582
+ l.nop
1583
+
1584
+ /*
1585
+ * DSCR: prints a string referenced by r3.
1586
+ *
1587
+ * PRMS: r3 - address of the first character of null
1588
+ * terminated string to be printed
1589
+ *
1590
+ * PREQ: UART at UART_BASE_ADD has to be initialized
1591
+ *
1592
+ * POST: caller should be aware that r3, r9 are changed
1593
+ */
1594
+ ENTRY(_emergency_print)
1595
+ EMERGENCY_PRINT_STORE_GPR7
1596
+ EMERGENCY_PRINT_STORE_GPR9
1597
+
1598
+ /* Load character to r7, check for null terminator */
1599
+ 2: l.lbz r7,0 (r3)
1600
+ l.sfeqi r7,0x0
1601
+ l.bf 9f
1602
+ l.nop
1603
+
1604
+ l.jal _emergency_putc
1605
+ l.nop
1573
1606
1574
1607
/* next character */
1575
1608
l.j 2b
1576
- l.addi r3,r3,0x1
1609
+ l.addi r3,r3,0x1
1577
1610
1578
1611
9:
1612
+ EMERGENCY_PRINT_LOAD_GPR9
1579
1613
EMERGENCY_PRINT_LOAD_GPR7
1580
- EMERGENCY_PRINT_LOAD_GPR6
1581
- EMERGENCY_PRINT_LOAD_GPR5
1582
- EMERGENCY_PRINT_LOAD_GPR4
1583
1614
l.jr r9
1584
- l.nop
1615
+ l.nop
1585
1616
1617
+ /*
1618
+ * DSCR: prints a number in r3 in hex.
1619
+ *
1620
+ * PRMS: r3 - a 32-bit unsigned integer
1621
+ *
1622
+ * PREQ: UART at UART_BASE_ADD has to be initialized
1623
+ *
1624
+ * POST: caller should be aware that r3, r9 are changed
1625
+ */
1586
1626
ENTRY(_emergency_print_nr)
1587
- EMERGENCY_PRINT_STORE_GPR4
1588
- EMERGENCY_PRINT_STORE_GPR5
1589
- EMERGENCY_PRINT_STORE_GPR6
1590
1627
EMERGENCY_PRINT_STORE_GPR7
1591
1628
EMERGENCY_PRINT_STORE_GPR8
1629
+ EMERGENCY_PRINT_STORE_GPR9
1592
1630
1593
1631
l.addi r8,r0,32 // shift register
1594
1632
@@ -1600,58 +1638,39 @@ ENTRY(_emergency_print_nr)
1600
1638
/* don't skip the last zero if number == 0x0 */
1601
1639
l.sfeqi r8,0x4
1602
1640
l.bf 2f
1603
- l.nop
1641
+ l.nop
1604
1642
1605
1643
l.sfeq r7,r0
1606
1644
l.bf 1b
1607
- l.nop
1645
+ l.nop
1608
1646
1609
1647
2:
1610
1648
l.srl r7,r3,r8
1611
1649
1612
1650
l.andi r7,r7,0xf
1613
1651
l.sflts r8,r0
1614
- l.bf 9f
1652
+ l.bf 9f
1615
1653
1654
+ /* Numbers greater than 9 translate to a-f */
1616
1655
l.sfgtui r7,0x9
1617
1656
l.bnf 8f
1618
- l.nop
1657
+ l.nop
1619
1658
l.addi r7,r7,0x27
1620
1659
1621
- 8:
1622
- l.addi r7,r7,0x30
1623
- // putc:
1624
- l.movhi r4,hi(UART_BASE_ADD)
1625
-
1626
- l.addi r6,r0,0x20
1627
- 1: l.lbz r5,5 (r4)
1628
- l.andi r5,r5,0x20
1629
- l.sfeq r5,r6
1630
- l.bnf 1b
1631
- l.nop
1632
-
1633
- l.sb 0 (r4),r7
1634
-
1635
- l.addi r6,r0,0x60
1636
- 1: l.lbz r5,5 (r4)
1637
- l.andi r5,r5,0x60
1638
- l.sfeq r5,r6
1639
- l.bnf 1b
1640
- l.nop
1660
+ /* Convert to ascii and output character */
1661
+ 8: l.jal _emergency_putc
1662
+ l.addi r7,r7,0x30
1641
1663
1642
1664
/* next character */
1643
1665
l.j 2b
1644
1666
l.addi r8,r8,-0x4
1645
1667
1646
1668
9:
1669
+ EMERGENCY_PRINT_LOAD_GPR9
1647
1670
EMERGENCY_PRINT_LOAD_GPR8
1648
1671
EMERGENCY_PRINT_LOAD_GPR7
1649
- EMERGENCY_PRINT_LOAD_GPR6
1650
- EMERGENCY_PRINT_LOAD_GPR5
1651
- EMERGENCY_PRINT_LOAD_GPR4
1652
1672
l.jr r9
1653
- l.nop
1654
-
1673
+ l.nop
1655
1674
1656
1675
/*
1657
1676
* This should be used for debugging only.
@@ -1676,7 +1695,9 @@ ENTRY(_emergency_print_nr)
1676
1695
1677
1696
ENTRY(_early_uart_init)
1678
1697
l.movhi r3,hi(UART_BASE_ADD)
1698
+ l.ori r3,r3,lo(UART_BASE_ADD)
1679
1699
1700
+ #if defined(CONFIG_SERIAL_8250)
1680
1701
l.addi r4,r0,0x7
1681
1702
l.sb 0x2 (r3),r4
1682
1703
@@ -1694,9 +1715,10 @@ ENTRY(_early_uart_init)
1694
1715
l.addi r4,r0,((UART_DIVISOR) & 0x000000ff )
1695
1716
l.sb UART_DLL(r3),r4
1696
1717
l.sb 0x3 (r3),r5
1718
+ #endif
1697
1719
1698
1720
l.jr r9
1699
- l.nop
1721
+ l.nop
1700
1722
1701
1723
.align 0x1000
1702
1724
.global _secondary_evbar
@@ -1711,13 +1733,13 @@ _secondary_evbar:
1711
1733
1712
1734
.section .rodata
1713
1735
_string_unhandled_exception:
1714
- .string "\n\rRunarunaround : Unhandled exception 0x\0"
1736
+ .string "\r\nRunarunaround : Unhandled exception 0x\0"
1715
1737
1716
1738
_string_epc_prefix:
1717
1739
.string ": EPC=0x\0"
1718
1740
1719
1741
_string_nl:
1720
- .string "\n\r \0"
1742
+ .string "\r\n \0"
1721
1743
1722
1744
1723
1745
/* ========================================[ page aligned structures ]=== */
0 commit comments