coreboot
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
March 2010
- 61 participants
- 434 discussions
1. Remove warnings and multiple blank lines.
2. Mahogany uses GPIO9 to detect 80-pin IDE cable.
Signed-off-by: Zheng Bao <zheng.bao(a)amd.com>
Throw my last patch away.
Index: src/mainboard/amd/mahogany_fam10/Kconfig
===================================================================
--- src/mainboard/amd/mahogany_fam10/Kconfig (revision 5287)
+++ src/mainboard/amd/mahogany_fam10/Kconfig (working copy)
@@ -117,7 +117,7 @@
config ACPI_SSDTX_NUM
int
- default 31
+ default 0
depends on BOARD_AMD_MAHOGANY_FAM10
config MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID
Index: src/mainboard/amd/mahogany_fam10/acpi_tables.c
===================================================================
--- src/mainboard/amd/mahogany_fam10/acpi_tables.c (revision 5287)
+++ src/mainboard/amd/mahogany_fam10/acpi_tables.c (working copy)
@@ -92,7 +92,8 @@
extern void get_bus_conf(void);
extern void update_ssdt(void *ssdt);
-
+/* not tested yet. */
+#if CONFIG_ACPI_SSDTX_NUM >= 1
static void update_ssdtx(void *ssdtx, int i)
{
u8 *PCI;
@@ -115,6 +116,7 @@
/* FIXME: need to update the GSI id in the ssdtx too */
}
+#endif
unsigned long write_acpi_tables(unsigned long start)
{
@@ -129,10 +131,11 @@
acpi_facs_t *facs;
acpi_header_t *dsdt;
acpi_header_t *ssdt;
+#if CONFIG_ACPI_SSDTX_NUM >= 1
acpi_header_t *ssdtx;
acpi_header_t const *p;
-
int i;
+#endif
get_bus_conf(); //it will get sblk, pci1234, hcdn, and sbdn
@@ -204,7 +207,7 @@
printk(BIOS_DEBUG, "ACPI: * SSDT for PState at %lx\n",
current);
current = acpi_add_ssdt_pstates(rsdp, current);
-#if 0 //CONFIG_ACPI_SSDTX_NUM >= 1
+#if CONFIG_ACPI_SSDTX_NUM >= 1
/* same htio, but different possition? We may have to copy,
change HCIN, and recalculate the checknum and add_table */
Index: src/mainboard/amd/mahogany_fam10/romstage.c
===================================================================
--- src/mainboard/amd/mahogany_fam10/romstage.c (revision 5287)
+++ src/mainboard/amd/mahogany_fam10/romstage.c (working copy)
@@ -298,4 +298,3 @@
post_cache_as_ram(); // BSP switch stack to ram, copy then
execute LB.
post_code(0x43); // Should never see this post code.
}
-
Index: src/mainboard/amd/mahogany_fam10/devicetree.cb
===================================================================
--- src/mainboard/amd/mahogany_fam10/devicetree.cb (revision 5287)
+++ src/mainboard/amd/mahogany_fam10/devicetree.cb (working copy)
@@ -143,5 +143,3 @@
# end
end
-
-
Index: src/mainboard/amd/mahogany_fam10/mainboard.c
===================================================================
--- src/mainboard/amd/mahogany_fam10/mainboard.c (revision 5287)
+++ src/mainboard/amd/mahogany_fam10/mainboard.c (working copy)
@@ -25,6 +25,7 @@
#include <cpu/x86/msr.h>
#include <cpu/amd/mtrr.h>
#include <device/pci_def.h>
+#include <arch/coreboot_tables.h>
#include <../southbridge/amd/sb700/sb700.h>
#include "chip.h"
@@ -35,6 +36,9 @@
uint64_t uma_memory_base, uma_memory_size;
+void set_pcie_dereset(void);
+void set_pcie_reset(void);
+
/*
* Mahogany uses GPIO 6 as PCIe slot reset, GPIO4 as GFX slot reset. We
need to
* pull it up before training the slot.
@@ -65,12 +69,13 @@
pci_write_config16(sm_dev, 0xA8, word);
}
+#if 0 /* not tested yet. */
/********************************************************
-* mahogany uses SB700 GPIO8 to detect IDE_DMA66.
-* IDE_DMA66 is routed to GPIO 8. So we read Gpio 8 to
+* mahogany uses SB700 GPIO9 to detect IDE_DMA66.
+* IDE_DMA66 is routed to GPIO 9. So we read Gpio 9 to
* get the cable type, 40 pin or 80 pin?
********************************************************/
-static void get_ide_dma66()
+static void get_ide_dma66(void)
{
u8 byte;
/*u32 sm_dev, ide_dev; */
@@ -79,27 +84,29 @@
sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
byte = pci_read_config8(sm_dev, 0xA9);
- byte |= (1 << 4); /* Set Gpio8 as input */
+ byte |= (1 << 5); /* Set Gpio8 as input */
pci_write_config8(sm_dev, 0xA9, byte);
ide_dev = dev_find_slot(0, PCI_DEVFN(0x14, 1));
byte = pci_read_config8(ide_dev, 0x56);
byte &= ~(7 << 0);
- if ((1 << 4) & pci_read_config8(sm_dev, 0xAA))
+ if ((1 << 5) & pci_read_config8(sm_dev, 0xAA))
byte |= 2 << 0; /* mode 2 */
else
byte |= 5 << 0; /* mode 5 */
pci_write_config8(ide_dev, 0x56, byte);
}
+#endif /* get_ide_dma66() */
/*************************************************
* enable the dedicated function in mahogany board.
* This function called early than rs780_enable.
*************************************************/
-void mahogany_enable(device_t dev)
+static void mahogany_enable(device_t dev)
{
- struct mainboard_config *mainboard =
- (struct mainboard_config *)dev->chip_info;
+ /* Leave it for furture use. */
+ /* struct mainboard_config *mainboard =
+ (struct mainboard_config *)dev->chip_info; */
printk(BIOS_INFO, "Mainboard MAHOGANY Enable. dev=0x%p\n", dev);
@@ -158,6 +165,7 @@
lb_add_memory_range(mem, LB_MEM_RESERVED, uma_memory_base,
uma_memory_size);
#endif
+ return 0;
}
struct chip_operations mainboard_ops = {
Index: src/mainboard/amd/mahogany/devicetree.cb
===================================================================
--- src/mainboard/amd/mahogany/devicetree.cb (revision 5287)
+++ src/mainboard/amd/mahogany/devicetree.cb (working copy)
@@ -121,4 +121,3 @@
end #northbridge/amd/amdk8
end #pci_domain
end #northbridge/amd/amdk8/root_complex
-
Index: src/mainboard/amd/mahogany/acpi_tables.c
===================================================================
--- src/mainboard/amd/mahogany/acpi_tables.c (revision 5287)
+++ src/mainboard/amd/mahogany/acpi_tables.c (working copy)
@@ -101,6 +101,7 @@
extern void get_bus_conf(void);
+#if CONFIG_ACPI_SSDTX_NUM >= 1
static void update_ssdtx(void *ssdtx, int i)
{
uint8_t *PCI;
@@ -122,6 +123,7 @@
/* FIXME: need to update the GSI id in the ssdtx too */
}
+#endif
unsigned long acpi_fill_ssdt_generator(unsigned long current, const
char *oem_table_id) {
k8acpi_write_vars();
@@ -140,6 +142,11 @@
acpi_facs_t *facs;
acpi_header_t *dsdt;
acpi_header_t *ssdt;
+#if CONFIG_ACPI_SSDTX_NUM >= 1
+ acpi_header_t *ssdtx;
+ acpi_header_t const *p;
+ int i;
+#endif
get_bus_conf(); /* it will get sblk, pci1234, hcdn, and
sbdn */
Index: src/mainboard/amd/mahogany/mainboard.c
===================================================================
--- src/mainboard/amd/mahogany/mainboard.c (revision 5287)
+++ src/mainboard/amd/mahogany/mainboard.c (working copy)
@@ -25,6 +25,7 @@
#include <cpu/x86/msr.h>
#include <cpu/amd/mtrr.h>
#include <device/pci_def.h>
+#include <arch/coreboot_tables.h>
#include <../southbridge/amd/sb700/sb700.h>
#include "chip.h"
@@ -35,6 +36,9 @@
uint64_t uma_memory_base, uma_memory_size;
+void set_pcie_dereset(void);
+void set_pcie_reset(void);
+
/*
* Mahogany uses GPIO 6 as PCIe slot reset, GPIO4 as GFX slot reset. We
need to
* pull it up before training the slot.
@@ -65,12 +69,13 @@
pci_write_config16(sm_dev, 0xA8, word);
}
+#if 0 /* not tested yet */
/********************************************************
-* mahogany uses SB700 GPIO8 to detect IDE_DMA66.
-* IDE_DMA66 is routed to GPIO 8. So we read Gpio 8 to
+* mahogany uses SB700 GPIO9 to detect IDE_DMA66.
+* IDE_DMA66 is routed to GPIO 9. So we read Gpio 9 to
* get the cable type, 40 pin or 80 pin?
********************************************************/
-static void get_ide_dma66()
+static void get_ide_dma66(void)
{
u8 byte;
/*u32 sm_dev, ide_dev; */
@@ -79,27 +84,29 @@
sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
byte = pci_read_config8(sm_dev, 0xA9);
- byte |= (1 << 4); /* Set Gpio8 as input */
+ byte |= (1 << 5); /* Set Gpio9 as input */
pci_write_config8(sm_dev, 0xA9, byte);
ide_dev = dev_find_slot(0, PCI_DEVFN(0x14, 1));
byte = pci_read_config8(ide_dev, 0x56);
byte &= ~(7 << 0);
- if ((1 << 4) & pci_read_config8(sm_dev, 0xAA))
+ if ((1 << 5) & pci_read_config8(sm_dev, 0xAA))
byte |= 2 << 0; /* mode 2 */
else
byte |= 5 << 0; /* mode 5 */
pci_write_config8(ide_dev, 0x56, byte);
}
+#endif /* get_ide_dma66 */
/*************************************************
* enable the dedicated function in mahogany board.
* This function called early than rs780_enable.
*************************************************/
-void mahogany_enable(device_t dev)
+static void mahogany_enable(device_t dev)
{
- struct mainboard_config *mainboard =
- (struct mainboard_config *)dev->chip_info;
+ /* Leave it for future. */
+ /* struct mainboard_config *mainboard =
+ (struct mainboard_config *)dev->chip_info;*/
printk(BIOS_INFO, "Mainboard MAHOGANY Enable. dev=0x%p\n", dev);
@@ -158,6 +165,7 @@
lb_add_memory_range(mem, LB_MEM_RESERVED, uma_memory_base,
uma_memory_size);
#endif
+ return 0;
}
struct chip_operations mainboard_ops = {
Index: src/mainboard/amd/mahogany/get_bus_conf.c
===================================================================
--- src/mainboard/amd/mahogany/get_bus_conf.c (revision 5287)
+++ src/mainboard/amd/mahogany/get_bus_conf.c (working copy)
@@ -63,6 +63,8 @@
static u32 get_bus_conf_done = 0;
+void get_bus_conf(void);
+
void get_bus_conf(void)
{
u32 apicid_base;
2
2
[commit] r5300 - in trunk/src/mainboard/amd: mahogany mahogany_fam10
by repository service March 26, 2010
by repository service March 26, 2010
March 26, 2010
Author: zbao
Date: Fri Mar 26 02:43:30 2010
New Revision: 5300
URL: https://tracker.coreboot.org/trac/coreboot/changeset/5300
Log:
1. Remove warnings and multiple blank lines.
2. Mahogany uses GPIO9 to detect 80-pin IDE cable.
Signed-off-by: Zheng Bao <zheng.bao(a)amd.com>
Acked-by: Patrick Georgi <patrick.georgi(a)coresystems.de>
Modified:
trunk/src/mainboard/amd/mahogany/acpi_tables.c
trunk/src/mainboard/amd/mahogany/devicetree.cb
trunk/src/mainboard/amd/mahogany/get_bus_conf.c
trunk/src/mainboard/amd/mahogany/mainboard.c
trunk/src/mainboard/amd/mahogany_fam10/Kconfig
trunk/src/mainboard/amd/mahogany_fam10/acpi_tables.c
trunk/src/mainboard/amd/mahogany_fam10/devicetree.cb
trunk/src/mainboard/amd/mahogany_fam10/mainboard.c
trunk/src/mainboard/amd/mahogany_fam10/romstage.c
Modified: trunk/src/mainboard/amd/mahogany/acpi_tables.c
==============================================================================
--- trunk/src/mainboard/amd/mahogany/acpi_tables.c Thu Mar 25 23:17:36 2010 (r5299)
+++ trunk/src/mainboard/amd/mahogany/acpi_tables.c Fri Mar 26 02:43:30 2010 (r5300)
@@ -101,6 +101,7 @@
extern void get_bus_conf(void);
+#if CONFIG_ACPI_SSDTX_NUM >= 1
static void update_ssdtx(void *ssdtx, int i)
{
uint8_t *PCI;
@@ -122,6 +123,7 @@
/* FIXME: need to update the GSI id in the ssdtx too */
}
+#endif
unsigned long acpi_fill_ssdt_generator(unsigned long current, const char *oem_table_id) {
k8acpi_write_vars();
@@ -140,6 +142,11 @@
acpi_facs_t *facs;
acpi_header_t *dsdt;
acpi_header_t *ssdt;
+#if CONFIG_ACPI_SSDTX_NUM >= 1
+ acpi_header_t *ssdtx;
+ acpi_header_t const *p;
+ int i;
+#endif
get_bus_conf(); /* it will get sblk, pci1234, hcdn, and sbdn */
Modified: trunk/src/mainboard/amd/mahogany/devicetree.cb
==============================================================================
--- trunk/src/mainboard/amd/mahogany/devicetree.cb Thu Mar 25 23:17:36 2010 (r5299)
+++ trunk/src/mainboard/amd/mahogany/devicetree.cb Fri Mar 26 02:43:30 2010 (r5300)
@@ -121,4 +121,3 @@
end #northbridge/amd/amdk8
end #pci_domain
end #northbridge/amd/amdk8/root_complex
-
Modified: trunk/src/mainboard/amd/mahogany/get_bus_conf.c
==============================================================================
--- trunk/src/mainboard/amd/mahogany/get_bus_conf.c Thu Mar 25 23:17:36 2010 (r5299)
+++ trunk/src/mainboard/amd/mahogany/get_bus_conf.c Fri Mar 26 02:43:30 2010 (r5300)
@@ -63,6 +63,8 @@
static u32 get_bus_conf_done = 0;
+void get_bus_conf(void);
+
void get_bus_conf(void)
{
u32 apicid_base;
Modified: trunk/src/mainboard/amd/mahogany/mainboard.c
==============================================================================
--- trunk/src/mainboard/amd/mahogany/mainboard.c Thu Mar 25 23:17:36 2010 (r5299)
+++ trunk/src/mainboard/amd/mahogany/mainboard.c Fri Mar 26 02:43:30 2010 (r5300)
@@ -25,6 +25,7 @@
#include <cpu/x86/msr.h>
#include <cpu/amd/mtrr.h>
#include <device/pci_def.h>
+#include <arch/coreboot_tables.h>
#include <../southbridge/amd/sb700/sb700.h>
#include "chip.h"
@@ -35,6 +36,9 @@
uint64_t uma_memory_base, uma_memory_size;
+void set_pcie_dereset(void);
+void set_pcie_reset(void);
+
/*
* Mahogany uses GPIO 6 as PCIe slot reset, GPIO4 as GFX slot reset. We need to
* pull it up before training the slot.
@@ -65,12 +69,13 @@
pci_write_config16(sm_dev, 0xA8, word);
}
+#if 0 /* not tested yet */
/********************************************************
-* mahogany uses SB700 GPIO8 to detect IDE_DMA66.
-* IDE_DMA66 is routed to GPIO 8. So we read Gpio 8 to
+* mahogany uses SB700 GPIO9 to detect IDE_DMA66.
+* IDE_DMA66 is routed to GPIO 9. So we read Gpio 9 to
* get the cable type, 40 pin or 80 pin?
********************************************************/
-static void get_ide_dma66()
+static void get_ide_dma66(void)
{
u8 byte;
/*u32 sm_dev, ide_dev; */
@@ -79,27 +84,29 @@
sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
byte = pci_read_config8(sm_dev, 0xA9);
- byte |= (1 << 4); /* Set Gpio8 as input */
+ byte |= (1 << 5); /* Set Gpio9 as input */
pci_write_config8(sm_dev, 0xA9, byte);
ide_dev = dev_find_slot(0, PCI_DEVFN(0x14, 1));
byte = pci_read_config8(ide_dev, 0x56);
byte &= ~(7 << 0);
- if ((1 << 4) & pci_read_config8(sm_dev, 0xAA))
+ if ((1 << 5) & pci_read_config8(sm_dev, 0xAA))
byte |= 2 << 0; /* mode 2 */
else
byte |= 5 << 0; /* mode 5 */
pci_write_config8(ide_dev, 0x56, byte);
}
+#endif /* get_ide_dma66 */
/*************************************************
* enable the dedicated function in mahogany board.
* This function called early than rs780_enable.
*************************************************/
-void mahogany_enable(device_t dev)
+static void mahogany_enable(device_t dev)
{
- struct mainboard_config *mainboard =
- (struct mainboard_config *)dev->chip_info;
+ /* Leave it for future. */
+ /* struct mainboard_config *mainboard =
+ (struct mainboard_config *)dev->chip_info;*/
printk(BIOS_INFO, "Mainboard MAHOGANY Enable. dev=0x%p\n", dev);
@@ -158,6 +165,7 @@
lb_add_memory_range(mem, LB_MEM_RESERVED, uma_memory_base,
uma_memory_size);
#endif
+ return 0;
}
struct chip_operations mainboard_ops = {
Modified: trunk/src/mainboard/amd/mahogany_fam10/Kconfig
==============================================================================
--- trunk/src/mainboard/amd/mahogany_fam10/Kconfig Thu Mar 25 23:17:36 2010 (r5299)
+++ trunk/src/mainboard/amd/mahogany_fam10/Kconfig Fri Mar 26 02:43:30 2010 (r5300)
@@ -117,7 +117,7 @@
config ACPI_SSDTX_NUM
int
- default 31
+ default 0
depends on BOARD_AMD_MAHOGANY_FAM10
config MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID
Modified: trunk/src/mainboard/amd/mahogany_fam10/acpi_tables.c
==============================================================================
--- trunk/src/mainboard/amd/mahogany_fam10/acpi_tables.c Thu Mar 25 23:17:36 2010 (r5299)
+++ trunk/src/mainboard/amd/mahogany_fam10/acpi_tables.c Fri Mar 26 02:43:30 2010 (r5300)
@@ -92,7 +92,8 @@
extern void get_bus_conf(void);
extern void update_ssdt(void *ssdt);
-
+/* not tested yet. */
+#if CONFIG_ACPI_SSDTX_NUM >= 1
static void update_ssdtx(void *ssdtx, int i)
{
u8 *PCI;
@@ -115,6 +116,7 @@
/* FIXME: need to update the GSI id in the ssdtx too */
}
+#endif
unsigned long write_acpi_tables(unsigned long start)
{
@@ -129,10 +131,11 @@
acpi_facs_t *facs;
acpi_header_t *dsdt;
acpi_header_t *ssdt;
+#if CONFIG_ACPI_SSDTX_NUM >= 1
acpi_header_t *ssdtx;
acpi_header_t const *p;
-
int i;
+#endif
get_bus_conf(); //it will get sblk, pci1234, hcdn, and sbdn
@@ -204,7 +207,7 @@
printk(BIOS_DEBUG, "ACPI: * SSDT for PState at %lx\n", current);
current = acpi_add_ssdt_pstates(rsdp, current);
-#if 0 //CONFIG_ACPI_SSDTX_NUM >= 1
+#if CONFIG_ACPI_SSDTX_NUM >= 1
/* same htio, but different possition? We may have to copy,
change HCIN, and recalculate the checknum and add_table */
Modified: trunk/src/mainboard/amd/mahogany_fam10/devicetree.cb
==============================================================================
--- trunk/src/mainboard/amd/mahogany_fam10/devicetree.cb Thu Mar 25 23:17:36 2010 (r5299)
+++ trunk/src/mainboard/amd/mahogany_fam10/devicetree.cb Fri Mar 26 02:43:30 2010 (r5300)
@@ -143,5 +143,3 @@
# end
end
-
-
Modified: trunk/src/mainboard/amd/mahogany_fam10/mainboard.c
==============================================================================
--- trunk/src/mainboard/amd/mahogany_fam10/mainboard.c Thu Mar 25 23:17:36 2010 (r5299)
+++ trunk/src/mainboard/amd/mahogany_fam10/mainboard.c Fri Mar 26 02:43:30 2010 (r5300)
@@ -25,6 +25,7 @@
#include <cpu/x86/msr.h>
#include <cpu/amd/mtrr.h>
#include <device/pci_def.h>
+#include <arch/coreboot_tables.h>
#include <../southbridge/amd/sb700/sb700.h>
#include "chip.h"
@@ -35,6 +36,9 @@
uint64_t uma_memory_base, uma_memory_size;
+void set_pcie_dereset(void);
+void set_pcie_reset(void);
+
/*
* Mahogany uses GPIO 6 as PCIe slot reset, GPIO4 as GFX slot reset. We need to
* pull it up before training the slot.
@@ -65,12 +69,13 @@
pci_write_config16(sm_dev, 0xA8, word);
}
+#if 0 /* not tested yet. */
/********************************************************
-* mahogany uses SB700 GPIO8 to detect IDE_DMA66.
-* IDE_DMA66 is routed to GPIO 8. So we read Gpio 8 to
+* mahogany uses SB700 GPIO9 to detect IDE_DMA66.
+* IDE_DMA66 is routed to GPIO 9. So we read Gpio 9 to
* get the cable type, 40 pin or 80 pin?
********************************************************/
-static void get_ide_dma66()
+static void get_ide_dma66(void)
{
u8 byte;
/*u32 sm_dev, ide_dev; */
@@ -79,27 +84,29 @@
sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
byte = pci_read_config8(sm_dev, 0xA9);
- byte |= (1 << 4); /* Set Gpio8 as input */
+ byte |= (1 << 5); /* Set Gpio9 as input */
pci_write_config8(sm_dev, 0xA9, byte);
ide_dev = dev_find_slot(0, PCI_DEVFN(0x14, 1));
byte = pci_read_config8(ide_dev, 0x56);
byte &= ~(7 << 0);
- if ((1 << 4) & pci_read_config8(sm_dev, 0xAA))
+ if ((1 << 5) & pci_read_config8(sm_dev, 0xAA))
byte |= 2 << 0; /* mode 2 */
else
byte |= 5 << 0; /* mode 5 */
pci_write_config8(ide_dev, 0x56, byte);
}
+#endif /* get_ide_dma66() */
/*************************************************
* enable the dedicated function in mahogany board.
* This function called early than rs780_enable.
*************************************************/
-void mahogany_enable(device_t dev)
+static void mahogany_enable(device_t dev)
{
- struct mainboard_config *mainboard =
- (struct mainboard_config *)dev->chip_info;
+ /* Leave it for furture use. */
+ /* struct mainboard_config *mainboard =
+ (struct mainboard_config *)dev->chip_info; */
printk(BIOS_INFO, "Mainboard MAHOGANY Enable. dev=0x%p\n", dev);
@@ -158,6 +165,7 @@
lb_add_memory_range(mem, LB_MEM_RESERVED, uma_memory_base,
uma_memory_size);
#endif
+ return 0;
}
struct chip_operations mainboard_ops = {
Modified: trunk/src/mainboard/amd/mahogany_fam10/romstage.c
==============================================================================
--- trunk/src/mainboard/amd/mahogany_fam10/romstage.c Thu Mar 25 23:17:36 2010 (r5299)
+++ trunk/src/mainboard/amd/mahogany_fam10/romstage.c Fri Mar 26 02:43:30 2010 (r5300)
@@ -298,4 +298,3 @@
post_cache_as_ram(); // BSP switch stack to ram, copy then execute LB.
post_code(0x43); // Should never see this post code.
}
-
1
0
[commit] r5299 - in trunk/payloads/libpayload: drivers drivers/usb include/usb
by repository service March 25, 2010
by repository service March 25, 2010
March 25, 2010
Author: stepan
Date: Thu Mar 25 23:17:36 2010
New Revision: 5299
URL: https://tracker.coreboot.org/trac/coreboot/changeset/5299
Log:
USB updates from our internal tree
- support MMC2 devices
- make usb stack more solid
- drop some unused functions
- fix lowspeed/speed naming
- add support for "quirks"
- improve usbhid driver
Signed-off-by: Stefan Reinauer <stepan(a)coresystems.de>
Acked-by: Joseph Smith <joe(a)settoplinux.org>
Added:
trunk/payloads/libpayload/drivers/usb/quirks.c
Modified:
trunk/payloads/libpayload/drivers/Makefile.inc
trunk/payloads/libpayload/drivers/usb/uhci.c
trunk/payloads/libpayload/drivers/usb/uhci.h
trunk/payloads/libpayload/drivers/usb/uhci_rh.c
trunk/payloads/libpayload/drivers/usb/usb.c
trunk/payloads/libpayload/drivers/usb/usbhid.c
trunk/payloads/libpayload/drivers/usb/usbhub.c
trunk/payloads/libpayload/drivers/usb/usbinit.c
trunk/payloads/libpayload/drivers/usb/usbmsc.c
trunk/payloads/libpayload/include/usb/usb.h
trunk/payloads/libpayload/include/usb/usbmsc.h
Modified: trunk/payloads/libpayload/drivers/Makefile.inc
==============================================================================
--- trunk/payloads/libpayload/drivers/Makefile.inc Thu Mar 25 23:15:19 2010 (r5298)
+++ trunk/payloads/libpayload/drivers/Makefile.inc Thu Mar 25 23:17:36 2010 (r5299)
@@ -56,6 +56,7 @@
TARGETS-$(CONFIG_USB) += drivers/usb/usbinit.o
TARGETS-$(CONFIG_USB) += drivers/usb/usb.o
TARGETS-$(CONFIG_USB) += drivers/usb/usb_dev.o
+TARGETS-$(CONFIG_USB) += drivers/usb/quirks.o
TARGETS-$(CONFIG_USB_HUB) += drivers/usb/usbhub.o
TARGETS-$(CONFIG_USB_UHCI) += drivers/usb/uhci.o
TARGETS-$(CONFIG_USB_UHCI) += drivers/usb/uhci_rh.o
Added: trunk/payloads/libpayload/drivers/usb/quirks.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/payloads/libpayload/drivers/usb/quirks.c Thu Mar 25 23:17:36 2010 (r5299)
@@ -0,0 +1,88 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2010 coresystems GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+//#define USB_DEBUG
+
+#include <libpayload-config.h>
+#include <usb/usb.h>
+
+typedef struct {
+ u16 vendor, device;
+ u32 quirks;
+ int interface;
+} usb_quirks_t;
+
+// IDs without a quirk don't need to be mentioned in this list
+// but some are here for easier testing.
+
+usb_quirks_t usb_quirks[] = {
+ /* Working chips,... remove before next release */
+ { 0x3538, 0x0054, USB_QUIRK_NONE, 0 }, // PQI 1GB
+ { 0x13fd, 0x0841, USB_QUIRK_NONE, 0 }, // Samsung SE-S084
+
+ /* Silence the warning for known devices with more
+ * than one interface
+ */
+ { 0x1267, 0x0103, USB_QUIRK_NONE, 1 }, // Keyboard Trust KB-1800S
+ { 0x0a12, 0x0001, USB_QUIRK_NONE, 1 }, // Bluetooth Allnet ALL1575
+
+ /* Currently unsupported, possibly interesting devices:
+ * FTDI serial: device 0x0403:0x6001 is USB 1.10 (class ff)
+ * UPEK TouchChip: device 0x147e:0x2016 is USB 1.0 (class ff)
+ */
+};
+
+u32 usb_quirk_check(u16 vendor, u16 device)
+{
+ int i;
+ for (i = 0; i < ARRAY_SIZE(usb_quirks); i++) {
+ if ((usb_quirks[i].vendor == vendor) &&
+ (usb_quirks[i].device == device)) {
+ debug("USB quirks enabled: %08x\n",
+ usb_quirks[i].quirks);
+ return usb_quirks[i].quirks;
+ }
+ }
+
+ return USB_QUIRK_NONE;
+}
+
+int usb_interface_check(u16 vendor, u16 device)
+{
+ int i;
+ for (i = 0; i < ARRAY_SIZE(usb_quirks); i++) {
+ if ((usb_quirks[i].vendor == vendor) &&
+ (usb_quirks[i].device == device)) {
+ return usb_quirks[i].interface;
+ }
+ }
+
+ return 0;
+}
+
Modified: trunk/payloads/libpayload/drivers/usb/uhci.c
==============================================================================
--- trunk/payloads/libpayload/drivers/usb/uhci.c Thu Mar 25 23:15:19 2010 (r5298)
+++ trunk/payloads/libpayload/drivers/usb/uhci.c Thu Mar 25 23:17:36 2010 (r5299)
@@ -1,7 +1,7 @@
/*
* This file is part of the libpayload project.
*
- * Copyright (C) 2008 coresystems GmbH
+ * Copyright (C) 2008-2010 coresystems GmbH
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,6 +27,8 @@
* SUCH DAMAGE.
*/
+//#define USB_DEBUG
+
#include <usb/usb.h>
#include "uhci.h"
#include <arch/virtual.h>
@@ -35,8 +37,6 @@
static void uhci_stop (hci_t *controller);
static void uhci_reset (hci_t *controller);
static void uhci_shutdown (hci_t *controller);
-static int uhci_packet (usbdev_t *dev, int endp, int pid, int toggle,
- int length, u8 *data);
static int uhci_bulk (endpoint_t *ep, int size, u8 *data, int finalize);
static int uhci_control (usbdev_t *dev, pid_t dir, int drlen, void *devreq,
int dalen, u8 *data);
@@ -128,6 +128,8 @@
uhci_init (pcidev_t addr)
{
int i;
+ u16 reg16;
+
hci_t *controller = new_controller ();
if (!controller)
@@ -141,7 +143,6 @@
controller->stop = uhci_stop;
controller->reset = uhci_reset;
controller->shutdown = uhci_shutdown;
- controller->packet = uhci_packet;
controller->bulk = uhci_bulk;
controller->control = uhci_control;
controller->create_intr_queue = uhci_create_intr_queue;
@@ -160,7 +161,9 @@
uhci_stop (controller);
mdelay (1);
uhci_reg_write16 (controller, USBSTS, 0x3f);
- pci_write_config32 (controller->bus_address, 0xc0, 0x8f00);
+ reg16 = pci_read_config16(controller->bus_address, 0xc0);
+ reg16 &= 0xdf80;
+ pci_write_config16 (controller->bus_address, 0xc0, reg16);
UHCI_INST (controller)->framelistptr = memalign (0x1000, 1024 * sizeof (flistp_t *)); /* 4kb aligned to 4kb */
if (! UHCI_INST (controller)->framelistptr)
@@ -277,18 +280,6 @@
0) ? 0 : GET_TD (phys_to_virt (qh->elementlinkptr.ptr));
}
-static void
-wait_for_completed_td (hci_t *controller, td_t *td)
-{
- int timeout = 10000;
- while ((td->status_active == 1)
- && ((uhci_reg_read16 (controller, USBSTS) & 2) == 0)
- && (timeout-- > 0)) {
- uhci_reg_mask16 (controller, USBSTS, ~0, 0); // clear resettable registers
- udelay (10);
- }
-}
-
static int
maxlen (int size)
{
@@ -331,7 +322,7 @@
tds[0].maxlen = maxlen (drlen);
tds[0].counter = 3;
tds[0].data_toggle = 0;
- tds[0].lowspeed = dev->lowspeed;
+ tds[0].lowspeed = dev->speed;
tds[0].bufptr = virt_to_phys (devreq);
tds[0].status_active = 1;
@@ -343,7 +334,7 @@
tds[i].maxlen = maxlen (min (mlen, dalen));
tds[i].counter = 3;
tds[i].data_toggle = toggle;
- tds[i].lowspeed = dev->lowspeed;
+ tds[i].lowspeed = dev->speed;
tds[i].bufptr = virt_to_phys (data);
tds[i].status_active = 1;
toggle ^= 1;
@@ -357,7 +348,8 @@
tds[count].maxlen = maxlen (0);
tds[count].counter = 0; /* as per linux 2.4.10 */
tds[count].data_toggle = 1;
- tds[count].lowspeed = dev->lowspeed, tds[count].bufptr = 0;
+ tds[count].lowspeed = dev->speed;
+ tds[count].bufptr = 0;
tds[count].status_active = 1;
UHCI_INST (dev->controller)->qh_data->elementlinkptr.ptr =
virt_to_phys (tds);
@@ -378,48 +370,6 @@
return result;
}
-static int
-uhci_packet (usbdev_t *dev, int endp, int pid, int toggle, int length,
- unsigned char *data)
-{
- static td_t *td = 0;
- if (td == 0)
- td = memalign (16, sizeof (td_t));
-
- memset (td, 0, sizeof (td_t));
- td->ptr = 0;
- td->terminate = 1;
- td->queue_head = 0;
-
- td->pid = pid;
- td->dev_addr = dev->address;
- td->endp = endp & 0xf;
- td->maxlen = maxlen (length);
- if (pid == SETUP)
- td->counter = 3;
- else
- td->counter = 0;
- td->data_toggle = toggle & 1;
- td->lowspeed = dev->lowspeed;
- td->bufptr = virt_to_phys (data);
-
- td->status_active = 1;
-
- UHCI_INST (dev->controller)->qh_data->elementlinkptr.ptr =
- virt_to_phys (td);
- UHCI_INST (dev->controller)->qh_data->elementlinkptr.queue_head = 0;
- UHCI_INST (dev->controller)->qh_data->elementlinkptr.terminate = 0;
- wait_for_completed_td (dev->controller, td);
- if ((td->status & 0x7f) == 0) {
- //printf("successfully sent a %x packet to %x.%x\n",pid, dev->address,endp);
- // success
- return 0;
- } else {
- td_dump (td);
- return 1;
- }
-}
-
static td_t *
create_schedule (int numpackets)
{
@@ -454,7 +404,7 @@
else
td->counter = 0;
td->data_toggle = *toggle & 1;
- td->lowspeed = ep->dev->lowspeed;
+ td->lowspeed = ep->dev->speed;
td->bufptr = virt_to_phys (data);
td->status_active = 1;
@@ -484,7 +434,7 @@
{
int maxpsize = ep->maxpacketsize;
if (maxpsize == 0)
- fatal ("MaxPacketSize == 0!!!");
+ usb_fatal ("MaxPacketSize == 0!!!");
int numpackets = (size + maxpsize - 1 + finalize) / maxpsize;
if (numpackets == 0)
return 0;
@@ -498,6 +448,7 @@
size -= maxpsize;
}
if (run_schedule (ep->dev, tds) == 1) {
+ debug("Stalled. Trying to clean up.\n");
clear_stall (ep);
free (tds);
return 1;
@@ -557,7 +508,7 @@
tds[i].maxlen = maxlen (reqsize);
tds[i].counter = 0;
tds[i].data_toggle = ep->toggle & 1;
- tds[i].lowspeed = ep->dev->lowspeed;
+ tds[i].lowspeed = ep->dev->speed;
tds[i].bufptr = virt_to_phys (data);
tds[i].status_active = 1;
ep->toggle ^= 1;
Modified: trunk/payloads/libpayload/drivers/usb/uhci.h
==============================================================================
--- trunk/payloads/libpayload/drivers/usb/uhci.h Thu Mar 25 23:15:19 2010 (r5298)
+++ trunk/payloads/libpayload/drivers/usb/uhci.h Thu Mar 25 23:17:36 2010 (r5299)
@@ -1,7 +1,7 @@
/*
* This file is part of the libpayload project.
*
- * Copyright (C) 2008 coresystems GmbH
+ * Copyright (C) 2008-2010 coresystems GmbH
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Modified: trunk/payloads/libpayload/drivers/usb/uhci_rh.c
==============================================================================
--- trunk/payloads/libpayload/drivers/usb/uhci_rh.c Thu Mar 25 23:15:19 2010 (r5298)
+++ trunk/payloads/libpayload/drivers/usb/uhci_rh.c Thu Mar 25 23:17:36 2010 (r5299)
@@ -1,7 +1,7 @@
/*
* This file is part of the libpayload project.
*
- * Copyright (C) 2008 coresystems GmbH
+ * Copyright (C) 2008-2010 coresystems GmbH
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,6 +27,8 @@
* SUCH DAMAGE.
*/
+//#define USB_DEBUG
+
#include <libpayload.h>
#include "uhci.h"
@@ -43,8 +45,13 @@
hci_t *controller = dev->controller;
if (port == 1)
port = PORTSC1;
- else
+ else if (port == 2)
port = PORTSC2;
+ else {
+ printf("Invalid port %d\n", port);
+ return;
+ }
+
uhci_reg_mask16 (controller, port, ~(1 << 12), 0); /* wakeup */
uhci_reg_mask16 (controller, port, ~0, 1 << 9); /* reset */
@@ -85,8 +92,10 @@
} else if (port == 2) {
portsc = PORTSC2;
offset = 1;
- } else
+ } else {
+ printf("Invalid port %d\n", port);
return;
+ }
int devno = RH_INST (dev)->port[offset];
if ((dev->controller->devices[devno] != 0) && (devno != -1)) {
usb_detach_device(dev->controller, devno);
@@ -94,16 +103,17 @@
}
uhci_reg_mask16 (dev->controller, portsc, ~0, (1 << 3) | (1 << 2)); // clear port state change, enable port
+ mdelay(100); // wait for signal to stabilize
+
if ((uhci_reg_read16 (dev->controller, portsc) & 1) != 0) {
// device attached
uhci_rh_disable_port (dev, port);
uhci_rh_enable_port (dev, port);
- int lowspeed =
- (uhci_reg_read16 (dev->controller, portsc) >> 8) & 1;
+ int speed = ((uhci_reg_read16 (dev->controller, portsc) >> 8) & 1);
- RH_INST (dev)->port[offset] = usb_attach_device(dev->controller, dev->address, portsc, lowspeed);
+ RH_INST (dev)->port[offset] = usb_attach_device(dev->controller, dev->address, portsc, speed);
}
}
@@ -114,21 +124,30 @@
stored = (RH_INST (dev)->port[0] == -1);
real = ((uhci_reg_read16 (dev->controller, PORTSC1) & 1) == 0);
- if (stored != real)
+ if (stored != real) {
+ debug("change on port 1\n");
return 1;
+ }
stored = (RH_INST (dev)->port[1] == -1);
real = ((uhci_reg_read16 (dev->controller, PORTSC2) & 1) == 0);
- if (stored != real)
+ if (stored != real) {
+ debug("change on port 2\n");
return 2;
+ }
+
+ // maybe detach+attach happened between two scans?
-// maybe detach+attach happened between two scans?
- if ((uhci_reg_read16 (dev->controller, PORTSC1) & 2) > 0)
+ if ((uhci_reg_read16 (dev->controller, PORTSC1) & 2) > 0) {
+ debug("possibly re-attached on port 1\n");
return 1;
- if ((uhci_reg_read16 (dev->controller, PORTSC2) & 2) > 0)
+ }
+ if ((uhci_reg_read16 (dev->controller, PORTSC2) & 2) > 0) {
+ debug("possibly re-attached on port 2\n");
return 2;
+ }
-// no change
+ // no change
return -1;
}
Modified: trunk/payloads/libpayload/drivers/usb/usb.c
==============================================================================
--- trunk/payloads/libpayload/drivers/usb/usb.c Thu Mar 25 23:15:19 2010 (r5298)
+++ trunk/payloads/libpayload/drivers/usb/usb.c Thu Mar 25 23:17:36 2010 (r5299)
@@ -1,7 +1,7 @@
/*
* This file is part of the libpayload project.
*
- * Copyright (C) 2008 coresystems GmbH
+ * Copyright (C) 2008-2010 coresystems GmbH
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,6 +27,8 @@
* SUCH DAMAGE.
*/
+//#define USB_DEBUG
+
#include <libpayload-config.h>
#include <usb/usb.h>
@@ -69,7 +71,7 @@
* Polls all hubs on all USB controllers, to find out about device changes
*/
void
-usb_poll ()
+usb_poll (void)
{
if (usb_hcs == 0)
return;
@@ -78,8 +80,7 @@
int i;
for (i = 0; i < 128; i++) {
if (controller->devices[i] != 0) {
- controller->devices[i]->poll (controller->
- devices[i]);
+ controller->devices[i]->poll (controller->devices[i]);
}
}
controller = controller->next;
@@ -150,7 +151,7 @@
if (descType == 1) {
device_descriptor_t *dd = (device_descriptor_t *) buf;
- printf ("maxPacketSize0: %x\n", dd->bMaxPacketSize0);
+ debug ("maxPacketSize0: %x\n", dd->bMaxPacketSize0);
if (dd->bMaxPacketSize0 != 0)
dev->endpoints[0].maxpacketsize = dd->bMaxPacketSize0;
}
@@ -204,6 +205,7 @@
dr.wIndex = endp;
dr.wLength = 0;
dev->controller->control (dev, OUT, sizeof (dr), &dr, 0, 0);
+ ep->toggle = 0;
return 0;
}
@@ -221,7 +223,7 @@
}
int
-set_address (hci_t *controller, int lowspeed)
+set_address (hci_t *controller, int speed)
{
int adr = get_free_address (controller); // address to set
dev_req_t dr;
@@ -241,7 +243,7 @@
usbdev_t *dev = controller->devices[adr];
// dummy values for registering the address
dev->address = 0;
- dev->lowspeed = lowspeed;
+ dev->speed = speed;
dev->endpoints[0].dev = dev;
dev->endpoints[0].endpoint = 0;
dev->endpoints[0].maxpacketsize = 8;
@@ -254,26 +256,25 @@
}
mdelay (50);
dev->address = adr;
- dev->descriptor =
- get_descriptor (dev,
- gen_bmRequestType (device_to_host,
- standard_type, dev_recp),
- 1, 0, 0);
+ dev->descriptor = get_descriptor (dev, gen_bmRequestType
+ (device_to_host, standard_type, dev_recp), 1, 0, 0);
dd = (device_descriptor_t *) dev->descriptor;
- printf ("device version: %x.%x\n", dd->bcdUSB >> 8,
- dd->bcdUSB & 0xff);
- printf ("device has %x configurations\n", dd->bNumConfigurations);
+
+ printf ("device 0x%04x:0x%04x is USB %x.%x ",
+ dd->idVendor, dd->idProduct,
+ dd->bcdUSB >> 8, dd->bcdUSB & 0xff);
+ dev->quirks = usb_quirk_check(dd->idVendor, dd->idProduct);
+
+ debug ("\ndevice has %x configurations\n", dd->bNumConfigurations);
if (dd->bNumConfigurations == 0) {
/* device isn't usable */
- printf ("no usable configuration!\n");
+ printf ("... no usable configuration!\n");
dev->address = 0;
return -1;
}
- dev->configuration =
- get_descriptor (dev,
- gen_bmRequestType (device_to_host,
- standard_type, dev_recp),
- 2, 0, 0);
+
+ dev->configuration = get_descriptor (dev, gen_bmRequestType
+ (device_to_host, standard_type, dev_recp), 2, 0, 0);
cd = (configuration_descriptor_t *) dev->configuration;
set_configuration (dev);
interface_descriptor_t *interface =
@@ -282,24 +283,33 @@
int i;
int num = cd->bNumInterfaces;
interface_descriptor_t *current = interface;
- printf ("device has %x interfaces\n", num);
- if (num>1)
- printf ("NOTICE: This driver defaults to using the first interface.\n"
- "This might be the wrong choice and lead to limited functionality\n"
- "of the device. Please report such a case to coreboot(a)coreboot.org\n"
- "as you might be the first.\n");
- /* we limit to the first interface, as there was no need to
- implement something else for the time being. If you need
- it, see the SetInterface and GetInterface functions in
- the USB specification, and adapt appropriately. */
- num = (num > 1) ? 1 : num;
+ debug ("device has %x interfaces\n", num);
+ if (num > 1) {
+ int interfaces = usb_interface_check(dd->idVendor, dd->idProduct);
+ if (interfaces) {
+ /* Well known device, don't warn */
+ num = interfaces;
+ } else {
+
+ printf ("\nNOTICE: This driver defaults to using the first interface.\n"
+ "This might be the wrong choice and lead to limited functionality\n"
+ "of the device. Please report such a case to coreboot(a)coreboot.org\n"
+ "as you might be the first.\n");
+ /* we limit to the first interface, as there was no need to
+ * implement something else for the time being. If you need
+ * it, see the SetInterface and GetInterface functions in
+ * the USB specification, and adapt appropriately.
+ */
+ num = (num > 1) ? 1 : num;
+ }
+ }
for (i = 0; i < num; i++) {
int j;
- printf (" #%x has %x endpoints, interface %x:%x, protocol %x\n", current->bInterfaceNumber, current->bNumEndpoints, current->bInterfaceClass, current->bInterfaceSubClass, current->bInterfaceProtocol);
+ debug (" #%x has %x endpoints, interface %x:%x, protocol %x\n",
+ current->bInterfaceNumber, current->bNumEndpoints, current->bInterfaceClass, current->bInterfaceSubClass, current->bInterfaceProtocol);
endpoint_descriptor_t *endp =
(endpoint_descriptor_t *) (((char *) current)
- +
- current->bLength);
+ + current->bLength);
if (interface->bInterfaceClass == 0x3)
endp = (endpoint_descriptor_t *) (((char *) endp) + ((char *) endp)[0]); // ignore HID descriptor
memset (dev->endpoints, 0, sizeof (dev->endpoints));
@@ -309,11 +319,12 @@
dev->endpoints[0].direction = SETUP;
dev->endpoints[0].type = CONTROL;
for (j = 1; j <= current->bNumEndpoints; j++) {
- static const char *transfertypes[4] =
- { "control", "isochronous", "bulk",
- "interrupt"
+#ifdef USB_DEBUG
+ static const char *transfertypes[4] = {
+ "control", "isochronous", "bulk", "interrupt"
};
- printf (" #%x: Endpoint %x (%s), max packet size %x, type %s\n", j, endp->bEndpointAddress & 0x7f, ((endp->bEndpointAddress & 0x80) != 0) ? "in" : "out", endp->wMaxPacketSize, transfertypes[endp->bmAttributes]);
+ debug (" #%x: Endpoint %x (%s), max packet size %x, type %s\n", j, endp->bEndpointAddress & 0x7f, ((endp->bEndpointAddress & 0x80) != 0) ? "in" : "out", endp->wMaxPacketSize, transfertypes[endp->bmAttributes]);
+#endif
endpoint_t *ep =
&dev->endpoints[dev->num_endp++];
ep->dev = dev;
@@ -330,36 +341,94 @@
current = (interface_descriptor_t *) endp;
}
}
+
int class = dd->bDeviceClass;
if (class == 0)
class = interface->bInterfaceClass;
- enum { hid_device = 0x3, msc_device = 0x8, hub_device = 0x9 };
-
- printf ("device of class %x found\n", class);
- if (class == hub_device) {
- printf ("hub found\n");
-#ifdef CONFIG_USB_HUB
- controller->devices[adr]->init = usb_hub_init;
-#else
- printf ("support not compiled in\n");
-#endif
- }
- if (class == hid_device) {
- printf ("HID found\n");
+ enum {
+ audio_device = 0x01,
+ comm_device = 0x02,
+ hid_device = 0x03,
+ physical_device = 0x05,
+ imaging_device = 0x06,
+ printer_device = 0x07,
+ msc_device = 0x08,
+ hub_device = 0x09,
+ cdc_device = 0x0a,
+ ccid_device = 0x0b,
+ security_device = 0x0d,
+ video_device = 0x0e,
+ healthcare_device = 0x0f,
+ diagnostic_device = 0xdc,
+ wireless_device = 0xe0,
+ misc_device = 0xef,
+ };
+
+ switch (class) {
+ case audio_device:
+ printf("(Audio)\n");
+ break;
+ case comm_device:
+ printf("(Communication)\n");
+ break;
+ case hid_device:
+ printf ("(HID)\n");
#ifdef CONFIG_USB_HID
controller->devices[adr]->init = usb_hid_init;
#else
- printf ("support not compiled in\n");
+ printf ("NOTICE: USB HID support not compiled in\n");
#endif
- }
- if (class == msc_device) {
- printf ("MSC found\n");
+ break;
+ case physical_device:
+ printf("(Physical)\n");
+ break;
+ case imaging_device:
+ printf("(Camera)\n");
+ break;
+ case printer_device:
+ printf("(Printer)\n");
+ break;
+ case msc_device:
+ printf ("(MSC)\n");
#ifdef CONFIG_USB_MSC
controller->devices[adr]->init = usb_msc_init;
#else
- printf ("support not compiled in\n");
+ printf ("NOTICE: USB MSC support not compiled in\n");
+#endif
+ break;
+ case hub_device:
+ printf ("(Hub)\n");
+#ifdef CONFIG_USB_HUB
+ controller->devices[adr]->init = usb_hub_init;
+#else
+ printf ("NOTICE: USB hub support not compiled in.\n");
#endif
+ break;
+ case cdc_device:
+ printf("(CDC)\n");
+ break;
+ case ccid_device:
+ printf ("(Smart Card / CCID)\n");
+ break;
+ case security_device:
+ printf("(Content Security)\n");
+ break;
+ case video_device:
+ printf("(Video)\n");
+ break;
+ case healthcare_device:
+ printf("(Healthcare)\n");
+ break;
+ case diagnostic_device:
+ printf("(Diagnostic)\n");
+ break;
+ case wireless_device:
+ printf("(Wireless)\n");
+ break;
+ default:
+ printf ("(unsupported class %x)\n", class);
+ break;
}
return adr;
}
@@ -373,10 +442,11 @@
}
int
-usb_attach_device(hci_t *controller, int hubaddress, int port, int lowspeed)
+usb_attach_device(hci_t *controller, int hubaddress, int port, int speed)
{
- printf ("%sspeed device\n", (lowspeed == 1) ? "low" : "full");
- int newdev = set_address (controller, lowspeed);
+ static const char* speeds[] = { "full", "low", "high" };
+ printf ("%sspeed device\n", (speed <= 2) ? speeds[speed] : "invalid value - no");
+ int newdev = set_address (controller, speed);
if (newdev == -1)
return -1;
usbdev_t *newdev_t = controller->devices[newdev];
Modified: trunk/payloads/libpayload/drivers/usb/usbhid.c
==============================================================================
--- trunk/payloads/libpayload/drivers/usb/usbhid.c Thu Mar 25 23:15:19 2010 (r5298)
+++ trunk/payloads/libpayload/drivers/usb/usbhid.c Thu Mar 25 23:17:36 2010 (r5299)
@@ -1,7 +1,7 @@
/*
* This file is part of the libpayload project.
*
- * Copyright (C) 2008 coresystems GmbH
+ * Copyright (C) 2008-2010 coresystems GmbH
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,6 +27,8 @@
* SUCH DAMAGE.
*/
+// #define USB_DEBUG
+
#include <usb/usb.h>
#include <curses.h>
@@ -35,7 +37,9 @@
enum { hid_boot_proto_none = 0, hid_boot_proto_keyboard =
1, hid_boot_proto_mouse = 2
};
+#ifdef USB_DEBUG
static const char *boot_protos[3] = { "(none)", "keyboard", "mouse" };
+#endif
enum { GET_REPORT = 0x1, GET_IDLE = 0x2, GET_PROTOCOL = 0x3, SET_REPORT =
0x9, SET_IDLE = 0xa, SET_PROTOCOL = 0xb
};
@@ -48,72 +52,295 @@
typedef struct {
void* queue;
+ hid_descriptor_t *descriptor;
} usbhid_inst_t;
#define HID_INST(dev) ((usbhid_inst_t*)(dev)->data)
-/* buffer is global to all keyboard drivers */
-int count;
-short keybuffer[16];
+/* keybuffer is global to all USB keyboards */
+static int keycount;
+#define KEYBOARD_BUFFER_SIZE 16
+static short keybuffer[KEYBOARD_BUFFER_SIZE];
+
+char *countries[36][2] = {
+ { "not supported", "us" },
+ { "Arabic", "ae" },
+ { "Belgian", "be" },
+ { "Canadian-Bilingual", "ca" },
+ { "Canadian-French", "ca" },
+ { "Czech Republic", "cz" },
+ { "Danish", "dk" },
+ { "Finnish", "fi" },
+ { "French", "fr" },
+ { "German", "de" },
+ { "Greek", "gr" },
+ { "Hebrew", "il" },
+ { "Hungary", "hu" },
+ { "International (ISO)", "iso" },
+ { "Italian", "it" },
+ { "Japan (Katakana)", "jp" },
+ { "Korean", "us" },
+ { "Latin American", "us" },
+ { "Netherlands/Dutch", "nl" },
+ { "Norwegian", "no" },
+ { "Persian (Farsi)", "ir" },
+ { "Poland", "pl" },
+ { "Portuguese", "pt" },
+ { "Russia", "ru" },
+ { "Slovakia", "sl" },
+ { "Spanish", "es" },
+ { "Swedish", "se" },
+ { "Swiss/French", "ch" },
+ { "Swiss/German", "ch" },
+ { "Switzerland", "ch" },
+ { "Taiwan", "tw" },
+ { "Turkish-Q", "tr" },
+ { "UK", "uk" },
+ { "US", "us" },
+ { "Yugoslavia", "yu" },
+ { "Turkish-F", "tr" },
+ /* 36 - 255: Reserved */
+};
+
+
+
+struct layout_maps {
+ char *country;
+ short map[4][0x80];
+};
+
+static struct layout_maps *map;
-int keypress;
-short keymap[256] = {
+static struct layout_maps keyboard_layouts[] = {
+// #ifdef CONFIG_PC_KEYBOARD_LAYOUT_US
+{ .country = "us", .map = {
+ { /* No modifier */
-1, -1, -1, -1, 'a', 'b', 'c', 'd',
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
-
+ /* 0x10 */
'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z', '1', '2',
-
+ /* 0x20 */
'3', '4', '5', '6', '7', '8', '9', '0',
'\n', '\e', '\b', '\t', ' ', '-', '=', '[',
-
+ /* 0x30 */
']', '\\', -1, ';', '\'', '`', ',', '.',
- '/', -1, KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5), KEY_F(6),
-
- KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10), KEY_F(11), KEY_F(12), -1, -1,
+ '/', -1 /* CapsLk */, KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5), KEY_F(6),
+ /* 0x40 */
+ KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10), KEY_F(11), KEY_F(12), KEY_PRINT, -1 /* ScrLk */,
+ KEY_BREAK, KEY_IC, KEY_HOME, KEY_PPAGE, KEY_DC, KEY_END, KEY_NPAGE, KEY_RIGHT,
+ /* 50 */
+ KEY_LEFT, KEY_DOWN, KEY_UP, -1 /*NumLck*/, '/', '*', '-' /* = ? */, '+',
+ KEY_ENTER, KEY_END, KEY_DOWN, KEY_NPAGE, KEY_LEFT, -1, KEY_RIGHT, KEY_HOME,
+ /* 60 */
+ KEY_UP, KEY_PPAGE, -1, KEY_DC, -1 /* < > | */, -1 /* Win Key Right */, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ /* 70 */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ },
+ { /* Shift modifier */
+ -1, -1, -1, -1, 'A', 'B', 'C', 'D',
+ 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
+ /* 0x10 */
+ 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
+ 'U', 'V', 'W', 'X', 'Y', 'Z', '!', '@',
+ /* 0x20 */
+ '#', '$', '%', '^', '&', '*', '(', ')',
+ '\n', '\e', '\b', '\t', ' ', '-', '=', '[',
+ /* 0x30 */
+ ']', '\\', -1, ':', '\'', '`', ',', '.',
+ '/', -1 /* CapsLk */, KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5), KEY_F(6),
+ /* 0x40 */
+ KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10), KEY_F(11), KEY_F(12), KEY_PRINT, -1 /* ScrLk */,
+ KEY_BREAK, KEY_IC, KEY_HOME, KEY_PPAGE, KEY_DC, KEY_END, KEY_NPAGE, KEY_RIGHT,
+ /* 50 */
+ KEY_LEFT, KEY_DOWN, KEY_UP, -1 /*NumLck*/, '/', '*', '-' /* = ? */, '+',
+ KEY_ENTER, KEY_END, KEY_DOWN, KEY_NPAGE, KEY_LEFT, -1, KEY_RIGHT, KEY_HOME,
+ /* 60 */
+ KEY_UP, KEY_PPAGE, -1, KEY_DC, -1 /* < > | */, -1 /* Win Key Right */, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ /* 70 */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ },
+ { /* Alt */
+ -1, -1, -1, -1, 'a', 'b', 'c', 'd',
+ 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
+ /* 0x10 */
+ 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
+ 'u', 'v', 'w', 'x', 'y', 'z', '1', '2',
+ /* 0x20 */
+ '3', '4', '5', '6', '7', '8', '9', '0',
+ '\n', '\e', '\b', '\t', ' ', '-', '=', '[',
+ /* 0x30 */
+ ']', '\\', -1, ';', '\'', '`', ',', '.',
+ '/', -1 /* CapsLk */, KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5), KEY_F(6),
+ /* 0x40 */
+ KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10), KEY_F(11), KEY_F(12), KEY_PRINT, -1 /* ScrLk */,
+ KEY_BREAK, KEY_IC, KEY_HOME, KEY_PPAGE, KEY_DC, KEY_END, KEY_NPAGE, KEY_RIGHT,
+ /* 50 */
+ KEY_LEFT, KEY_DOWN, KEY_UP, -1 /*NumLck*/, '/', '*', '-' /* = ? */, '+',
+ KEY_ENTER, KEY_END, KEY_DOWN, KEY_NPAGE, KEY_LEFT, -1, KEY_RIGHT, KEY_HOME,
+ /* 60 */
+ KEY_UP, KEY_PPAGE, -1, KEY_DC, -1 /* < > | */, -1 /* Win Key Right */, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ /* 70 */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ },
+ { /* Shift+Alt modifier */
+ -1, -1, -1, -1, 'A', 'B', 'C', 'D',
+ 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
+ /* 0x10 */
+ 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
+ 'U', 'V', 'W', 'X', 'Y', 'Z', '!', '@',
+ /* 0x20 */
+ '#', '$', '%', '^', '&', '*', '(', ')',
+ '\n', '\e', '\b', '\t', ' ', '-', '=', '[',
+ /* 0x30 */
+ ']', '\\', -1, ':', '\'', '`', ',', '.',
+ '/', -1 /* CapsLk */, KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5), KEY_F(6),
+ /* 0x40 */
+ KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10), KEY_F(11), KEY_F(12), KEY_PRINT, -1 /* ScrLk */,
+ KEY_BREAK, KEY_IC, KEY_HOME, KEY_PPAGE, KEY_DC, KEY_END, KEY_NPAGE, KEY_RIGHT,
+ /* 50 */
+ KEY_LEFT, KEY_DOWN, KEY_UP, -1 /*NumLck*/, '/', '*', '-' /* = ? */, '+',
+ KEY_ENTER, KEY_END, KEY_DOWN, KEY_NPAGE, KEY_LEFT, -1, KEY_RIGHT, KEY_HOME,
+ /* 60 */
+ KEY_UP, KEY_PPAGE, -1, KEY_DC, -1 /* < > | */, -1 /* Win Key Right */, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-/* 50 */
- -1, -1, -1, -1, -1, '*', '-', '+',
- -1, KEY_END, KEY_DOWN, KEY_NPAGE, KEY_LEFT, -1, KEY_RIGHT, KEY_HOME,
-
- KEY_UP, KEY_PPAGE, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
-
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ /* 70 */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ }
+}},
+//#endif
};
+#define MOD_SHIFT (1 << 0)
+#define MOD_ALT (1 << 1)
+#define MOD_CTRL (1 << 2)
+
+static void usb_hid_keyboard_queue(int ch) {
+ /* ignore key presses if buffer full */
+ if (keycount < KEYBOARD_BUFFER_SIZE)
+ keybuffer[keycount++] = ch;
+}
-static void
-usb_hid_poll (usbdev_t *dev)
+typedef union {
+ struct {
+ u8 modifiers;
+ u8 repeats;
+ u8 keys[6];
+ };
+ u8 buffer[8];
+} usb_hid_keyboard_event_t;
+
+#define KEYBOARD_REPEAT_MS 30
+#define INITIAL_REPEAT_DELAY 10
+#define REPEAT_DELAY 2
+
+static void
+usb_hid_process_keyboard_event(usb_hid_keyboard_event_t *current,
+ usb_hid_keyboard_event_t *previous)
{
- u8* buf;
- while ((buf=dev->controller->poll_intr_queue (HID_INST(dev)->queue))) {
- // FIXME: manage buf[0]=special keys, too
- int i;
- keypress = 0;
- for (i=2; i<9; i++) {
- if (buf[i] != 0)
- keypress = keymap[buf[i]];
- else
+ int i, keypress = 0, modifiers = 0;
+ static int lastkeypress = 0, repeat_delay = INITIAL_REPEAT_DELAY;
+
+ if (current->modifiers & 0x01) /* Left-Ctrl */ modifiers |= MOD_CTRL;
+ if (current->modifiers & 0x02) /* Left-Shift */ modifiers |= MOD_SHIFT;
+ if (current->modifiers & 0x04) /* Left-Alt */ modifiers |= MOD_ALT;
+ if (current->modifiers & 0x08) /* Left-GUI */ ;
+ if (current->modifiers & 0x10) /* Right-Ctrl */ modifiers |= MOD_CTRL;
+ if (current->modifiers & 0x20) /* Right-Shift */ modifiers |= MOD_SHIFT;
+ if (current->modifiers & 0x40) /* Right-AltGr */ modifiers |= MOD_ALT;
+ if (current->modifiers & 0x80) /* Right-GUI */ ;
+
+ if ((current->modifiers & 0x05) && ((current->keys[0] == 0x4c) ||
+ (current->keys[0]==0x63))) {
+ /* vulcan nerve pinch */
+ if (reset_handler)
+ reset_handler();
+ }
+
+ /* Did the event change at all? */
+ if (lastkeypress && !memcmp(current, previous, sizeof(usb_hid_keyboard_event_t))) {
+ /* No. Then it's a key repeat event. */
+ if (repeat_delay) {
+ repeat_delay--;
+ } else {
+ usb_hid_keyboard_queue(lastkeypress);
+ repeat_delay = REPEAT_DELAY;
+ }
+
+ return;
+ }
+
+ lastkeypress = 0;
+
+ for (i=0; i<6; i++) {
+ int j;
+ int skip = 0;
+ // No more keys? skip
+ if (current->keys[i] == 0)
+ return;
+
+ for (j=0; j<6; j++) {
+ if (current->keys[i] == previous->keys[j]) {
+ skip = 1;
break;
+ }
}
- if ((keypress == -1) && (buf[2] != 0)) {
- printf ("%x %x %x %x %x %x %x %x\n", buf[0], buf[1], buf[2],
- buf[3], buf[4], buf[5], buf[6], buf[7]);
+ if (skip)
+ continue;
+
+
+ /* Mask off MOD_CTRL */
+ keypress = map->map[modifiers & 0x03][current->keys[i]];
+
+ if (modifiers & MOD_CTRL) {
+ switch (keypress) {
+ case 'a' ... 'z':
+ keypress &= 0x1f;
+ break;
+ default:
+ continue;
+ }
}
- if (keypress != -1) {
- /* ignore key presses if buffer full */
- if (count < 16)
- keybuffer[count++] = keypress;
+
+ if (keypress == -1) {
+ /* Debug: Print unknown keys */
+ debug ("usbhid: <%x> %x [ %x %x %x %x %x %x ] %d\n",
+ current->modifiers, current->repeats,
+ current->keys[0], current->keys[1],
+ current->keys[2], current->keys[3],
+ current->keys[4], current->keys[5], i);
+
+ /* Unknown key? Try next one in the queue */
+ continue;
}
+
+ usb_hid_keyboard_queue(keypress);
+
+ /* Remember for authentic key repeat */
+ lastkeypress = keypress;
+ repeat_delay = INITIAL_REPEAT_DELAY;
+ }
+}
+
+static void
+usb_hid_poll (usbdev_t *dev)
+{
+ usb_hid_keyboard_event_t current;
+ static usb_hid_keyboard_event_t previous = {
+ .buffer = { 0, 0, 0, 0, 0, 0, 0, 0}
+ };
+ u8* buf;
+ while ((buf=dev->controller->poll_intr_queue (HID_INST(dev)->queue))) {
+ memcpy(¤t.buffer, buf, 8);
+ usb_hid_process_keyboard_event(¤t, &previous);
+ previous = current;
}
}
@@ -150,6 +377,30 @@
.getchar = usbhid_getchar
};
+
+int usb_hid_set_layout (char *country)
+{
+ /* FIXME should be per keyboard */
+ int i;
+
+ for (i=0; i<ARRAY_SIZE(keyboard_layouts); i++) {
+ if (strncmp(keyboard_layouts[i].country, country,
+ strlen(keyboard_layouts[i].country)))
+ continue;
+
+ /* Found, changing keyboard layout */
+ map = &keyboard_layouts[i];
+ printf(" Keyboard layout '%s'\n", map->country);
+ return 0;
+ }
+
+ printf("Keyboard layout '%s' not found, using '%s'\n",
+ country, map->country);
+
+ /* Nothing found, not changed */
+ return -1;
+}
+
void
usb_hid_init (usbdev_t *dev)
{
@@ -164,17 +415,34 @@
interface_descriptor_t *interface = (interface_descriptor_t*)(((char *) cd) + cd->bLength);
if (interface->bInterfaceSubClass == hid_subclass_boot) {
- printf (" supports boot interface..\n");
- printf (" it's a %s\n",
+ u8 countrycode;
+ debug (" supports boot interface..\n");
+ debug (" it's a %s\n",
boot_protos[interface->bInterfaceProtocol]);
- if (interface->bInterfaceProtocol == hid_boot_proto_keyboard) {
+ switch (interface->bInterfaceProtocol) {
+ case hid_boot_proto_keyboard:
dev->data = malloc (sizeof (usbhid_inst_t));
if (!dev->data)
usb_fatal("Not enough memory for USB HID device.\n");
- printf (" configuring...\n");
+ debug (" configuring...\n");
usb_hid_set_protocol(dev, interface, hid_proto_boot);
- usb_hid_set_idle(dev, interface, 0);
- printf (" activating...\n");
+ usb_hid_set_idle(dev, interface, KEYBOARD_REPEAT_MS);
+ debug (" activating...\n");
+
+ HID_INST (dev)->descriptor =
+ (hid_descriptor_t *)
+ get_descriptor(dev, gen_bmRequestType
+ (device_to_host, standard_type, iface_recp),
+ 0x21, 0, 0);
+ countrycode = HID_INST(dev)->descriptor->bCountryCode;
+ /* 35 countries defined: */
+ if (countrycode > 35)
+ countrycode = 0;
+ printf (" Keyboard has %s layout (country code %02x)\n",
+ countries[countrycode][0], countrycode);
+
+ /* Set keyboard layout accordingly */
+ usb_hid_set_layout(countries[countrycode][1]);
// only add here, because we only support boot-keyboard HID devices
dev->destroy = usb_hid_destroy;
@@ -189,24 +457,33 @@
continue;
break;
}
- printf (" found endpoint %x for interrupt-in\n", i);
+ debug (" found endpoint %x for interrupt-in\n", i);
/* 20 buffers of 8 bytes, for every 10 msecs */
HID_INST(dev)->queue = dev->controller->create_intr_queue (&dev->endpoints[i], 8, 20, 10);
- count = 0;
- printf (" configuration done.\n");
+ keycount = 0;
+ debug (" configuration done.\n");
+ break;
+ case hid_boot_proto_mouse:
+ printf("NOTICE: USB mice are not supported.\n");
+ break;
}
}
}
int usbhid_havechar (void)
{
- return (count != 0);
+ return (keycount != 0);
}
int usbhid_getchar (void)
{
- if (count == 0) return 0;
- short ret = keybuffer[0];
- memmove (keybuffer, keybuffer+1, --count);
- return ret;
+ short ret;
+
+ if (keycount == 0)
+ return 0;
+ ret = keybuffer[0];
+ memmove(keybuffer, keybuffer + 1, --keycount);
+
+ return (int)ret;
}
+
Modified: trunk/payloads/libpayload/drivers/usb/usbhub.c
==============================================================================
--- trunk/payloads/libpayload/drivers/usb/usbhub.c Thu Mar 25 23:15:19 2010 (r5298)
+++ trunk/payloads/libpayload/drivers/usb/usbhub.c Thu Mar 25 23:17:36 2010 (r5299)
@@ -1,7 +1,7 @@
/*
* This file is part of the libpayload project.
*
- * Copyright (C) 2008 coresystems GmbH
+ * Copyright (C) 2008-2010 coresystems GmbH
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -74,9 +74,15 @@
mdelay (20);
get_status (dev, port, DR_PORT, 4, buf);
- int lowspeed = (buf[0] >> 9) & 1;
- HUB_INST (dev)->ports[port] = usb_attach_device(dev->controller, dev->address, port, lowspeed);
+ /* bit 10 9
+ * 0 0 full speed
+ * 0 1 low speed
+ * 1 0 high speed
+ */
+ int speed = ((buf[0] >> 9) & 3) ;
+
+ HUB_INST (dev)->ports[port] = usb_attach_device(dev->controller, dev->address, port, speed);
}
static int
@@ -93,7 +99,7 @@
return port;
}
-// no change
+ // no change
return -1;
}
@@ -131,12 +137,8 @@
if (!dev->data)
usb_fatal("Not enough memory for USB hub.\n");
- HUB_INST (dev)->descriptor =
- (hub_descriptor_t *) get_descriptor (dev,
- gen_bmRequestType
- (device_to_host,
- class_type, dev_recp),
- 0x29, 0, 0);
+ HUB_INST (dev)->descriptor = (hub_descriptor_t *) get_descriptor(dev,
+ gen_bmRequestType(device_to_host, class_type, dev_recp), 0x29, 0, 0);
HUB_INST (dev)->num_ports = HUB_INST (dev)->descriptor->bNbrPorts;
HUB_INST (dev)->ports =
malloc (sizeof (int) * (HUB_INST (dev)->num_ports + 1));
Modified: trunk/payloads/libpayload/drivers/usb/usbinit.c
==============================================================================
--- trunk/payloads/libpayload/drivers/usb/usbinit.c Thu Mar 25 23:15:19 2010 (r5298)
+++ trunk/payloads/libpayload/drivers/usb/usbinit.c Thu Mar 25 23:17:36 2010 (r5299)
@@ -1,7 +1,7 @@
/*
* This file is part of the libpayload project.
*
- * Copyright (C) 2008 coresystems GmbH
+ * Copyright (C) 2008-2010 coresystems GmbH
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,6 +30,9 @@
#include <libpayload-config.h>
#include <usb/usb.h>
#include "uhci.h"
+//#include "ohci.h"
+//#include "ehci.h"
+//#include "xhci.h"
#include <usb/usbdisk.h>
/**
@@ -58,20 +61,19 @@
/* enable busmaster */
#define PCI_COMMAND 4
#define PCI_COMMAND_MASTER 4
- pci_write_config32 (addr, PCI_COMMAND,
- pci_read_config32 (addr,
- PCI_COMMAND) |
- PCI_COMMAND_MASTER);
-
if (devclass == 0xc03) {
+ u32 pci_command;
+
+ pci_command =pci_read_config32(addr, PCI_COMMAND);
+ pci_command |= PCI_COMMAND_MASTER;
+ pci_write_config32(addr, PCI_COMMAND, pci_command);
+
printf ("%02x:%02x.%x %04x:%04x.%d ", 0, dev, func,
pciid >> 16, pciid & 0xFFFF, func);
if (prog_if == 0) {
printf ("UHCI controller\n");
#ifdef CONFIG_USB_UHCI
uhci_init (addr);
- usb_poll ();
- usb_poll ();
#else
printf ("Not supported.\n");
#endif
@@ -79,7 +81,8 @@
if (prog_if == 0x10) {
printf ("OHCI controller\n");
#ifdef CONFIG_USB_OHCI
- // ohci_init(addr);
+ //ohci_init(addr);
+ printf ("Not supported.\n");
#else
printf ("Not supported.\n");
#endif
@@ -88,7 +91,18 @@
if (prog_if == 0x20) {
printf ("EHCI controller\n");
#ifdef CONFIG_USB_EHCI
- // ehci_init(addr);
+ //ehci_init(addr);
+ printf ("Not supported.\n");
+#else
+ printf ("Not supported.\n");
+#endif
+
+ }
+ if (prog_if == 0x30) {
+ printf ("XHCI controller\n");
+#ifdef CONFIG_USB_XHCI
+ //xhci_init(addr);
+ printf ("Not supported.\n");
#else
printf ("Not supported.\n");
#endif
@@ -106,10 +120,17 @@
usb_initialize (void)
{
int bus, dev, func;
+ /* EHCI is defined by standards to be at a
+ * higher function than the USB1 controllers.
+ * We don't want to init USB1 + devices just to
+ * "steal" those for USB2, so make sure USB2
+ * comes first.
+ */
for (bus = 0; bus < 256; bus++)
for (dev = 0; dev < 32; dev++)
- for (func = 0; func < 8; func++)
+ for (func = 7; func >= 0 ; func--)
usb_controller_initialize (bus, dev, func);
+ usb_poll();
return 0;
}
Modified: trunk/payloads/libpayload/drivers/usb/usbmsc.c
==============================================================================
--- trunk/payloads/libpayload/drivers/usb/usbmsc.c Thu Mar 25 23:15:19 2010 (r5298)
+++ trunk/payloads/libpayload/drivers/usb/usbmsc.c Thu Mar 25 23:17:36 2010 (r5299)
@@ -40,6 +40,7 @@
msc_subclass_sff8070i = 0x5,
msc_subclass_scsitrans = 0x6
};
+
static const char *msc_subclass_strings[7] = {
"(none)",
"RBC",
@@ -96,19 +97,20 @@
unsigned long bCBWCBLength:5;
unsigned long:3;
unsigned char CBWCB[31 - 15];
-} __attribute__ ((packed))
- cbw_t;
+} __attribute__ ((packed)) cbw_t;
+
+typedef struct {
+ unsigned int dCSWSignature;
+ unsigned int dCSWTag;
+ unsigned int dCSWDataResidue;
+ unsigned char bCSWStatus;
+} __attribute__ ((packed)) csw_t;
- typedef struct {
- unsigned int dCSWSignature;
- unsigned int dCSWTag;
- unsigned int dCSWDataResidue;
- unsigned char bCSWStatus;
- } __attribute__ ((packed))
- csw_t;
+static int
+request_sense (usbdev_t *dev);
- static void
- reset_transport (usbdev_t *dev)
+static void
+reset_transport (usbdev_t *dev)
{
dev_req_t dr;
memset (&dr, 0, sizeof (dr));
@@ -171,7 +173,8 @@
static void
get_csw (endpoint_t *ep, csw_t *csw)
{
- ep->dev->controller->bulk (ep, sizeof (csw_t), (u8 *) csw, 1);
+ if (ep->dev->controller->bulk (ep, sizeof (csw_t), (u8 *) csw, 1))
+ clear_stall (ep);
}
static int
@@ -188,21 +191,23 @@
wrap_cbw (&cbw, buflen, dir, cb, cblen);
if (dev->controller->
bulk (MSC_INST (dev)->bulk_out, sizeof (cbw), (u8 *) &cbw, 0)) {
- clear_stall (MSC_INST (dev)->bulk_out);
+ reset_transport (dev);
return 1;
}
mdelay (10);
- if (dir == cbw_direction_data_in) {
- if (dev->controller->
- bulk (MSC_INST (dev)->bulk_in, buflen, buf, 0)) {
- clear_stall (MSC_INST (dev)->bulk_in);
- return 1;
- }
- } else {
- if (dev->controller->
- bulk (MSC_INST (dev)->bulk_out, buflen, buf, 0)) {
- clear_stall (MSC_INST (dev)->bulk_out);
- return 1;
+ if (buflen > 0) {
+ if (dir == cbw_direction_data_in) {
+ if (dev->controller->
+ bulk (MSC_INST (dev)->bulk_in, buflen, buf, 0)) {
+ clear_stall (MSC_INST (dev)->bulk_in);
+ return 1;
+ }
+ } else {
+ if (dev->controller->
+ bulk (MSC_INST (dev)->bulk_out, buflen, buf, 0)) {
+ clear_stall (MSC_INST (dev)->bulk_out);
+ return 1;
+ }
}
}
get_csw (MSC_INST (dev)->bulk_in, &csw);
@@ -220,6 +225,7 @@
return 0;
}
// error "check condition" or reserved error
+ request_sense (dev);
return 1;
}
@@ -241,6 +247,27 @@
unsigned char res4; //5
} __attribute__ ((packed)) cmdblock6_t;
+/**
+ * Like readwrite_blocks, but for soft-sectors of 512b size. Converts the
+ * start and count from 512b units.
+ * Start and count must be aligned so that they match the native
+ * sector size.
+ *
+ * @param dev device to access
+ * @param start first sector to access
+ * @param n number of sectors to access
+ * @param dir direction of access: cbw_direction_data_in == read, cbw_direction_data_out == write
+ * @param buf buffer to read into or write from. Must be at least n*512 bytes
+ * @return 0 on success, 1 on failure
+ */
+int
+readwrite_blocks_512 (usbdev_t *dev, int start, int n,
+ cbw_direction dir, u8 *buf)
+{
+ int blocksize_divider = MSC_INST(dev)->blocksize / 512;
+ return readwrite_blocks (dev, start / blocksize_divider,
+ n / blocksize_divider, dir, buf);
+}
/**
* Reads or writes a number of sequential blocks on a USB storage device.
@@ -251,7 +278,7 @@
* @param start first sector to access
* @param n number of sectors to access
* @param dir direction of access: cbw_direction_data_in == read, cbw_direction_data_out == write
- * @param buf buffer to read into or write from. Must be at least n*512 bytes
+ * @param buf buffer to read into or write from. Must be at least n*sectorsize bytes
* @return 0 on success, 1 on failure
*/
int
@@ -266,10 +293,26 @@
// write
cb.command = 0x2a;
}
- cb.block = ntohl (start);
- cb.numblocks = ntohw (n);
+ cb.block = htonl (start);
+ cb.numblocks = htonw (n);
+
return execute_command (dev, dir, (u8 *) &cb, sizeof (cb), buf,
- n * 512);
+ n * MSC_INST(dev)->blocksize);
+}
+
+/* Only request it, we don't interpret it.
+ On certain errors, that's necessary to get devices out of
+ a special state called "Contingent Allegiance Condition" */
+static int
+request_sense (usbdev_t *dev)
+{
+ u8 buf[19];
+ cmdblock6_t cb;
+ memset (&cb, 0, sizeof (cb));
+ cb.command = 0x3;
+
+ return execute_command (dev, cbw_direction_data_in, (u8 *) &cb,
+ sizeof (cb), buf, 19);
}
static int
@@ -338,17 +381,25 @@
printf (" it uses %s protocol\n",
msc_protocol_strings[interface->bInterfaceProtocol]);
- if ((interface->bInterfaceProtocol != 0x50)
- || (interface->bInterfaceSubClass != 6)) {
+
+ if (interface->bInterfaceProtocol != 0x50) {
+ printf (" Protocol not supported.\n");
+ return;
+ }
+
+ if ((interface->bInterfaceSubClass != 2) && // ATAPI 8020
+ (interface->bInterfaceSubClass != 5) && // ATAPI 8070
+ (interface->bInterfaceSubClass != 6)) { // SCSI
/* Other protocols, such as ATAPI don't seem to be very popular. looks like ATAPI would be really easy to add, if necessary. */
- printf (" Only SCSI over Bulk is supported.\n");
+ printf (" Interface SubClass not supported.\n");
return;
}
dev->data = malloc (sizeof (usbmsc_inst_t));
if (!dev->data)
- usb_fatal("Not enough memory for USB MSC device.\n");
+ usb_fatal ("Not enough memory for USB MSC device.\n");
+ MSC_INST (dev)->protocol = interface->bInterfaceSubClass;
MSC_INST (dev)->bulk_in = 0;
MSC_INST (dev)->bulk_out = 0;
@@ -376,10 +427,11 @@
printf (" has %d luns\n", get_max_luns (dev) + 1);
printf (" Waiting for device to become ready... ");
- timeout = 10;
+ timeout = 30 * 10; /* SCSI/ATA specs say we have to wait up to 30s. Ugh */
while (test_unit_ready (dev) && --timeout) {
mdelay (100);
- printf (".");
+ if (!(timeout % 10))
+ printf (".");
}
if (test_unit_ready (dev)) {
printf ("timeout. Device not ready. Still trying...\n");
Modified: trunk/payloads/libpayload/include/usb/usb.h
==============================================================================
--- trunk/payloads/libpayload/include/usb/usb.h Thu Mar 25 23:15:19 2010 (r5298)
+++ trunk/payloads/libpayload/include/usb/usb.h Thu Mar 25 23:17:36 2010 (r5299)
@@ -101,7 +101,8 @@
int address; // usb address
int hub; // hub, device is attached to
int port; // port where device is attached
- int lowspeed; // 1 if lowspeed device
+ int speed; // 1: lowspeed, 0: fullspeed, 2: highspeed
+ u32 quirks; // quirks field. got to love usb
void *data;
u8 *descriptor;
u8 *configuration;
@@ -119,8 +120,6 @@
void (*stop) (hci_t *controller);
void (*reset) (hci_t *controller);
void (*shutdown) (hci_t *controller);
- int (*packet) (usbdev_t *dev, int endp, int pid, int toggle,
- int length, u8 *data);
int (*bulk) (endpoint_t *ep, int size, u8 *data, int finalize);
int (*control) (usbdev_t *dev, pid_t pid, int dr_length,
void *devreq, int data_length, u8 *data);
@@ -199,6 +198,16 @@
unsigned char bInterval;
} __attribute__ ((packed)) endpoint_descriptor_t;
+typedef struct {
+ unsigned char bLength;
+ unsigned char bDescriptorType;
+ unsigned short bcdHID;
+ unsigned char bCountryCode;
+ unsigned char bNumDescriptors;
+ unsigned char bReportDescriptorType;
+ unsigned short wReportDescriptorLength;
+} __attribute__ ((packed)) hid_descriptor_t;
+
hci_t *new_controller (void);
void detach_controller (hci_t *controller);
void usb_poll (void);
@@ -213,7 +222,7 @@
void usb_hid_init (usbdev_t *dev);
void usb_msc_init (usbdev_t *dev);
-int set_address (hci_t *controller, int lowspeed);
+int set_address (hci_t *controller, int speed);
u8 *get_descriptor (usbdev_t *dev, unsigned char bmRequestType,
int descType, int descIdx, int langID);
@@ -225,7 +234,28 @@
}
void usb_detach_device(hci_t *controller, int devno);
-int usb_attach_device(hci_t *controller, int hubaddress, int port, int lowspeed);
+int usb_attach_device(hci_t *controller, int hubaddress, int port, int speed);
+
+u32 usb_quirk_check(u16 vendor, u16 device);
+int usb_interface_check(u16 vendor, u16 device);
+
+#define USB_QUIRK_MSC_FORCE_PROTO_SCSI (1 << 0)
+#define USB_QUIRK_MSC_FORCE_PROTO_ATAPI (1 << 1)
+#define USB_QUIRK_MSC_FORCE_PROTO_UFI (1 << 2)
+#define USB_QUIRK_MSC_FORCE_PROTO_RBC (1 << 3)
+#define USB_QUIRK_MSC_FORCE_TRANS_BBB (1 << 4)
+#define USB_QUIRK_MSC_FORCE_TRANS_CBI (1 << 5)
+#define USB_QUIRK_MSC_FORCE_TRANS_CBI_I (1 << 6)
+#define USB_QUIRK_MSC_NO_TEST_UNIT_READY (1 << 7)
+#define USB_QUIRK_MSC_SHORT_INQUIRY (1 << 8)
+#define USB_QUIRK_TEST (1 << 31)
+#define USB_QUIRK_NONE 0
+
+#ifdef USB_DEBUG
+#define debug(x...) printf(x);
+#else
+#define debug(x...)
+#endif
void usb_fatal(const char *message) __attribute__ ((noreturn));
#endif
Modified: trunk/payloads/libpayload/include/usb/usbmsc.h
==============================================================================
--- trunk/payloads/libpayload/include/usb/usbmsc.h Thu Mar 25 23:15:19 2010 (r5298)
+++ trunk/payloads/libpayload/include/usb/usbmsc.h Thu Mar 25 23:17:36 2010 (r5299)
@@ -1,7 +1,7 @@
/*
* This file is part of the libpayload project.
*
- * Copyright (C) 2008 coresystems GmbH
+ * Copyright (C) 2008-2010 coresystems GmbH
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,6 +32,7 @@
typedef struct {
unsigned int blocksize;
unsigned int numblocks;
+ unsigned int protocol;
endpoint_t *bulk_in;
endpoint_t *bulk_out;
} usbmsc_inst_t;
@@ -41,7 +42,7 @@
typedef enum { cbw_direction_data_in = 0x80, cbw_direction_data_out = 0
} cbw_direction;
-int readwrite_blocks (usbdev_t *dev, int start, int n, cbw_direction dir,
- u8 *buf);
+int readwrite_blocks_512 (usbdev_t *dev, int start, int n, cbw_direction dir, u8 *buf);
+int readwrite_blocks (usbdev_t *dev, int start, int n, cbw_direction dir, u8 *buf);
#endif
1
0
[commit] r5298 - in trunk/payloads/libpayload: . include include/powerpc/arch libc
by repository service March 25, 2010
by repository service March 25, 2010
March 25, 2010
Author: stepan
Date: Thu Mar 25 23:15:19 2010
New Revision: 5298
URL: https://tracker.coreboot.org/trac/coreboot/changeset/5298
Log:
libpayload update
* rework Config.in
* add string_to_args function to actually make getopt usable.
* add strchr
* add strlcat
* some malloc fixes (exposed by the USB stack)
* add malloc debugging (thanks to Matthias Krause from Secunet!)
* make LAR support optional, it's not really used anymore
* (define htoX macros for ppc)
Signed-off-by: Stefan Reinauer <stepan(a)coresystems.de>
Acked-by: Joseph Smith <joe(a)settoplinux.org>
Added:
trunk/payloads/libpayload/libc/args.c
Modified:
trunk/payloads/libpayload/Config.in
trunk/payloads/libpayload/include/getopt.h
trunk/payloads/libpayload/include/libpayload.h
trunk/payloads/libpayload/include/powerpc/arch/endian.h
trunk/payloads/libpayload/libc/Makefile.inc
trunk/payloads/libpayload/libc/malloc.c
trunk/payloads/libpayload/libc/string.c
Modified: trunk/payloads/libpayload/Config.in
==============================================================================
--- trunk/payloads/libpayload/Config.in Thu Mar 25 22:45:25 2010 (r5297)
+++ trunk/payloads/libpayload/Config.in Thu Mar 25 23:15:19 2010 (r5298)
@@ -30,6 +30,31 @@
mainmenu "Libpayload Configuration"
+menu "Generic Options"
+
+config EXPERIMENTAL
+ bool "Experimental Options"
+ default n
+ help
+ Prompt for experimental functionality. Attention: This is not likely
+ to work without problems
+
+config OBSOLETE
+ bool "Obsolete Options"
+ default n
+ help
+ Prompt for obsolete options. These options are for old, unsupported
+ features and are likely to go away in the future.
+
+config DEVELOPER
+ bool "Developer Options"
+ default n
+ help
+ Prompt for developer options. These options are only interesting for
+ libpayload developers.
+
+endmenu
+
menu "Architecture Options"
choice
@@ -65,6 +90,18 @@
bool "Enable tinycurses support"
default y
+config LAR
+ bool "LAR support"
+ default n
+ depends on OBSOLETE
+ help
+ LAR is the archive format of (obsolete) coreboot v3
+
+config CBFS
+ bool "CBFS support"
+ default y
+ help
+ CBFS is the archive format of (obsolete) coreboot v3
endmenu
menu "Console Options"
@@ -197,19 +234,52 @@
NOTE: This option is not (fully) implemented yet
config USB_HID
- bool "Support for USB keyboards (broken)"
+ bool "Support for USB keyboards"
depends on USB
- default n
+ default y
+ help
+ Select this option if you want to use devices complying to the
+ USB HID (Human Interface Device) standard. Such devices are for
+ example keyboards and mice. Currently only keyboards are supported.
+ Say Y here unless you know exactly what you are doing.
config USB_HUB
- bool "Support for USB hubs (broken)"
+ bool "Support for USB hubs"
depends on USB
- default n
+ default y
+ help
+ Select this option if you want to compile in support for USB hubs.
+ Say Y here unless you know exactly what you are doing.
config USB_MSC
bool "Support for USB storage"
depends on USB
+ default y
+ help
+ Select this option if you want to compile in support for USB mass
+ storage devices (USB memory sticks, hard drives, CDROM/DVD drives)
+ Say Y here unless you know exactly what you are doing.
+
+endmenu
+
+menu "Debugging"
+ depends on DEVELOPER
+
+config DEBUG_MALLOC
+ bool "Debug memory allocator"
+ depends on USB
+ default n
+ help
+ Select this option if you want to debug the memory allocator. This
+ option logs all uses of the following functions:
+
+ void free(void *ptr);
+ void *malloc(size_t size);
+ void *calloc(size_t nmemb, size_t size);
+ void *realloc(void *ptr, size_t size);
+ void *memalign(size_t align, size_t size);
+ Say N here unless you are debugging memory allocator problems.
endmenu
Modified: trunk/payloads/libpayload/include/getopt.h
==============================================================================
--- trunk/payloads/libpayload/include/getopt.h Thu Mar 25 22:45:25 2010 (r5297)
+++ trunk/payloads/libpayload/include/getopt.h Thu Mar 25 23:15:19 2010 (r5298)
@@ -75,4 +75,9 @@
#endif
//__END_DECLS
+#define MAX_ARGS 16
+extern char *string_argv[MAX_ARGS];
+extern int string_argc;
+int string_to_args(char *caller, char *string);
+
#endif /* !_GETOPT_H_ */
Modified: trunk/payloads/libpayload/include/libpayload.h
==============================================================================
--- trunk/payloads/libpayload/include/libpayload.h Thu Mar 25 22:45:25 2010 (r5297)
+++ trunk/payloads/libpayload/include/libpayload.h Thu Mar 25 23:15:19 2010 (r5298)
@@ -43,14 +43,17 @@
#ifndef _LIBPAYLOAD_H
#define _LIBPAYLOAD_H
+#include <libpayload-config.h>
#include <stddef.h>
#include <arch/types.h>
#include <arch/io.h>
#include <arch/virtual.h>
#include <sysinfo.h>
#include <stdarg.h>
-#include <lar.h>
#include <pci.h>
+#ifdef CONFIG_LAR
+#include <lar.h>
+#endif
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
@@ -253,11 +256,82 @@
* @defgroup malloc Memory allocation functions
* @{
*/
+#if defined(CONFIG_DEBUG_MALLOC) && !defined(IN_MALLOC_C)
+#define free(p) \
+ ({ \
+ extern void print_malloc_map(void); \
+ extern void free(void *); \
+ printf("free(%p) called from %s:%s:%d...\n", p, __FILE__, __func__, \
+ __LINE__);\
+ printf("PRE free()\n"); \
+ print_malloc_map(); \
+ free(p); \
+ printf("POST free()\n"); \
+ print_malloc_map(); \
+ })
+#define malloc(s) \
+ ({ \
+ extern void print_malloc_map(void); \
+ extern void *malloc(size_t); \
+ void *ptr; \
+ printf("malloc(%u) called from %s:%s:%d...\n", s, __FILE__, __func__, \
+ __LINE__);\
+ printf("PRE malloc\n"); \
+ print_malloc_map(); \
+ ptr = malloc(s); \
+ printf("POST malloc (ptr = %p)\n", ptr); \
+ print_malloc_map(); \
+ ptr; \
+ })
+#define calloc(n,s) \
+ ({ \
+ extern void print_malloc_map(void); \
+ extern void *calloc(size_t,size_t); \
+ void *ptr; \
+ printf("calloc(%u, %u) called from %s:%s:%d...\n", n, s, __FILE__, \
+ __func__, __LINE__);\
+ printf("PRE calloc\n"); \
+ print_malloc_map(); \
+ ptr = calloc(n,s); \
+ printf("POST calloc (ptr = %p)\n", ptr); \
+ print_malloc_map(); \
+ ptr; \
+ })
+#define realloc(p,s) \
+ ({ \
+ extern void print_malloc_map(void); \
+ extern void *realloc(void*,size_t); \
+ void *ptr; \
+ printf("realloc(%p, %u) called from %s:%s:%d...\n", p, s, __FILE__, \
+ __func__, __LINE__);\
+ printf("PRE realloc\n"); \
+ print_malloc_map(); \
+ ptr = realloc(p,s); \
+ printf("POST realloc (ptr = %p)\n", ptr); \
+ print_malloc_map(); \
+ ptr; \
+ })
+#define memalign(a,s) \
+ ({ \
+ extern void print_malloc_map(void); \
+ extern void *memalign(size_t, size_t); \
+ void *ptr; \
+ printf("memalign(%u, %u) called from %s:%s:%d...\n", a, s, __FILE__, \
+ __func__, __LINE__);\
+ printf("PRE memalign\n"); \
+ print_malloc_map(); \
+ ptr = memalign(a,s); \
+ printf("POST realloc (ptr = %p)\n", ptr); \
+ print_malloc_map(); \
+ ptr; \
+ })
+#else
void free(void *ptr);
void *malloc(size_t size);
void *calloc(size_t nmemb, size_t size);
void *realloc(void *ptr, size_t size);
void *memalign(size_t align, size_t size);
+#endif
/** @} */
/**
@@ -341,7 +415,9 @@
char *strncpy(char *d, const char *s, size_t n);
char *strcpy(char *d, const char *s);
char *strncat(char *d, const char *s, size_t n);
+size_t strlcat(char *d, const char *s, size_t n);
char *strchr(const char *s, int c);
+char *strrchr(const char *s, int c);
char *strdup(const char *s);
char *strstr(const char *h, const char *n);
char *strsep(char **stringp, const char *delim);
@@ -363,6 +439,7 @@
int gettimeofday(struct timeval *tv, void *tz);
/** @} */
+#ifdef CONFIG_LAR
/**
* @defgroup lar LAR functions
* @{
@@ -421,6 +498,7 @@
int lfseek(struct LFILE *stream, long offset, int whence);
int lfclose(struct LFILE *file);
/** @} */
+#endif
/**
* @defgroup info System information functions
Modified: trunk/payloads/libpayload/include/powerpc/arch/endian.h
==============================================================================
--- trunk/payloads/libpayload/include/powerpc/arch/endian.h Thu Mar 25 22:45:25 2010 (r5297)
+++ trunk/payloads/libpayload/include/powerpc/arch/endian.h Thu Mar 25 23:15:19 2010 (r5298)
@@ -38,4 +38,8 @@
#define ntohll(in) (in)
+#define htonw(in) ntohw(in)
+#define htonl(in) ntohw(in)
+#define htonll(in) ntohll(in)
+
#endif
Modified: trunk/payloads/libpayload/libc/Makefile.inc
==============================================================================
--- trunk/payloads/libpayload/libc/Makefile.inc Thu Mar 25 22:45:25 2010 (r5297)
+++ trunk/payloads/libpayload/libc/Makefile.inc Thu Mar 25 23:15:19 2010 (r5298)
@@ -30,5 +30,10 @@
TARGETS-$(CONFIG_LIBC) += libc/malloc.o libc/printf.o libc/console.o libc/string.o
TARGETS-$(CONFIG_LIBC) += libc/memory.o libc/ctype.o libc/ipchecksum.o libc/lib.o
-TARGETS-$(CONFIG_LIBC) += libc/rand.o libc/time.o libc/lar.o libc/exec.o
+TARGETS-$(CONFIG_LIBC) += libc/rand.o libc/time.o libc/exec.o
TARGETS-$(CONFIG_LIBC) += libc/readline.o libc/getopt_long.o libc/sysinfo.o
+TARGETS-$(CONFIG_LIBC) += libc/args.o
+
+# should be moved to coreboot directory
+TARGETS-$(CONFIG_LAR) += libc/lar.o
+#TARGETS-$(CONFIG_CBFS) += libc/cbfs.o
Added: trunk/payloads/libpayload/libc/args.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/payloads/libpayload/libc/args.c Thu Mar 25 23:15:19 2010 (r5298)
@@ -0,0 +1,88 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 coresystems GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/**
+ * @file libc/readline.c
+ * Simple readline implementation
+ */
+
+#include <libpayload.h>
+#include <getopt.h>
+
+/* We don't want to waste malloc on this, so we live with a small
+ * fixed size array
+ */
+char *string_argv[MAX_ARGS];
+int string_argc;
+
+/**
+ * Take a string and make char *argv[] and int argc from it.
+ *
+ * This function allows the user to use getopt on an arbitrary string.
+ *
+ * global variables valid after a successful run of string_to_args():
+ * string_argc pointer to number of arguments
+ * string_argv pointer to argument list.
+ *
+ * @param caller to be used as argv[0] (may be NULL to ignore)
+ * @param string to process
+ * @return 0 if no error occured.
+ */
+int string_to_args(char *caller, char *string)
+{
+ int i = 0;
+
+ if (caller)
+ string_argv[i++] = caller;
+
+ if (*string)
+ string_argv[i++] = string;
+
+ /* Terminate if the string ends */
+ while (string && *string) {
+ /* whitespace occured? */
+ if ((*string == ' ') || (*string == '\t')) {
+ /* skip all whitespace (and null it) */
+ while (*string == ' ' || *string == '\t')
+ *string++ = 0;
+ /* if our ugly static array is big enough, store
+ * argument to string_argv[]
+ */
+ if (i < MAX_ARGS)
+ string_argv[i++] = string;
+ }
+ string++;
+ }
+
+ /* prevent array from overflowing */
+ string_argc = (i <= MAX_ARGS) ? i : MAX_ARGS;
+
+ /* and return whether there was an overflow */
+ return (i <= MAX_ARGS) ? 0 : 1;
+}
Modified: trunk/payloads/libpayload/libc/malloc.c
==============================================================================
--- trunk/payloads/libpayload/libc/malloc.c Thu Mar 25 22:45:25 2010 (r5297)
+++ trunk/payloads/libpayload/libc/malloc.c Thu Mar 25 23:15:19 2010 (r5298)
@@ -2,6 +2,7 @@
* This file is part of the libpayload project.
*
* Copyright (C) 2008 Advanced Micro Devices, Inc.
+ * Copyright (C) 2008-2010 coresystems GmbH
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -38,6 +39,7 @@
* your buffers, kids!).
*/
+#define IN_MALLOC_C
#include <libpayload.h>
extern char _heap, _eheap; /* Defined in the ldscript. */
@@ -66,11 +68,21 @@
static int free_aligned(void* addr);
void print_malloc_map(void);
+#ifdef CONFIG_DEBUG_MALLOC
+static int heap_initialized = 0;
+static int minimal_free = 0;
+#endif
+
static void setup(void)
{
int size = (unsigned int)(&_eheap - &_heap) - HDRSIZE;
*((hdrtype_t *) hstart) = FREE_BLOCK(size);
+
+#ifdef CONFIG_DEBUG_MALLOC
+ heap_initialized = 1;
+ minimal_free = size;
+#endif
}
static void *alloc(int len)
@@ -94,7 +106,9 @@
int size = SIZE(header);
if (!HAS_MAGIC(header) || size == 0) {
- printf("memory allocator panic.\n");
+ printf("memory allocator panic. (%s%s)\n",
+ !HAS_MAGIC(header) ? " no magic " : "",
+ size == 0 ? " size=0 " : "");
halt();
}
@@ -268,9 +282,16 @@
static struct align_region_t* align_regions = 0;
-static struct align_region_t *allocate_region(struct align_region_t *old_first, int alignment, int num_elements)
+static struct align_region_t *allocate_region(int alignment, int num_elements)
{
- struct align_region_t *new_region = malloc(sizeof(struct align_region_t));
+ struct align_region_t *new_region;
+#ifdef CONFIG_DEBUG_MALLOC
+ printf("%s(old align_regions=%p, alignment=%u, num_elements=%u)\n",
+ __func__, align_regions, alignment, num_elements);
+#endif
+
+ new_region = malloc(sizeof(struct align_region_t));
+
if (!new_region)
return NULL;
new_region->alignment = alignment;
@@ -282,8 +303,9 @@
new_region->start_data = (void*)((u32)(new_region->start + num_elements + alignment - 1) & (~(alignment-1)));
new_region->size = num_elements * alignment;
new_region->free = num_elements;
- new_region->next = old_first;
+ new_region->next = align_regions;
memset(new_region->start, 0, num_elements);
+ align_regions = new_region;
return new_region;
}
@@ -325,15 +347,29 @@
{
if ((reg->alignment == align) && (reg->free >= (size + align - 1)/align))
{
+#ifdef CONFIG_DEBUG_MALLOC
+ printf(" found memalign region. %x free, %x required\n", reg->free, (size + align - 1)/align);
+#endif
break;
}
reg = reg->next;
}
if (reg == 0)
{
- align_regions = allocate_region(align_regions, align, (size/align<99)?100:((size/align)+1));
- reg = align_regions;
+#ifdef CONFIG_DEBUG_MALLOC
+ printf(" need to allocate a new memalign region\n");
+#endif
+ /* get align regions */
+ reg = allocate_region(align, (size<1024)?(1024/align):(((size-1)/align)+1));
+#ifdef CONFIG_DEBUG_MALLOC
+ printf(" ... returned %p\n", align_regions);
+#endif
+ }
+ if (reg == 0) {
+ /* Nothing available. */
+ return (void *)NULL;
}
+
int i, count = 0, target = (size+align-1)/align;
for (i = 0; i < (reg->size/align); i++)
{
@@ -358,16 +394,20 @@
}
/* This is for debugging purposes. */
-#ifdef TEST
+#ifdef CONFIG_DEBUG_MALLOC
void print_malloc_map(void)
{
void *ptr = hstart;
+ int free_memory = 0;
while (ptr < hend) {
hdrtype_t hdr = *((hdrtype_t *) ptr);
if (!HAS_MAGIC(hdr)) {
- printf("Poisoned magic - we're toast\n");
+ if (heap_initialized)
+ printf("Poisoned magic - we're toast\n");
+ else
+ printf("No magic yet - going to initialize\n");
break;
}
@@ -377,7 +417,15 @@
(unsigned int)(ptr - hstart),
hdr & FLAG_FREE ? "FREE" : "USED", SIZE(hdr));
+ if (hdr & FLAG_FREE)
+ free_memory += SIZE(hdr);
+
ptr += HDRSIZE + SIZE(hdr);
}
+
+ if (free_memory && (minimal_free > free_memory))
+ minimal_free = free_memory;
+ printf("Maximum memory consumption: %d bytes",
+ (unsigned int)(&_eheap - &_heap) - HDRSIZE - minimal_free);
}
#endif
Modified: trunk/payloads/libpayload/libc/string.c
==============================================================================
--- trunk/payloads/libpayload/libc/string.c Thu Mar 25 22:45:25 2010 (r5297)
+++ trunk/payloads/libpayload/libc/string.c Thu Mar 25 23:15:19 2010 (r5298)
@@ -171,7 +171,9 @@
char *strncat(char *d, const char *s, size_t n)
{
char *p = d + strlen(d);
- int max = n > strlen(s) ? strlen(s) : n;
+ int sl = strlen(s);
+ int max = n > sl ? sl : n;
+ // int max = n > strlen(s) ? strlen(s) : n;
int i;
for (i = 0; i < max; i++)
@@ -182,6 +184,30 @@
}
/**
+ * Concatenates two strings with a maximum length.
+ *
+ * @param d The destination string.
+ * @param s The source string.
+ * @param n Not more than n characters from s will be appended to d.
+ * @return A pointer to the destination string.
+ */
+size_t strlcat(char *d, const char *s, size_t n)
+{
+ int sl = strlen(s);
+ int dl = strlen(d);
+
+ char *p = d + dl;
+ int max = n > (sl + dl) ? sl : (n - dl - 1);
+ int i;
+
+ for (i = 0; i < max; i++)
+ p[i] = s[i];
+
+ p[i] = '\0';
+ return max;
+}
+
+/**
* Find a character in a string.
*
* @param s The string.
@@ -197,6 +223,27 @@
if (*p == c)
return p;
}
+
+ return NULL;
+}
+
+/**
+ * Find a character in a string.
+ *
+ * @param s The string.
+ * @param c The character.
+ * @return A pointer to the last occurence of the character in the
+ * string, or NULL if the character was not encountered within the string.
+ */
+
+char *strrchr(const char *s, int c)
+{
+ char *p = (char *)s + strlen(s);
+
+ for (; p >= s; p--) {
+ if (*p == c)
+ return p;
+ }
return NULL;
}
1
0
See patch
2
1
March 25, 2010
See patch.
2
1
[commit] r5297 - in trunk: . src src/arch/i386 util/abuild util/romcc
by repository service March 25, 2010
by repository service March 25, 2010
March 25, 2010
Author: oxygene
Date: Thu Mar 25 22:45:25 2010
New Revision: 5297
URL: https://tracker.coreboot.org/trac/coreboot/changeset/5297
Log:
Add support to build with ccache in the build system
Signed-off-by: Patrick Georgi <patrick.georgi(a)coresystems.de>
Acked-by: Stefan Reinauer <stepan(a)coresystems.de>
Modified:
trunk/Makefile
trunk/src/Kconfig
trunk/src/arch/i386/Makefile.bootblock.inc
trunk/src/arch/i386/Makefile.inc
trunk/util/abuild/abuild
trunk/util/romcc/romcc.c
Modified: trunk/Makefile
==============================================================================
--- trunk/Makefile Thu Mar 25 20:01:27 2010 (r5296)
+++ trunk/Makefile Thu Mar 25 22:45:25 2010 (r5297)
@@ -61,6 +61,7 @@
endif
CPP:= $(CC) -x assembler-with-cpp -DASSEMBLY -E
+ROMCC:= $(obj)/romcc
HOSTCC = gcc
HOSTCXX = g++
HOSTCFLAGS := -I$(srck) -I$(objk) -g
@@ -85,6 +86,17 @@
endif
endif
+ifeq ($(CONFIG_CCACHE),y)
+CCACHE:=CCACHE_COMPILERCHECK=content $(wildcard $(addsuffix /ccache,$(subst :, ,$(PATH))))
+ifeq ($(CCACHE),)
+$(error ccache selected, but not found in PATH)
+endif
+CC := $(CCACHE) $(CC)
+HOSTCC := $(CCACHE) $(HOSTCC)
+HOSTCXX := $(CCACHE) $(HOSTCXX)
+ROMCC := $(CCACHE) $(ROMCC)
+endif
+
strip_quotes = $(subst ",,$(subst \",,$(1)))
ARCHDIR-$(CONFIG_ARCH_X86) := i386
Modified: trunk/src/Kconfig
==============================================================================
--- trunk/src/Kconfig Thu Mar 25 20:01:27 2010 (r5296)
+++ trunk/src/Kconfig Thu Mar 25 22:45:25 2010 (r5297)
@@ -62,6 +62,7 @@
config SCANBUILD_ENABLE
bool "Build with scan-build for static analysis"
default n
+ depends on !CCACHE
help
Changes the build process to scan-build is used.
Requires scan-build in path.
@@ -73,6 +74,13 @@
help
Where the scan-build report should be stored
+config CCACHE
+ bool "ccache"
+ default n
+ help
+ Enables the use of ccache for faster builds.
+ Requires ccache in path.
+
endmenu
source src/mainboard/Kconfig
Modified: trunk/src/arch/i386/Makefile.bootblock.inc
==============================================================================
--- trunk/src/arch/i386/Makefile.bootblock.inc Thu Mar 25 20:01:27 2010 (r5296)
+++ trunk/src/arch/i386/Makefile.bootblock.inc Thu Mar 25 22:45:25 2010 (r5297)
@@ -71,7 +71,7 @@
@printf " ROMCC $(subst $(obj)/,,$(@))\n"
$(CC) -MM -MT$(obj)/mainboard/$(MAINBOARDDIR)/bootblock.inc \
$< > $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.inc.d
- $(obj)/romcc $(bootblock_romccflags) $(ROMCCFLAGS) $(INCLUDES) $< -o $@
+ $(ROMCC) -c -S $(bootblock_romccflags) $(ROMCCFLAGS) -I. $(INCLUDES) $< -o $@
$(obj)/bootblock.elf: $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.o $(obj)/bootblock/ldscript.ld
@printf " LINK $(subst $(obj)/,,$(@))\n"
Modified: trunk/src/arch/i386/Makefile.inc
==============================================================================
--- trunk/src/arch/i386/Makefile.inc Thu Mar 25 20:01:27 2010 (r5296)
+++ trunk/src/arch/i386/Makefile.inc Thu Mar 25 22:45:25 2010 (r5297)
@@ -195,7 +195,7 @@
$(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(obj)/romcc $(OPTION_TABLE_H) $(obj)/build.h
printf " ROMCC romstage.inc\n"
- $(obj)/romcc $(ROMCCFLAGS) -include $(obj)/build.h $(INCLUDES) $< -o $@
+ $(ROMCC) -c -S $(ROMCCFLAGS) -include $(obj)/build.h -I. $(INCLUDES) $< -o $@
else
Modified: trunk/util/abuild/abuild
==============================================================================
--- trunk/util/abuild/abuild Thu Mar 25 20:01:27 2010 (r5296)
+++ trunk/util/abuild/abuild Thu Mar 25 22:45:25 2010 (r5297)
@@ -55,6 +55,9 @@
# clang mode enabled by -sb option.
scanbuild=false
+# use ccache
+ccache=false
+
# stackprotect mode enabled by -ns option.
stackprotect=false
@@ -174,6 +177,11 @@
echo "CONFIG_DEFAULT_CONSOLE_LOGLEVEL=$loglevel" >> .config
fi
+ if [ "$ccache" = "true" ]; then
+ printf "(ccache enabled) "
+ echo "CONFIG_CCACHE=y" >> .config
+ fi
+
if [ "$scanbuild" = "true" ]; then
printf "(scan-build enabled) "
echo "CONFIG_SCANBUILD_ENABLE=y" >> .config
@@ -495,6 +503,7 @@
printf " [-s|--silent] omit compiler calls in logs\n"
printf " [-ns|--nostackprotect] use gcc -fno-stack-protector option\n"
printf " [-sb|--scan-build] use clang's static analyzer\n"
+ printf " [-y|--ccache] use ccache\n"
printf " [-C|--config] configure-only mode\n"
printf " [-l|--loglevel <num>] set loglevel\n"
printf " [lbroot] absolute path to coreboot sources\n"
@@ -530,11 +539,11 @@
getoptbrand="`getopt -V`"
if [ "${getoptbrand:0:6}" == "getopt" ]; then
# Detected GNU getopt that supports long options.
- args=`getopt -l version,verbose,help,all,target:,broken,payloads:,test,cpus:,silent,xml,config,loglevel: Vvhat:bp:Tc:sxCl: -- "$@"`
+ args=`getopt -l version,verbose,help,all,target:,broken,payloads:,test,cpus:,silent,xml,config,loglevel:,ccache Vvhat:bp:Tc:sxCl:y -- "$@"`
eval set "$args"
else
# Detected non-GNU getopt
- args=`getopt Vvhat:bp:Tc:sxCl:o $*`
+ args=`getopt Vvhat:bp:Tc:sxCl:y $*`
set -- $args
fi
@@ -559,6 +568,7 @@
-s|--silent) shift; silent="-s";;
-ns|--nostackprotect) shift; stackprotect=true;;
-sb|--scan-build) shift; scanbuild=true;;
+ -y|--ccache) shift; ccache=true;;
-C|--config) shift; configureonly=1;;
-l|--loglevel) shift; loglevel="$1"; shift;;
--) shift; break;;
Modified: trunk/util/romcc/romcc.c
==============================================================================
--- trunk/util/romcc/romcc.c Thu Mar 25 20:01:27 2010 (r5296)
+++ trunk/util/romcc/romcc.c Thu Mar 25 22:45:25 2010 (r5297)
@@ -24968,10 +24968,14 @@
state.errout = stderr;
state.dbgout = stdout;
/* Remember the output filename */
- state.output = fopen(state.compiler->ofilename, "w");
- if (!state.output) {
- error(&state, 0, "Cannot open output file %s\n",
- state.compiler->ofilename);
+ if ((state.compiler->flags & COMPILER_PP_ONLY) && (strcmp("auto.inc",state.compiler->ofilename) == 0)) {
+ state.output = stdout;
+ } else {
+ state.output = fopen(state.compiler->ofilename, "w");
+ if (!state.output) {
+ error(&state, 0, "Cannot open output file %s\n",
+ state.compiler->ofilename);
+ }
}
/* Make certain a good cleanup happens */
exit_state = &state;
@@ -25146,6 +25150,12 @@
else if (strncmp(argv[1], "-m", 2) == 0) {
result = arch_encode_flag(&arch, argv[1]+2);
}
+ else if (strncmp(argv[1], "-c", 2) == 0) {
+ result = 0;
+ }
+ else if (strncmp(argv[1], "-S", 2) == 0) {
+ result = 0;
+ }
else if (strncmp(argv[1], "-include", 10) == 0) {
struct filelist *old_head = include_filelist;
include_filelist = malloc(sizeof(struct filelist));
1
0
Hi,
most of the tree was already ccache aware, with one exception: romcc.
This hurt, as on the non-CAR boards, this is a large non-parallelizable
part of the total build time.
This patch changes romcc to:
- accept -c and -S (and ignores them as that's already the only mode it
knows)
- send -E output (preprocessor only) to stdout except if a filename is
given (by testing if it's set to the current default of auto.inc)
With these, ccache3.0pre0 (the version I tried) is capable of cache
romcc output.
The Makefile changes in this patch make use of that, if "ccache" is
found in $PATH (necessary as we use various paths for our romcc), and
runs ccache $(obj)/romcc, using the "content" compiler version
verification (which hashes the compiler executable) for romcc.
Thus when romcc is changed, ccache doesn't use cached files but requests
new builds.
On my test system, abuild of a romcc board (thomson/ip1000) goes down
from 9 to 3 seconds when using 4 parallel build jobs.
Signed-off-by: Patrick Georgi <patrick.georgi(a)coresystems.de>
2
3
March 25, 2010
hi all,
since i am trying to join this GSOC this year, i would rather to join
coreboot at the same time. I have already spend some time to get familar
with the source code. After getting suggestion from irc, I want to try the
project "drivers for libpayload". I have found that there is an USB driver
project last. And i have some questions now.
1) in the filo trunk, there is an ohci source code, does that work or i is
useless? since filo now use libpayload stack instead if itself.
2)since seabios now support both OHCI and UHCI, does that hard for me to
take seabios/usb code as an example?
3) is there any suggestion about this project?
any suggestion will be pretty good for me to get better in the future.
Cai Bai Yin
Peking University
questions about GSOC project with "drivers for libpayload"
2
1
Author: oxygene
Date: Thu Mar 25 20:01:27 2010
New Revision: 5296
URL: https://tracker.coreboot.org/trac/coreboot/changeset/5296
Log:
Make build verbose when requested by abuild
Signed-off-by: Patrick Georgi <patrick.georgi(a)coresystems.de>
Acked-by: Stefan Reinauer <stepan(a)coresystems.de>
Modified:
trunk/util/abuild/abuild
Modified: trunk/util/abuild/abuild
==============================================================================
--- trunk/util/abuild/abuild Thu Mar 25 19:56:26 2010 (r5295)
+++ trunk/util/abuild/abuild Thu Mar 25 20:01:27 2010 (r5296)
@@ -550,7 +550,7 @@
-a|--all) shift; buildall=true;;
-b|--broken) shift; buildbroken=true;;
-r|--remove) shift; remove=true; shift;;
- -v|--verbose) shift; verbose=true;;
+ -v|--verbose) shift; verbose=true; silent='V=1';;
-V|--version) shift; myversion; exit 0;;
-h|--help) shift; myversion; myhelp; exit 0;;
-p|--payloads) shift; payloads="$1"; shift;;
1
0