#include CYGHWR_MEMORY_LAYOUT_H
-#define SZ_1K 0x00000400
-#define SZ_2K 0x00000800
-#define SZ_4K 0x00001000
-#define SZ_8K 0x00002000
-#define SZ_16K 0x00004000
-#define SZ_32K 0x00008000
-#define SZ_64K 0x00010000
-#define SZ_128K 0x00020000
-#define SZ_256K 0x00040000
-#define SZ_512K 0x00080000
-#define SZ_1M 0x00100000
-#define SZ_2M 0x00200000
-#define SZ_4M 0x00400000
-#define SZ_8M 0x00800000
-#define SZ_16M 0x01000000
-#define SZ_32M 0x02000000
-#define SZ_64M 0x04000000
-#define SZ_128M 0x08000000
-#define SZ_256M 0x10000000
-#define SZ_512M 0x20000000
-#define SZ_1G 0x40000000
-
-#define RAM_BANK0_BASE CSD0_BASE_ADDR
-#define RAM_BANK1_BASE CSD1_BASE_ADDR
-#if SDRAM_SIZE > SZ_32M
-#define RAM_BANK0_SIZE (SDRAM_SIZE / 2)
-#define RAM_BANK1_SIZE (SDRAM_SIZE / 2)
-#else
-#define RAM_BANK0_SIZE SDRAM_SIZE
-#endif
-#define TX25_SDRAM_SIZE SDRAM_SIZE
+#define SZ_1K 0x00000400
+#define SZ_2K 0x00000800
+#define SZ_4K 0x00001000
+#define SZ_8K 0x00002000
+#define SZ_16K 0x00004000
+#define SZ_32K 0x00008000
+#define SZ_64K 0x00010000
+#define SZ_128K 0x00020000
+#define SZ_256K 0x00040000
+#define SZ_512K 0x00080000
+#define SZ_1M 0x00100000
+#define SZ_2M 0x00200000
+#define SZ_4M 0x00400000
+#define SZ_8M 0x00800000
+#define SZ_16M 0x01000000
+#define SZ_32M 0x02000000
+#define SZ_64M 0x04000000
+#define SZ_128M 0x08000000
+#define SZ_256M 0x10000000
+#define SZ_512M 0x20000000
+#define SZ_1G 0x40000000
#define TX25_LED_MASK (1 << 7)
#define TX25_LED_REG_ADDR (GPIO2_BASE_ADDR + GPIO_DR)
})
#define TURN_LED_ON(n) \
- CYG_MACRO_START \
+ CYG_MACRO_START \
CYG_WORD32 __val; \
HAL_READ_UINT32(TX25_LED_REG_ADDR, __val); \
__val |= TX25_LED_MASK; \
HAL_WRITE_UINT32(TX25_LED_REG_ADDR, __val); \
- CYG_MACRO_END
+ CYG_MACRO_END
#define TURN_LED_OFF(n) \
- CYG_MACRO_START \
+ CYG_MACRO_START \
CYG_WORD32 __val; \
HAL_READ_UINT32(TX25_LED_REG_ADDR, __val); \
__val &= ~TX25_LED_MASK; \
HAL_WRITE_UINT32(TX25_LED_REG_ADDR, __val); \
- CYG_MACRO_END
+ CYG_MACRO_END
#define BOARD_DEBUG_LED(n) \
- CYG_MACRO_START \
+ CYG_MACRO_START \
if (n >= 0 && n < LED_MAX_NUM) { \
if (LED_IS_ON(n)) \
TURN_LED_OFF(n); \
else \
TURN_LED_ON(n); \
} \
- CYG_MACRO_END
+ CYG_MACRO_END
#define BLINK_LED(l, n) \
- CYG_MACRO_START \
+ CYG_MACRO_START \
int _i; \
for (_i = 0; _i < (n); _i++) { \
BOARD_DEBUG_LED(l); \
HAL_DELAY_US(300000); \
} \
HAL_DELAY_US(1000000); \
- CYG_MACRO_END
+ CYG_MACRO_END
#if !defined(__ASSEMBLER__)
enum {
#define SDRAM_BASE_ADDR CSD0_BASE_ADDR
#define SDRAM_SIZE CYGNUM_HAL_ARM_TX25_SDRAM_SIZE
+#define SZ_32M 0x02000000
+#define RAM_BANK0_BASE CSD0_BASE_ADDR
+#define RAM_BANK1_BASE CSD1_BASE_ADDR
+#if SDRAM_SIZE > SZ_32M
+#define RAM_BANK0_SIZE (SDRAM_SIZE / 2)
+#define RAM_BANK1_SIZE (SDRAM_SIZE / 2)
+#else
+#define RAM_BANK0_SIZE SDRAM_SIZE
+#endif
+#define TX25_SDRAM_SIZE SDRAM_SIZE
+
#define REDBOOT_IMAGE_SIZE 0x00040000
#ifndef REDBOOT_BOTTOM
//===========================================================================
#include <cyg/hal/hal_misc.h>
+#include CYGHWR_MEMORY_LAYOUT_H
// Get the pagesize for a particular virtual address:
// This does not depend on the vaddr.
-#define HAL_MM_PAGESIZE(vaddr, pagesize) CYG_MACRO_START \
- (pagesize) = SZ_1M; \
-CYG_MACRO_END
+#define HAL_MM_PAGESIZE(vaddr, pagesize) \
+ CYG_MACRO_START \
+ (pagesize) = SZ_1M; \
+ CYG_MACRO_END
// Get the physical address from a virtual address:
-#define HAL_VIRT_TO_PHYS_ADDRESS( vaddr, paddr ) CYG_MACRO_START \
- cyg_uint32 _v_ = (cyg_uint32)(vaddr); \
- if ( _v_ < 128 * SZ_1M ) /* SDRAM */ \
- _v_ += SDRAM_BASE_ADDR; \
- else /* Rest of it */ \
- /* no change */ ; \
- (paddr) = _v_; \
-CYG_MACRO_END
+#define HAL_VIRT_TO_PHYS_ADDRESS(vaddr, paddr) \
+ CYG_MACRO_START \
+ cyg_uint32 _v_ = (cyg_uint32)(vaddr); \
+ if (_v_ < 128 * SZ_1M) /* SDRAM */ \
+ _v_ += SDRAM_BASE_ADDR; \
+ else /* Rest of it */ \
+ /* no change */ ; \
+ (paddr) = _v_; \
+ CYG_MACRO_END
/*
* translate the virtual address of ram space to physical address
* It is dependent on the implementation of hal_mmu_init
*/
+#if 1
+/*
+ * translate the virtual address of ram space to physical address
+ * It is dependent on the implementation of hal_mmu_init
+ */
+#ifndef RAM_BANK0_SIZE
+#warning using SDRAM_SIZE for RAM_BANK0_SIZE
+#define RAM_BANK0_SIZE SDRAM_SIZE
+#endif
+
+static unsigned long __inline__ hal_virt_to_phy(unsigned long virt)
+{
+ /* SDRAM mappings:
+ 80000000 -> 80000000
+ 90000000 -> 80000000 + (SDRAM_SIZE / 2)
+ */
+ if (virt < 0x08000000) {
+ return virt | (virt < RAM_BANK0_SIZE ? CSD0_BASE_ADDR : CSD1_BASE_ADDR);
+ }
+ if ((virt & 0xF0000000) == CSD0_BASE_ADDR) {
+ virt &= ~0x08000000;
+ if (virt >= CSD0_BASE_ADDR + RAM_BANK0_SIZE) {
+ virt = virt - CSD0_BASE_ADDR + CSD1_BASE_ADDR - RAM_BANK0_SIZE;
+ }
+ }
+ return virt;
+}
+
+/*
+ * remap the physical address of ram space to uncacheable virtual address space
+ * It is dependent on the implementation of hal_mmu_init
+ */
+static unsigned long __inline__ hal_ioremap_nocache(unsigned long phy)
+{
+ /* 0x88000000~0x88FFFFFF is uncacheable memory space which is mapped to SDRAM */
+ if ((phy & 0xF0000000) == CSD0_BASE_ADDR) {
+ phy |= 0x08000000;
+ }
+ if ((phy & 0xF0000000) == CSD1_BASE_ADDR) {
+ phy = (phy - CSD1_BASE_ADDR + CSD0_BASE_ADDR + RAM_BANK0_SIZE) | 0x08000000;
+ }
+ return phy;
+}
+#else
static unsigned long __inline__ hal_virt_to_phy(unsigned long virt)
{
- if(virt < 0x08000000) {
- return virt|0x80000000;
- }
- if((virt & 0xF0000000) == 0x80000000) {
- return virt&(~0x08000000);
- }
- return virt;
+ if (virt < 0x08000000) {
+ return virt|0x80000000;
+ }
+ if((virt & 0xF0000000) == 0x80000000) {
+ return virt&(~0x08000000);
+ }
+ return virt;
}
/*
*/
static unsigned long __inline__ hal_ioremap_nocache(unsigned long phy)
{
- /* 0x88000000~0x87FFFFFF is uncacheable meory space which is mapped to SDRAM*/
- if((phy & 0xF0000000) == 0x80000000) {
- phy |= 0x08000000;
- }
- return phy;
+ /* 0x88000000~0x87FFFFFF is uncacheable meory space which is mapped to SDRAM*/
+ if ((phy & 0xF0000000) == 0x80000000) {
+ phy |= 0x08000000;
+ }
+ return phy;
}
+#endif
//---------------------------------------------------------------------------
#endif // CYGONCE_HAL_BOARD_PLATFORM_PLF_MMAP_H
static void do_mem(int argc, char *argv[]);
RedBoot_cmd("mem",
- "Set a memory location",
- "[-h|-b] [-n] [-a <address>] <data>",
- do_mem
- );
+ "Set a memory location",
+ "[-h|-b] [-n] [-a <address>] <data>",
+ do_mem
+ );
RedBoot_cmd("run",
- "Run an image at a location with MMU off",
- "[<virtual addr>]",
- runImg
- );
+ "Run an image at a location with MMU off",
+ "[<virtual addr>]",
+ runImg
+ );
static void do_mem(int argc, char *argv[])
{
diag_printf(" Set 0x%08lX to 0x%02X\n", address, value);
} else {
diag_printf(" Set 0x%08lX to 0x%02X (result 0x%02X)\n",
- address, value, (int)*(cyg_uint8*)address );
+ address, value, (int)*(cyg_uint8*)address );
}
} else if (mem_half_word) {
if (address & 1) {
diag_printf(" Set 0x%08lX to 0x%04X\n", address, value);
} else {
diag_printf(" Set 0x%08lX to 0x%04X (result 0x%04X)\n",
- address, value, (int)*(cyg_uint16*)address);
+ address, value, (int)*(cyg_uint16*)address);
}
}
} else {
diag_printf(" Set 0x%08lX to 0x%08X\n", address, value);
} else {
diag_printf(" Set 0x%08lX to 0x%08X (result 0x%08X)\n",
- address, value, (int)*(cyg_uint32*)address);
+ address, value, (int)*(cyg_uint32*)address);
}
}
}
void launchRunImg(unsigned long addr)
{
- asm volatile ("mov r12, r0;");
- HAL_MMU_OFF();
- asm volatile (
- "mov r0, #0;"
- "mov r1, r12;"
- "mov r11, #0;"
- "mov r12, #0;"
- "mrs r10, cpsr;"
- "bic r10, r10, #0xF0000000;"
- "msr cpsr_f, r10;"
- "mov pc, r1"
- );
+ asm volatile ("mov r12, r0;");
+ HAL_MMU_OFF();
+ asm volatile (
+ "mov r0, #0;"
+ "mov r1, r12;"
+ "mov r11, #0;"
+ "mov r12, #0;"
+ "mrs r10, cpsr;"
+ "bic r10, r10, #0xF0000000;"
+ "msr cpsr_f, r10;"
+ "mov pc, r1"
+ );
}
static void runImg(int argc,char *argv[])
virt_addr = entry_address;
if (!scan_opts(argc, argv, 1, 0, 0, &virt_addr,
- OPTION_ARG_TYPE_NUM, "virtual address"))
+ OPTION_ARG_TYPE_NUM, "virtual address"))
return;
if (entry_address != 0xFFFFFFFF)
#if defined(CYGSEM_REDBOOT_FLASH_CONFIG) && defined(CYG_HAL_STARTUP_ROMRAM)
RedBoot_cmd("romupdate",
- "Update Redboot with currently running image",
- "",
- romupdate
- );
+ "Update Redboot with currently running image",
+ "",
+ romupdate
+ );
#ifdef CYGPKG_IO_FLASH
void romupdate(int argc, char *argv[])
// Erase area to be programmed
if ((stat = flash_erase(base_addr, CYGBLD_REDBOOT_MIN_IMAGE_SIZE, &err_addr)) != 0) {
diag_printf("Can't erase region at %p: %s\n",
- err_addr, flash_errmsg(stat));
+ err_addr, flash_errmsg(stat));
return;
}
// Now program it
if ((stat = flash_program(base_addr, ram_end,
CYGBLD_REDBOOT_MIN_IMAGE_SIZE, &err_addr)) != 0) {
diag_printf("Can't program region at %p: %s\n",
- err_addr, flash_errmsg(stat));
+ err_addr, flash_errmsg(stat));
}
}
#endif //CYGPKG_IO_FLASH
#endif
#define SD_SZ (RAM_BANK0_SIZE >> 20)
-#define SD_B0 0x800
-#define SD_B1 (0x800 + SD_SZ)
-#define SD_B2 (0x880 + SD_SZ)
#ifdef RAM_BANK1_SIZE
+#define SD_B0 0x800
+#define SD_B1 (SD_B0 + SD_SZ)
+#define SD_B2 (SD_B0 + 0x80 + SD_SZ)
#define SD_HI (0x900 + ((RAM_BANK1_SIZE >> 20) - 1))
#endif
/* xxx00000 */
X_ARM_MMU_SECTION(0x000, 0xF00, 0x001, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* Boot Rom */
X_ARM_MMU_SECTION(0x43f, 0x43f, 0x3c1, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* Internal Registers */
- X_ARM_MMU_SECTION(0x800, 0x000, SD_SZ, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM */
- X_ARM_MMU_SECTION(0x800, 0x800, SD_SZ, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM */
+ X_ARM_MMU_SECTION(0x800, 0x000, SD_SZ, ARM_UNCACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM */
+ X_ARM_MMU_SECTION(0x800, 0x800, SD_SZ, ARM_UNCACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM */
X_ARM_MMU_SECTION(0x800, 0x880, SD_SZ, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM */
#ifdef RAM_BANK1_SIZE
X_ARM_MMU_SECTION(0x900, SD_SZ, SD_SZ, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM */
{
/* GPIOs to set up for TX25/Starterkit-5:
Function GPIO Dir act. FCT
- Lvl
+ Lvl
FEC_RESET PB30 OUT LOW GPIO
FEC_ENABLE PB27 OUT HIGH GPIO
OSCM26_ENABLE PB22 OUT HIGH GPIO
writel(0, IOMUXC_BASE_ADDR + 0x01D4);
writel(0x40, IOMUXC_BASE_ADDR + 0x03CC);
- /*
+ /*
* Set up the FEC_RESET_B and FEC_ENABLE GPIO pins.
* Assert FEC_RESET_B, then power up the PHY by asserting
* FEC_ENABLE, at the same time lifting FEC_RESET_B.
if ((fuse | mac_addr[i]) != mac_addr[i]) {
diag_printf("MAC address fuse cannot be programmed: fuse[%d]=0x%02x -> 0x%02x\n",
- i, fuse, mac_addr[i]);
+ i, fuse, mac_addr[i]);
return -1;
}
if (fuse != mac_addr[i]) {
}
if (fuse_blow(0, i + ((SOC_MAC_ADDR_BASE & 0xff) >> 2), bit)) {
diag_printf("Failed to blow fuse bank 0 row %d bit %d\n",
- i, bit);
+ i, bit);
ret = -1;
goto out;
}
/*
* Translation Table Base Bit Masks
*/
-#define ARM_TRANSLATION_TABLE_MASK 0xFFFFC000
+#define ARM_TRANSLATION_TABLE_MASK 0xFFFFC000
/*
* Domain Access Control Bit Masks
*/
-#define ARM_ACCESS_TYPE_NO_ACCESS(domain_num) (0x0 << (domain_num)*2)
-#define ARM_ACCESS_TYPE_CLIENT(domain_num) (0x1 << (domain_num)*2)
-#define ARM_ACCESS_TYPE_MANAGER(domain_num) (0x3 << (domain_num)*2)
+#define ARM_ACCESS_TYPE_NO_ACCESS(domain_num) (0x0 << ((domain_num) * 2))
+#define ARM_ACCESS_TYPE_CLIENT(domain_num) (0x1 << ((domain_num) * 2))
+#define ARM_ACCESS_TYPE_MANAGER(domain_num) (0x3 << ((domain_num) * 2))
struct ARM_MMU_FIRST_LEVEL_FAULT {
- unsigned int id : 2;
- unsigned int sbz : 30;
+ unsigned int id : 2;
+ unsigned int sbz : 30;
};
#define ARM_MMU_FIRST_LEVEL_FAULT_ID 0x0
struct ARM_MMU_FIRST_LEVEL_PAGE_TABLE {
- unsigned int id : 2;
- unsigned int imp : 2;
- unsigned int domain : 4;
- unsigned int sbz : 1;
- unsigned int base_address : 23;
+ unsigned int id : 2;
+ unsigned int imp : 2;
+ unsigned int domain : 4;
+ unsigned int sbz : 1;
+ unsigned int base_address : 23;
};
#define ARM_MMU_FIRST_LEVEL_PAGE_TABLE_ID 0x1
struct ARM_MMU_FIRST_LEVEL_SECTION {
- unsigned int id : 2;
- unsigned int b : 1;
- unsigned int c : 1;
- unsigned int imp : 1;
- unsigned int domain : 4;
- unsigned int sbz0 : 1;
- unsigned int ap : 2;
- unsigned int sbz1 : 8;
- unsigned int base_address : 12;
+ unsigned int id : 2;
+ unsigned int b : 1;
+ unsigned int c : 1;
+ unsigned int imp : 1;
+ unsigned int domain : 4;
+ unsigned int sbz0 : 1;
+ unsigned int ap : 2;
+ unsigned int sbz1 : 8;
+ unsigned int base_address : 12;
};
#define ARM_MMU_FIRST_LEVEL_SECTION_ID 0x2
struct ARM_MMU_FIRST_LEVEL_RESERVED {
- unsigned int id : 2;
- unsigned int sbz : 30;
+ unsigned int id : 2;
+ unsigned int sbz : 30;
};
#define ARM_MMU_FIRST_LEVEL_RESERVED_ID 0x3
-#define ARM_MMU_FIRST_LEVEL_DESCRIPTOR_ADDRESS(ttb_base, table_index) \
- (unsigned long *)((unsigned long)(ttb_base) + ((table_index) << 2))
+#define ARM_MMU_FIRST_LEVEL_DESCRIPTOR_ADDRESS(ttb_base, table_index) \
+ ((unsigned long *)(ttb_base) + (table_index))
#define ARM_FIRST_LEVEL_PAGE_TABLE_SIZE 0x4000
#define ARM_MMU_SECTION(ttb_base, actual_base, virtual_base, \
- cacheable, bufferable, perm) \
- CYG_MACRO_START \
- register union ARM_MMU_FIRST_LEVEL_DESCRIPTOR desc; \
+ cacheable, bufferable, perm) \
+ CYG_MACRO_START \
+ register union ARM_MMU_FIRST_LEVEL_DESCRIPTOR desc; \
\
- desc.word = 0; \
- desc.section.id = ARM_MMU_FIRST_LEVEL_SECTION_ID; \
- desc.section.domain = 0; \
- desc.section.c = cacheable; \
- desc.section.b = bufferable; \
- desc.section.ap = perm; \
- desc.section.base_address = actual_base; \
- *ARM_MMU_FIRST_LEVEL_DESCRIPTOR_ADDRESS(ttb_base, virtual_base) \
- = desc.word; \
- CYG_MACRO_END
-
-#define X_ARM_MMU_SECTION(abase,vbase,size,cache,buff,access) { \
- int i; int j = abase; int k = vbase; \
- for (i = size; i > 0 ; i--, j++, k++) { \
- ARM_MMU_SECTION(ttb_base, j, k, cache, buff, access); \
- } \
-}
+ desc.word = 0; \
+ desc.section.id = ARM_MMU_FIRST_LEVEL_SECTION_ID; \
+ desc.section.domain = 0; \
+ desc.section.c = cacheable; \
+ desc.section.b = bufferable; \
+ desc.section.ap = perm; \
+ desc.section.base_address = actual_base; \
+ *ARM_MMU_FIRST_LEVEL_DESCRIPTOR_ADDRESS(ttb_base, virtual_base) = desc.word; \
+ CYG_MACRO_END
+
+#define X_ARM_MMU_SECTION(abase,vbase,size,cache,buff,access) \
+ CYG_MACRO_START \
+ int i; int j = abase; int k = vbase; \
+ for (i = size; i > 0 ; i--, j++, k++) { \
+ ARM_MMU_SECTION(ttb_base, j, k, cache, buff, access); \
+ } \
+ CYG_MACRO_END
union ARM_MMU_FIRST_LEVEL_DESCRIPTOR {
- unsigned long word;
- struct ARM_MMU_FIRST_LEVEL_FAULT fault;
- struct ARM_MMU_FIRST_LEVEL_PAGE_TABLE page_table;
- struct ARM_MMU_FIRST_LEVEL_SECTION section;
- struct ARM_MMU_FIRST_LEVEL_RESERVED reserved;
+ unsigned long word;
+ struct ARM_MMU_FIRST_LEVEL_FAULT fault;
+ struct ARM_MMU_FIRST_LEVEL_PAGE_TABLE page_table;
+ struct ARM_MMU_FIRST_LEVEL_SECTION section;
+ struct ARM_MMU_FIRST_LEVEL_RESERVED reserved;
};
-#define ARM_UNCACHEABLE 0
-#define ARM_CACHEABLE 1
-#define ARM_UNBUFFERABLE 0
-#define ARM_BUFFERABLE 1
+#define ARM_UNCACHEABLE 0
+#define ARM_CACHEABLE 1
+#define ARM_UNBUFFERABLE 0
+#define ARM_BUFFERABLE 1
-#define ARM_ACCESS_PERM_NONE_NONE 0
-#define ARM_ACCESS_PERM_RO_NONE 0
-#define ARM_ACCESS_PERM_RO_RO 0
-#define ARM_ACCESS_PERM_RW_NONE 1
-#define ARM_ACCESS_PERM_RW_RO 2
-#define ARM_ACCESS_PERM_RW_RW 3
+#define ARM_ACCESS_PERM_NONE_NONE 0
+#define ARM_ACCESS_PERM_RO_NONE 0
+#define ARM_ACCESS_PERM_RO_RO 0
+#define ARM_ACCESS_PERM_RW_NONE 1
+#define ARM_ACCESS_PERM_RW_RO 2
+#define ARM_ACCESS_PERM_RW_RW 3
/*
* Initialization for the Domain Access Control Register
*/
-#define ARM_ACCESS_DACR_DEFAULT ( \
- ARM_ACCESS_TYPE_MANAGER(0) | \
- ARM_ACCESS_TYPE_NO_ACCESS(1) | \
- ARM_ACCESS_TYPE_NO_ACCESS(2) | \
- ARM_ACCESS_TYPE_NO_ACCESS(3) | \
- ARM_ACCESS_TYPE_NO_ACCESS(4) | \
- ARM_ACCESS_TYPE_NO_ACCESS(5) | \
- ARM_ACCESS_TYPE_NO_ACCESS(6) | \
- ARM_ACCESS_TYPE_NO_ACCESS(7) | \
- ARM_ACCESS_TYPE_NO_ACCESS(8) | \
- ARM_ACCESS_TYPE_NO_ACCESS(9) | \
- ARM_ACCESS_TYPE_NO_ACCESS(10) | \
- ARM_ACCESS_TYPE_NO_ACCESS(11) | \
- ARM_ACCESS_TYPE_NO_ACCESS(12) | \
- ARM_ACCESS_TYPE_NO_ACCESS(13) | \
- ARM_ACCESS_TYPE_NO_ACCESS(14) | \
- ARM_ACCESS_TYPE_NO_ACCESS(15) )
-/*
- * translate the virtual address of ram space to physical address
- * It is dependent on the implementation of hal_mmu_init
- */
-#ifndef RAM_BANK0_SIZE
-#warning using SDRAM_SIZE for RAM_BANK0_SIZE
-#define RAM_BANK0_SIZE SDRAM_SIZE
-#endif
-
-static unsigned long __inline__ hal_virt_to_phy(unsigned long virt)
-{
- /* SDRAM mappings:
- 80000000 -> 80000000
- 90000000 -> 80000000 + (SDRAM_SIZE / 2)
- */
- if (virt < 0x08000000) {
- return virt | (virt < RAM_BANK0_SIZE ? CSD0_BASE_ADDR : CSD1_BASE_ADDR);
- }
- if ((virt & 0xF0000000) == CSD0_BASE_ADDR) {
- virt &= ~0x08000000;
- if (virt >= CSD0_BASE_ADDR + RAM_BANK0_SIZE) {
- virt = virt - CSD0_BASE_ADDR + CSD1_BASE_ADDR - RAM_BANK0_SIZE;
- }
- }
- return virt;
-}
-
-/*
- * remap the physical address of ram space to uncacheable virtual address space
- * It is dependent on the implementation of hal_mmu_init
- */
-static unsigned long __inline__ hal_ioremap_nocache(unsigned long phy)
-{
- /* 0x88000000~0x88FFFFFF is uncacheable memory space which is mapped to SDRAM */
- if ((phy & 0xF0000000) == CSD0_BASE_ADDR) {
- phy |= 0x08000000;
- }
- if ((phy & 0xF0000000) == CSD1_BASE_ADDR) {
- phy = (phy - CSD1_BASE_ADDR + CSD0_BASE_ADDR + RAM_BANK0_SIZE) | 0x08000000;
- }
- return phy;
-}
+#define ARM_ACCESS_DACR_DEFAULT ( \
+ ARM_ACCESS_TYPE_MANAGER(0) | \
+ ARM_ACCESS_TYPE_NO_ACCESS(1) | \
+ ARM_ACCESS_TYPE_NO_ACCESS(2) | \
+ ARM_ACCESS_TYPE_NO_ACCESS(3) | \
+ ARM_ACCESS_TYPE_NO_ACCESS(4) | \
+ ARM_ACCESS_TYPE_NO_ACCESS(5) | \
+ ARM_ACCESS_TYPE_NO_ACCESS(6) | \
+ ARM_ACCESS_TYPE_NO_ACCESS(7) | \
+ ARM_ACCESS_TYPE_NO_ACCESS(8) | \
+ ARM_ACCESS_TYPE_NO_ACCESS(9) | \
+ ARM_ACCESS_TYPE_NO_ACCESS(10) | \
+ ARM_ACCESS_TYPE_NO_ACCESS(11) | \
+ ARM_ACCESS_TYPE_NO_ACCESS(12) | \
+ ARM_ACCESS_TYPE_NO_ACCESS(13) | \
+ ARM_ACCESS_TYPE_NO_ACCESS(14) | \
+ ARM_ACCESS_TYPE_NO_ACCESS(15) )
// ------------------------------------------------------------------------
#endif // ifndef CYGONCE_HAL_MM_H
// End of hal_mm.h
-
-
-
-
-
#else /* __ASSEMBLER__ */
#define UL(a) (a##UL)
-extern char HAL_PLATFORM_EXTRA[];
+extern char HAL_PLATFORM_EXTRA[55];
#define REG8_VAL(a) ((unsigned char)(a))
#define REG16_VAL(a) ((unsigned short)(a))
#define REG32_VAL(a) ((unsigned int)(a))
static channel_data_t channels[] = {
#if CYGHWR_HAL_ARM_SOC_UART1 != 0
{(volatile struct mxc_serial*)UART1_BASE_ADDR, 1000,
- CYGNUM_HAL_INTERRUPT_UART1, CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD},
+ CYGNUM_HAL_INTERRUPT_UART1, CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD},
#endif
#if CYGHWR_HAL_ARM_SOC_UART2 != 0
{(volatile struct mxc_serial*)UART2_BASE_ADDR, 1000,
}
static cyg_bool cyg_hal_plf_serial_getc_nonblock(void *__ch_data,
- cyg_uint8 *ch)
+ cyg_uint8 *ch)
{
channel_data_t *chan = __ch_data;
volatile struct mxc_serial *base = chan->base;
}
static void cyg_hal_plf_serial_write(void *__ch_data, const cyg_uint8 *__buf,
- cyg_uint32 __len)
+ cyg_uint32 __len)
{
CYGARC_HAL_SAVE_GP();
}
cyg_bool cyg_hal_plf_serial_getc_timeout(void *__ch_data,
- cyg_uint8 *ch)
+ cyg_uint8 *ch)
{
int delay_count;
channel_data_t *chan = __ch_data;
}
static int cyg_hal_plf_serial_control(void *__ch_data,
- __comm_control_cmd_t __func, ...)
+ __comm_control_cmd_t __func, ...)
{
static int irq_state = 0;
channel_data_t *chan = __ch_data;
}
static int cyg_hal_plf_serial_isr(void *__ch_data, int *__ctrlc,
- CYG_ADDRWORD __vector, CYG_ADDRWORD __data)
+ CYG_ADDRWORD __vector, CYG_ADDRWORD __data)
{
int res = 0;
channel_data_t *chan = __ch_data;
#include <pkgconf/system.h>
#include CYGBLD_HAL_PLATFORM_H
-#include <cyg/infra/cyg_type.h> // base types
-#include <cyg/infra/cyg_trac.h> // tracing macros
-#include <cyg/infra/cyg_ass.h> // assertion macros
+#include <cyg/infra/cyg_type.h> // base types
+#include <cyg/infra/cyg_trac.h> // tracing macros
+#include <cyg/infra/cyg_ass.h> // assertion macros
-#include <cyg/hal/hal_misc.h> // Size constants
-#include <cyg/hal/hal_io.h> // IO macros
-#include <cyg/hal/hal_arch.h> // Register state info
+#include <cyg/hal/hal_misc.h> // Size constants
+#include <cyg/hal/hal_io.h> // IO macros
+#include <cyg/hal/hal_arch.h> // Register state info
#include <cyg/hal/hal_diag.h>
-#include <cyg/hal/hal_intr.h> // Interrupt names
-#include <cyg/hal/hal_cache.h> // Cache control
-#include <cyg/hal/hal_soc.h> // Hardware definitions
-#include <cyg/hal/hal_mm.h> // MMap table definitions
+#include <cyg/hal/hal_intr.h> // Interrupt names
+#include <cyg/hal/hal_cache.h> // Cache control
+#include <cyg/hal/hal_soc.h> // Hardware definitions
+#include <cyg/hal/hal_mm.h> // MMap table definitions
-#include <cyg/infra/diag.h> // diag_printf
+#include <cyg/infra/diag.h> // diag_printf
#include <cyg/io/imx_nfc.h>
// Most initialization has already been done before we get here.
externC void plf_hardware_init(void);
-#define IIM_PROD_REV_SH 3
-#define IIM_PROD_REV_LEN 5
-#define IIM_SREV_REV_SH 4
-#define IIM_SREV_REV_LEN 4
+#define IIM_PROD_REV_SH 3
+#define IIM_PROD_REV_LEN 5
+#define IIM_SREV_REV_SH 4
+#define IIM_SREV_REV_LEN 4
-#define PROD_SIGNATURE_MX25 0x1F
+#define PROD_SIGNATURE_MX25 0x1F
-#define PROD_SIGNATURE_SUPPORTED_1 PROD_SIGNATURE_MX25
+#define PROD_SIGNATURE_SUPPORTED_1 PROD_SIGNATURE_MX25
-#define CHIP_VERSION_NONE 0xFFFFFFFF // invalid product ID
-#define CHIP_VERSION_UNKNOWN 0xDEADBEEF // invalid chip rev
+#define CHIP_VERSION_NONE 0xFFFFFFFF // invalid product ID
+#define CHIP_VERSION_UNKNOWN 0xDEADBEEF // invalid chip rev
#define PART_NUMBER_OFFSET 12
#define MAJOR_NUMBER_OFFSET 4
*/
static int read_system_rev(void)
{
- int val;
+ int val;
- val = readl(IIM_BASE_ADDR + IIM_PREV_OFF);
+ val = readl(IIM_BASE_ADDR + IIM_PREV_OFF);
- system_rev = 0x25 << PART_NUMBER_OFFSET; /* For MX25 Platform*/
+ system_rev = 0x25 << PART_NUMBER_OFFSET; /* For MX25 Platform*/
/* If the IIM doesn't contain a valid product signature, return
- * the lowest revision number */
- if ((MXC_GET_FIELD(val, IIM_PROD_REV_LEN, IIM_PROD_REV_SH) !=
- PROD_SIGNATURE_SUPPORTED_1)) {
+ * the lowest revision number */
+ if ((MXC_GET_FIELD(val, IIM_PROD_REV_LEN, IIM_PROD_REV_SH) !=
+ PROD_SIGNATURE_SUPPORTED_1)) {
#if 0
- return CHIP_VERSION_NONE;
+ return CHIP_VERSION_NONE;
#endif
- }
+ }
- /* Now trying to retrieve the silicon rev from IIM's SREV register */
- return readl(IIM_BASE_ADDR + IIM_SREV_OFF);
+ /* Now trying to retrieve the silicon rev from IIM's SREV register */
+ return readl(IIM_BASE_ADDR + IIM_SREV_OFF);
}
extern nfc_setup_func_t *nfc_setup;
unsigned int mxc_nfc_soc_setup(unsigned int pg_sz, unsigned int io_sz,
- unsigned int is_mlc, unsigned int num_of_chips);
+ unsigned int is_mlc, unsigned int num_of_chips);
void hal_hardware_init(void)
{
- int ver;
-
- ver = read_system_rev();
- find_correct_chip = ver;
-
- if (ver != CHIP_VERSION_NONE) {
- /* Valid product revision found. Check actual silicon rev from the ROM code. */
- if (ver == 0x0) {
- HAL_PLATFORM_EXTRA[5] = '1';
- HAL_PLATFORM_EXTRA[7] = '0';
- system_rev |= 1 << MAJOR_NUMBER_OFFSET; /*Major Number*/
- system_rev |= 0 << MINOR_NUMBER_OFFSET; /*Minor Number*/
- } else if (ver == 0x1) {
- HAL_PLATFORM_EXTRA[5] = '1';
- HAL_PLATFORM_EXTRA[7] = '1';
- system_rev |= 1 << MAJOR_NUMBER_OFFSET; /*Major Number*/
- system_rev |= 1 << MINOR_NUMBER_OFFSET; /*Minor Number*/
- } else {
- HAL_PLATFORM_EXTRA[5] = 'z';
- HAL_PLATFORM_EXTRA[7] = 'z';
- system_rev |= 1 << MAJOR_NUMBER_OFFSET; /*Major Number*/
- system_rev |= 0 << MINOR_NUMBER_OFFSET; /*Minor Number*/
- find_correct_chip = CHIP_VERSION_UNKNOWN;
- }
- }
-
- // Mask all interrupts
- writel(0xFFFFFFFF, ASIC_NIMASK);
-
- // Make all interrupts do IRQ and not FIQ
- // FIXME: Change this if you use FIQs.
- writel(0, ASIC_INTTYPEH);
- writel(0, ASIC_INTTYPEL);
-
- // Enable caches
- HAL_ICACHE_ENABLE();
- HAL_DCACHE_ENABLE();
-
- // enable EPIT and start it with 32KHz input clock
- writel(0x00010000, EPIT_BASE_ADDR + EPITCR);
-
- // make sure reset is complete
- while ((readl(EPIT_BASE_ADDR + EPITCR) & 0x10000) != 0) {
- }
-
- writel(0x030E0002, EPIT_BASE_ADDR + EPITCR);
- writel(0x030E0003, EPIT_BASE_ADDR + EPITCR);
-
- writel(0, EPIT_BASE_ADDR + EPITCMPR); // always compare with 0
-
- if ((readw(WDOG_BASE_ADDR) & 4) != 0) {
- // increase the WDOG timeout value to the max
- writew(readw(WDOG_BASE_ADDR) | 0xFF00, WDOG_BASE_ADDR);
- }
-
- // Perform any platform specific initializations
- plf_hardware_init();
-
- // Set up eCos/ROM interfaces
- hal_if_init();
-
- nfc_setup = (nfc_setup_func_t*)mxc_nfc_soc_setup;
+ int ver;
+
+ ver = read_system_rev();
+ find_correct_chip = ver;
+
+ if (ver != CHIP_VERSION_NONE) {
+ /* Valid product revision found. Check actual silicon rev from the ROM code. */
+ if (ver == 0x0) {
+ HAL_PLATFORM_EXTRA[5] = '1';
+ HAL_PLATFORM_EXTRA[7] = '0';
+ system_rev |= 1 << MAJOR_NUMBER_OFFSET; /*Major Number*/
+ system_rev |= 0 << MINOR_NUMBER_OFFSET; /*Minor Number*/
+ } else if (ver == 0x1) {
+ HAL_PLATFORM_EXTRA[5] = '1';
+ HAL_PLATFORM_EXTRA[7] = '1';
+ system_rev |= 1 << MAJOR_NUMBER_OFFSET; /*Major Number*/
+ system_rev |= 1 << MINOR_NUMBER_OFFSET; /*Minor Number*/
+ } else {
+ HAL_PLATFORM_EXTRA[5] = 'z';
+ HAL_PLATFORM_EXTRA[7] = 'z';
+ system_rev |= 1 << MAJOR_NUMBER_OFFSET; /*Major Number*/
+ system_rev |= 0 << MINOR_NUMBER_OFFSET; /*Minor Number*/
+ find_correct_chip = CHIP_VERSION_UNKNOWN;
+ }
+ }
+
+ // Mask all interrupts
+ writel(0xFFFFFFFF, ASIC_NIMASK);
+
+ // Make all interrupts do IRQ and not FIQ
+ // FIXME: Change this if you use FIQs.
+ writel(0, ASIC_INTTYPEH);
+ writel(0, ASIC_INTTYPEL);
+
+ // Enable caches
+ HAL_ICACHE_ENABLE();
+ HAL_DCACHE_ENABLE();
+
+ // enable EPIT and start it with 32KHz input clock
+ writel(0x00010000, EPIT_BASE_ADDR + EPITCR);
+
+ // make sure reset is complete
+ while ((readl(EPIT_BASE_ADDR + EPITCR) & 0x10000) != 0) {
+ }
+
+ writel(0x030E0002, EPIT_BASE_ADDR + EPITCR);
+ writel(0x030E0003, EPIT_BASE_ADDR + EPITCR);
+
+ writel(0, EPIT_BASE_ADDR + EPITCMPR); // always compare with 0
+
+ if ((readw(WDOG_BASE_ADDR) & 4) != 0) {
+ // increase the WDOG timeout value to the max
+ writew(readw(WDOG_BASE_ADDR) | 0xFF00, WDOG_BASE_ADDR);
+ }
+
+ // Perform any platform specific initializations
+ plf_hardware_init();
+
+ // Set up eCos/ROM interfaces
+ hal_if_init();
+
+ nfc_setup = (nfc_setup_func_t*)mxc_nfc_soc_setup;
}
// -------------------------------------------------------------------------
return 0 - readl(EPIT_BASE_ADDR + EPITCNR);
}
-#define WDT_MAGIC_1 0x5555
-#define WDT_MAGIC_2 0xAAAA
-#define MXC_WDT_WSR 0x2
+#define WDT_MAGIC_1 0x5555
+#define WDT_MAGIC_2 0xAAAA
+#define MXC_WDT_WSR 0x2
unsigned int i2c_base_addr[] = {
- I2C_BASE_ADDR,
- I2C2_BASE_ADDR,
- I2C3_BASE_ADDR
+ I2C_BASE_ADDR,
+ I2C2_BASE_ADDR,
+ I2C3_BASE_ADDR
};
unsigned int i2c_num = 3;
//
void hal_delay_us(unsigned int usecs)
{
- /*
- * This causes overflow.
- * unsigned int delayCount = (usecs * 32000) / 1000000;
- * So use the following one instead
- */
+ /*
+ * This causes overflow.
+ * unsigned int delayCount = (usecs * 32000) / 1000000;
+ * So use the following one instead
+ */
unsigned int delayCount = (usecs * 512) / 16000;
- if (delayCount == 0) {
- return;
- }
+ if (delayCount == 0) {
+ return;
+ }
- // issue the service sequence instructions
- if ((readw(WDOG_BASE_ADDR) & 4) != 0) {
- writew(WDT_MAGIC_1, WDOG_BASE_ADDR + MXC_WDT_WSR);
- writew(WDT_MAGIC_2, WDOG_BASE_ADDR + MXC_WDT_WSR);
- }
+ // issue the service sequence instructions
+ if ((readw(WDOG_BASE_ADDR) & 4) != 0) {
+ writew(WDT_MAGIC_1, WDOG_BASE_ADDR + MXC_WDT_WSR);
+ writew(WDT_MAGIC_2, WDOG_BASE_ADDR + MXC_WDT_WSR);
+ }
- writel(0x01, EPIT_BASE_ADDR + EPITSR); // clear the compare status bit
+ writel(0x01, EPIT_BASE_ADDR + EPITSR); // clear the compare status bit
- writel(delayCount, EPIT_BASE_ADDR + EPITLR);
+ writel(delayCount, EPIT_BASE_ADDR + EPITLR);
- while ((0x1 & readl(EPIT_BASE_ADDR + EPITSR)) == 0); // return until compare bit is set
- if ((++led_on % 2000) == 0)
- BOARD_DEBUG_LED(0);
+ while ((0x1 & readl(EPIT_BASE_ADDR + EPITSR)) == 0); // return until compare bit is set
+ if ((++led_on % 2000) == 0)
+ BOARD_DEBUG_LED(0);
}
// -------------------------------------------------------------------------
int hal_IRQ_handler(void)
{
#ifdef HAL_EXTENDED_IRQ_HANDLER
- cyg_uint32 index;
+ cyg_uint32 index;
- // Use platform specific IRQ handler, if defined
- // Note: this macro should do a 'return' with the appropriate
- // interrupt number if such an extended interrupt exists. The
- // assumption is that the line after the macro starts 'normal' processing.
- HAL_EXTENDED_IRQ_HANDLER(index);
+ // Use platform specific IRQ handler, if defined
+ // Note: this macro should do a 'return' with the appropriate
+ // interrupt number if such an extended interrupt exists. The
+ // assumption is that the line after the macro starts 'normal' processing.
+ HAL_EXTENDED_IRQ_HANDLER(index);
#endif
- return CYGNUM_HAL_INTERRUPT_NONE; // This shouldn't happen!
+ return CYGNUM_HAL_INTERRUPT_NONE; // This shouldn't happen!
}
//
{
// diag_printf("6hal_interrupt_mask(vector=%d) \n", vector);
#ifdef HAL_EXTENDED_INTERRUPT_MASK
- // Use platform specific handling, if defined
- // Note: this macro should do a 'return' for "extended" values of 'vector'
- // Normal vectors are handled by code subsequent to the macro call.
- HAL_EXTENDED_INTERRUPT_MASK(vector);
+ // Use platform specific handling, if defined
+ // Note: this macro should do a 'return' for "extended" values of 'vector'
+ // Normal vectors are handled by code subsequent to the macro call.
+ HAL_EXTENDED_INTERRUPT_MASK(vector);
#endif
}
// diag_printf("7hal_interrupt_unmask(vector=%d) \n", vector);
#ifdef HAL_EXTENDED_INTERRUPT_UNMASK
- // Use platform specific handling, if defined
- // Note: this macro should do a 'return' for "extended" values of 'vector'
- // Normal vectors are handled by code subsequent to the macro call.
- HAL_EXTENDED_INTERRUPT_UNMASK(vector);
+ // Use platform specific handling, if defined
+ // Note: this macro should do a 'return' for "extended" values of 'vector'
+ // Normal vectors are handled by code subsequent to the macro call.
+ HAL_EXTENDED_INTERRUPT_UNMASK(vector);
#endif
}
// diag_printf("8hal_interrupt_acknowledge(vector=%d) \n", vector);
#ifdef HAL_EXTENDED_INTERRUPT_UNMASK
- // Use platform specific handling, if defined
- // Note: this macro should do a 'return' for "extended" values of 'vector'
- // Normal vectors are handled by code subsequent to the macro call.
- HAL_EXTENDED_INTERRUPT_ACKNOWLEDGE(vector);
+ // Use platform specific handling, if defined
+ // Note: this macro should do a 'return' for "extended" values of 'vector'
+ // Normal vectors are handled by code subsequent to the macro call.
+ HAL_EXTENDED_INTERRUPT_ACKNOWLEDGE(vector);
#endif
}
{
#ifdef HAL_EXTENDED_INTERRUPT_CONFIGURE
- // Use platform specific handling, if defined
- // Note: this macro should do a 'return' for "extended" values of 'vector'
- // Normal vectors are handled by code subsequent to the macro call.
- HAL_EXTENDED_INTERRUPT_CONFIGURE(vector, level, up);
+ // Use platform specific handling, if defined
+ // Note: this macro should do a 'return' for "extended" values of 'vector'
+ // Normal vectors are handled by code subsequent to the macro call.
+ HAL_EXTENDED_INTERRUPT_CONFIGURE(vector, level, up);
#endif
}
{
#ifdef HAL_EXTENDED_INTERRUPT_SET_LEVEL
- // Use platform specific handling, if defined
- // Note: this macro should do a 'return' for "extended" values of 'vector'
- // Normal vectors are handled by code subsequent to the macro call.
- HAL_EXTENDED_INTERRUPT_SET_LEVEL(vector, level);
+ // Use platform specific handling, if defined
+ // Note: this macro should do a 'return' for "extended" values of 'vector'
+ // Normal vectors are handled by code subsequent to the macro call.
+ HAL_EXTENDED_INTERRUPT_SET_LEVEL(vector, level);
#endif
- // Interrupt priorities are not configurable.
+ // Interrupt priorities are not configurable.
}
unsigned int mxc_nfc_soc_setup(unsigned int pg_sz, unsigned int io_sz, unsigned int is_mlc,
unsigned int num_of_chips)
{
- unsigned int tmp ;
- if (is_mlc) {
- tmp = readw(NAND_REG_BASE + NAND_FLASH_CONFIG1_REG_OFF) | (1 << 8);
- } else {
+ unsigned int tmp ;
+ if (is_mlc) {
+ tmp = readw(NAND_REG_BASE + NAND_FLASH_CONFIG1_REG_OFF) | (1 << 8);
+ } else {
tmp = readw(NAND_REG_BASE + NAND_FLASH_CONFIG1_REG_OFF) & ~(1 << 8);
- }
+ }
- writew(tmp, NAND_REG_BASE + NAND_FLASH_CONFIG1_REG_OFF);
- tmp = readl(CCM_BASE_ADDR + CLKCTL_RCSR);
- if (io_sz == 16) {
- tmp |= (1 << 14);
- } else {
+ writew(tmp, NAND_REG_BASE + NAND_FLASH_CONFIG1_REG_OFF);
+ tmp = readl(CCM_BASE_ADDR + CLKCTL_RCSR);
+ if (io_sz == 16) {
+ tmp |= (1 << 14);
+ } else {
tmp &= ~(1 << 14);
- }
+ }
- tmp &= ~(3<<8);
+ tmp &= ~(3<<8);
switch (pg_sz) {
- case 2048:
+ case 2048:
tmp |= (1<<8);
break;
- case 4096:
+ case 4096:
tmp |= (1<<9);
break;
- }
+ }
- writel(tmp, CCM_BASE_ADDR + CLKCTL_RCSR);
+ writel(tmp, CCM_BASE_ADDR + CLKCTL_RCSR);
return MXC_NFC_V1_1;
}
static void check_correct_chip(void)
{
- if (find_correct_chip == CHIP_VERSION_UNKNOWN) {
- diag_printf("Unrecognized chip version: 0x%x!!!\n", read_system_rev());
- diag_printf("Assuming chip version=0x%x\n", system_rev);
- } else if (find_correct_chip == CHIP_VERSION_NONE) {
- diag_printf("Unrecognized chip: 0x%x!!!\n", readl(IIM_BASE_ADDR + IIM_PREV_OFF));
- }
+ if (find_correct_chip == CHIP_VERSION_UNKNOWN) {
+ diag_printf("Unrecognized chip version: 0x%x!!!\n", read_system_rev());
+ diag_printf("Assuming chip version=0x%x\n", system_rev);
+ } else if (find_correct_chip == CHIP_VERSION_NONE) {
+ diag_printf("Unrecognized chip: 0x%x!!!\n", readl(IIM_BASE_ADDR + IIM_PREV_OFF));
+ }
}
RedBoot_init(check_correct_chip, RedBoot_INIT_LAST);
// combination of libbsp and vectors already in use by some
// eCos platforms.
// Usage: #include <cyg/hal/hal_if.h>
-//
+//
//####DESCRIPTIONEND####
//
//=============================================================================
-#include <cyg/infra/cyg_type.h> // types & externC
+#include <cyg/infra/cyg_type.h> // types & externC
#include <cyg/hal/dbg-threads-api.h>
#include <cyg/hal/dbg-thread-syscall.h>
// and eCos share facilities, e.g. the network hardware.
#if defined (CYGPKG_NET) || defined (CYGPKG_NET_LWIP)
#include <cyg/hal/hal_intr.h>
-#include <cyg/hal/drv_api.h> // cyg_drv_dsr_lock(), etc
-#define _ENTER_MONITOR() \
- cyg_uint32 ints; \
- HAL_DISABLE_INTERRUPTS(ints); \
- cyg_drv_dsr_lock()
-
-#define _EXIT_MONITOR() \
- cyg_drv_dsr_unlock(); \
- HAL_RESTORE_INTERRUPTS(ints)
+#include <cyg/hal/drv_api.h> // cyg_drv_dsr_lock(), etc
+#define _ENTER_MONITOR() \
+ cyg_uint32 ints; \
+ HAL_DISABLE_INTERRUPTS(ints); \
+ cyg_drv_dsr_lock()
+
+#define _EXIT_MONITOR() \
+ cyg_drv_dsr_unlock(); \
+ HAL_RESTORE_INTERRUPTS(ints)
#else // !CYGPKG_NET && !CYGPKG_NET_LWIP
#define _ENTER_MONITOR() CYG_EMPTY_STATEMENT
#define _EXIT_MONITOR() CYG_EMPTY_STATEMENT
// of this table.
typedef enum {
- /*
- * For serial ports, the control function may be used to set and get the
- * current baud rate. Usage:
- *
- * err = (*__control)(COMMCTL_SETBAUD, int bits_per_second);
- * err => Zero if successful, -1 if error.
- *
- * baud = (*__control)(COMMCTL_GETBAUD);
- * baud => -1 if error, current baud otherwise.
- */
- __COMMCTL_SETBAUD=0,
- __COMMCTL_GETBAUD,
-
- /*
- * Install and remove debugger interrupt handlers. These are the receiver
- * interrupt routines which are used to change control from a running
- * program to the debugger stub.
- */
- __COMMCTL_INSTALL_DBG_ISR,
- __COMMCTL_REMOVE_DBG_ISR,
-
- /*
- * Disable comm port interrupt. Returns TRUE if interrupt was enabled,
- * FALSE otherwise.
- */
- __COMMCTL_IRQ_DISABLE,
-
- /*
- * Enable comm port interrupt.
- */
- __COMMCTL_IRQ_ENABLE,
-
- /*
- * Returns the number of the interrupt vector used by the debug
- * interrupt handler.
- */
- __COMMCTL_DBG_ISR_VECTOR,
-
- /*
- * Returns the current timeout value and sets a new timeout.
- * Timeout resolution is in milliseconds.
- * old_timeout = (*__control)(__COMMCTL_SET_TIMEOUT,
- * cyg_int32 new_timeout);
- */
- __COMMCTL_SET_TIMEOUT,
-
- /*
- * Forces driver to send all characters which may be buffered in
- * the driver. This only flushes the driver buffers, not necessarily
- * any hardware FIFO, etc.
- */
- __COMMCTL_FLUSH_OUTPUT,
-
- /*
- * Forces driver to enable or disable flushes when a newline is
- * seen in the output stream. Flushing at line boundaries occurs
- * in the driver, not necessarily any hardware FIFO, etc. Line
- * buffering is optional and may only be available in some drivers.
- */
- __COMMCTL_ENABLE_LINE_FLUSH,
- __COMMCTL_DISABLE_LINE_FLUSH,
+ /*
+ * For serial ports, the control function may be used to set and get the
+ * current baud rate. Usage:
+ *
+ * err = (*__control)(COMMCTL_SETBAUD, int bits_per_second);
+ * err => Zero if successful, -1 if error.
+ *
+ * baud = (*__control)(COMMCTL_GETBAUD);
+ * baud => -1 if error, current baud otherwise.
+ */
+ __COMMCTL_SETBAUD=0,
+ __COMMCTL_GETBAUD,
+
+ /*
+ * Install and remove debugger interrupt handlers. These are the receiver
+ * interrupt routines which are used to change control from a running
+ * program to the debugger stub.
+ */
+ __COMMCTL_INSTALL_DBG_ISR,
+ __COMMCTL_REMOVE_DBG_ISR,
+
+ /*
+ * Disable comm port interrupt. Returns TRUE if interrupt was enabled,
+ * FALSE otherwise.
+ */
+ __COMMCTL_IRQ_DISABLE,
+
+ /*
+ * Enable comm port interrupt.
+ */
+ __COMMCTL_IRQ_ENABLE,
+
+ /*
+ * Returns the number of the interrupt vector used by the debug
+ * interrupt handler.
+ */
+ __COMMCTL_DBG_ISR_VECTOR,
+
+ /*
+ * Returns the current timeout value and sets a new timeout.
+ * Timeout resolution is in milliseconds.
+ * old_timeout = (*__control)(__COMMCTL_SET_TIMEOUT,
+ * cyg_int32 new_timeout);
+ */
+ __COMMCTL_SET_TIMEOUT,
+
+ /*
+ * Forces driver to send all characters which may be buffered in
+ * the driver. This only flushes the driver buffers, not necessarily
+ * any hardware FIFO, etc.
+ */
+ __COMMCTL_FLUSH_OUTPUT,
+
+ /*
+ * Forces driver to enable or disable flushes when a newline is
+ * seen in the output stream. Flushing at line boundaries occurs
+ * in the driver, not necessarily any hardware FIFO, etc. Line
+ * buffering is optional and may only be available in some drivers.
+ */
+ __COMMCTL_ENABLE_LINE_FLUSH,
+ __COMMCTL_DISABLE_LINE_FLUSH,
} __comm_control_cmd_t;
-#define CYGNUM_COMM_IF_CH_DATA 0
-#define CYGNUM_COMM_IF_WRITE 1
-#define CYGNUM_COMM_IF_READ 2
-#define CYGNUM_COMM_IF_PUTC 3
-#define CYGNUM_COMM_IF_GETC 4
-#define CYGNUM_COMM_IF_CONTROL 5
-#define CYGNUM_COMM_IF_DBG_ISR 6
-#define CYGNUM_COMM_IF_GETC_TIMEOUT 7
+#define CYGNUM_COMM_IF_CH_DATA 0
+#define CYGNUM_COMM_IF_WRITE 1
+#define CYGNUM_COMM_IF_READ 2
+#define CYGNUM_COMM_IF_PUTC 3
+#define CYGNUM_COMM_IF_GETC 4
+#define CYGNUM_COMM_IF_CONTROL 5
+#define CYGNUM_COMM_IF_DBG_ISR 6
+#define CYGNUM_COMM_IF_GETC_TIMEOUT 7
-#define CYGNUM_COMM_IF_TABLE_SIZE 8
+#define CYGNUM_COMM_IF_TABLE_SIZE 8
typedef volatile CYG_ADDRWORD hal_virtual_comm_table_t[CYGNUM_COMM_IF_TABLE_SIZE];
typedef void* __comm_if_ch_data_t;
typedef void (*__comm_if_write_t)(void* __ch_data, const cyg_uint8* __buf,
- cyg_uint32 __len);
+ cyg_uint32 __len);
typedef int (*__comm_if_read_t)(void* __ch_data, cyg_uint8* __buf,
- cyg_uint32 __len);
+ cyg_uint32 __len);
typedef void (*__comm_if_putc_t)(void* __ch_data, cyg_uint8 __ch);
typedef cyg_uint8 (*__comm_if_getc_t)(void* __ch_data);
-typedef int (*__comm_if_control_t)(void *__ch_data,
- __comm_control_cmd_t __func, ...);
-typedef int (*__comm_if_dbg_isr_t)(void *__ch_data,
- int* __ctrlc, CYG_ADDRWORD __vec,
- CYG_ADDRWORD __data);
+typedef int (*__comm_if_control_t)(void *__ch_data,
+ __comm_control_cmd_t __func, ...);
+typedef int (*__comm_if_dbg_isr_t)(void *__ch_data,
+ int* __ctrlc, CYG_ADDRWORD __vec,
+ CYG_ADDRWORD __data);
typedef cyg_bool (*__comm_if_getc_timeout_t)(void *__ch_data, void *__ch);
-#define __call_COMM0(_n_,_rt_,_t_) \
-static __inline__ _rt_ \
-__call_COMM_##_n_(hal_virtual_comm_table_t t) \
-{ \
- _rt_ res; \
- void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
- _ENTER_MONITOR(); \
- res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp); \
- _EXIT_MONITOR(); \
- return res; \
+#define __call_COMM0(_n_,_rt_,_t_) \
+static __inline__ _rt_ \
+__call_COMM_##_n_(hal_virtual_comm_table_t t) \
+{ \
+ _rt_ res; \
+ void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
+ _ENTER_MONITOR(); \
+ res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp); \
+ _EXIT_MONITOR(); \
+ return res; \
}
-#define __call_voidCOMM(_n_,_rt_,_t_) \
-static __inline__ _rt_ \
-__call_COMM_##_n_(hal_virtual_comm_table_t t) \
-{ \
- void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
- _ENTER_MONITOR(); \
- ((_t_)(t[CYGNUM_COMM_##_n_]))(dp); \
- _EXIT_MONITOR(); \
+#define __call_voidCOMM(_n_,_rt_,_t_) \
+static __inline__ _rt_ \
+__call_COMM_##_n_(hal_virtual_comm_table_t t) \
+{ \
+ void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
+ _ENTER_MONITOR(); \
+ ((_t_)(t[CYGNUM_COMM_##_n_]))(dp); \
+ _EXIT_MONITOR(); \
}
-#define __call_COMM1(_n_,_rt_,_t_,_t1_) \
-static __inline__ _rt_ \
-__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_) \
-{ \
- _rt_ res; \
- void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
- _ENTER_MONITOR(); \
- res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_); \
- _EXIT_MONITOR(); \
- return res; \
+#define __call_COMM1(_n_,_rt_,_t_,_t1_) \
+static __inline__ _rt_ \
+__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_) \
+{ \
+ _rt_ res; \
+ void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
+ _ENTER_MONITOR(); \
+ res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_); \
+ _EXIT_MONITOR(); \
+ return res; \
}
-#define __call_voidCOMM1(_n_,_rt_,_t_,_t1_) \
-static __inline__ _rt_ \
-__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_) \
-{ \
- void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
- _ENTER_MONITOR(); \
- ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_); \
- _EXIT_MONITOR(); \
+#define __call_voidCOMM1(_n_,_rt_,_t_,_t1_) \
+static __inline__ _rt_ \
+__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_) \
+{ \
+ void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
+ _ENTER_MONITOR(); \
+ ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_); \
+ _EXIT_MONITOR(); \
}
-#define __call_COMM2(_n_,_rt_,_t_,_t1_,_t2_) \
-static __inline__ _rt_ \
-__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_) \
-{ \
- _rt_ res; \
- void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
- _ENTER_MONITOR(); \
- res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_); \
- _EXIT_MONITOR(); \
- return res; \
+#define __call_COMM2(_n_,_rt_,_t_,_t1_,_t2_) \
+static __inline__ _rt_ \
+__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_) \
+{ \
+ _rt_ res; \
+ void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
+ _ENTER_MONITOR(); \
+ res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_); \
+ _EXIT_MONITOR(); \
+ return res; \
}
-#define __call_voidCOMM2(_n_,_rt_,_t_,_t1_,_t2_) \
-static __inline__ _rt_ \
-__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_) \
-{ \
- void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
- _ENTER_MONITOR(); \
- ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_); \
- _EXIT_MONITOR(); \
+#define __call_voidCOMM2(_n_,_rt_,_t_,_t1_,_t2_) \
+static __inline__ _rt_ \
+__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_) \
+{ \
+ void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
+ _ENTER_MONITOR(); \
+ ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_); \
+ _EXIT_MONITOR(); \
}
-#define __call_COMM3(_n_,_rt_,_t_,_t1_,_t2_,_t3_) \
-static __inline__ _rt_ \
-__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_, _t3_ _p3_) \
-{ \
- _rt_ res; \
- void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
- _ENTER_MONITOR(); \
- res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_, _p3_); \
- _EXIT_MONITOR(); \
- return res; \
+#define __call_COMM3(_n_,_rt_,_t_,_t1_,_t2_,_t3_) \
+static __inline__ _rt_ \
+__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_, _t3_ _p3_) \
+{ \
+ _rt_ res; \
+ void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
+ _ENTER_MONITOR(); \
+ res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_, _p3_); \
+ _EXIT_MONITOR(); \
+ return res; \
}
-#define __call_voidCOMM3(_n_,_rt_,_t_,_t1_,_t2_,_t3_) \
-static __inline__ _rt_ \
-__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_, _t3_ _p3_) \
-{ \
- void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
- _ENTER_MONITOR(); \
- ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_, _p3_); \
- _EXIT_MONITOR(); \
+#define __call_voidCOMM3(_n_,_rt_,_t_,_t1_,_t2_,_t3_) \
+static __inline__ _rt_ \
+__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_, _t3_ _p3_) \
+{ \
+ void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
+ _ENTER_MONITOR(); \
+ ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_, _p3_); \
+ _EXIT_MONITOR(); \
}
#ifndef CYGACC_COMM_IF_DEFINED
// This macro has not been changed to use inline functions like the
// others, simply because it uses variable arguments, and the change
// would break binary compatibility.
-#define CYGACC_COMM_IF_CONTROL(_t_, args...) \
- ({ int res; \
- _ENTER_MONITOR(); \
- res = ((__comm_if_control_t)((_t_)[CYGNUM_COMM_IF_CONTROL]))(CYGACC_COMM_IF_CH_DATA(_t_), args); \
- _EXIT_MONITOR(); \
- res;})
+#define CYGACC_COMM_IF_CONTROL(_t_, args...) \
+ ({ int res; \
+ _ENTER_MONITOR(); \
+ res = ((__comm_if_control_t)((_t_)[CYGNUM_COMM_IF_CONTROL]))(CYGACC_COMM_IF_CH_DATA(_t_), args); \
+ _EXIT_MONITOR(); \
+ res;})
#define CYGACC_COMM_IF_CONTROL_SET(_t_, _x_) \
- (_t_)[CYGNUM_COMM_IF_CONTROL]=(CYG_ADDRWORD)(_x_)
+ (_t_)[CYGNUM_COMM_IF_CONTROL]=(CYG_ADDRWORD)(_x_)
__call_COMM3(IF_DBG_ISR, int, __comm_if_dbg_isr_t, int *, CYG_ADDRWORD, CYG_ADDRWORD)
#define CYGACC_COMM_IF_DBG_ISR(_t_, _c_, _v_, _d_) \
- __call_COMM_IF_DBG_ISR(_t_, _c_, _v_, _d_)
+ __call_COMM_IF_DBG_ISR(_t_, _c_, _v_, _d_)
#define CYGACC_COMM_IF_DBG_ISR_SET(_t_, _x_) \
- (_t_)[CYGNUM_COMM_IF_DBG_ISR]=(CYG_ADDRWORD)(_x_)
+ (_t_)[CYGNUM_COMM_IF_DBG_ISR]=(CYG_ADDRWORD)(_x_)
__call_COMM1(IF_GETC_TIMEOUT, cyg_bool, __comm_if_getc_timeout_t, void *)
-#define CYGACC_COMM_IF_GETC_TIMEOUT(_t_, _c_) \
- __call_COMM_IF_GETC_TIMEOUT(_t_, _c_)
-#define CYGACC_COMM_IF_GETC_TIMEOUT_SET(_t_, _x_) \
- (_t_)[CYGNUM_COMM_IF_GETC_TIMEOUT]=(CYG_ADDRWORD)(_x_)
+#define CYGACC_COMM_IF_GETC_TIMEOUT(_t_, _c_) \
+ __call_COMM_IF_GETC_TIMEOUT(_t_, _c_)
+#define CYGACC_COMM_IF_GETC_TIMEOUT_SET(_t_, _x_) \
+ (_t_)[CYGNUM_COMM_IF_GETC_TIMEOUT]=(CYG_ADDRWORD)(_x_)
#endif // CYGACC_COMM_IF_DEFINED
//--------------------------------------------------------------------------
-// Main calling interface table. Will be assigned a location by the
+// Main calling interface table. Will be assigned a location by the
// linker script. Both ROM and RAM startup applications will know about
// the location.
-#define CYGNUM_CALL_IF_VERSION 0
-#define CYGNUM_CALL_IF_available_1 1
-#define CYGNUM_CALL_IF_available_2 2
-#define CYGNUM_CALL_IF_available_3 3
-#define CYGNUM_CALL_IF_KILL_VECTOR 4
-#define CYGNUM_CALL_IF_CONSOLE_PROCS 5
-#define CYGNUM_CALL_IF_DEBUG_PROCS 6
-#define CYGNUM_CALL_IF_FLUSH_DCACHE 7
-#define CYGNUM_CALL_IF_FLUSH_ICACHE 8
-#define CYGNUM_CALL_IF_available_9 9
-#define CYGNUM_CALL_IF_available_10 10
-#define CYGNUM_CALL_IF_available_11 11
-#define CYGNUM_CALL_IF_SET_DEBUG_COMM 12
-#define CYGNUM_CALL_IF_SET_CONSOLE_COMM 13
-#define CYGNUM_CALL_IF_MONITOR_VERSION 14
-#define CYGNUM_CALL_IF_DBG_SYSCALL 15
-#define CYGNUM_CALL_IF_RESET 16
-#define CYGNUM_CALL_IF_CONSOLE_INTERRUPT_FLAG 17
-#define CYGNUM_CALL_IF_DELAY_US 18
-#define CYGNUM_CALL_IF_DBG_DATA 19
-#define CYGNUM_CALL_IF_FLASH_CFG_OP 20
-#define CYGNUM_CALL_IF_MONITOR_RETURN 21
-#define CYGNUM_CALL_IF_FLASH_FIS_OP 22
-#define CYGNUM_CALL_IF_FLASH_FIS_OP2 23
-
-#define CYGNUM_CALL_IF_LAST_ENTRY CYGNUM_CALL_IF_FLASH_FIS_OP2
-
-#define CYGNUM_CALL_IF_INSTALL_BPT_FN 35
-
-#define CYGNUM_CALL_IF_TABLE_SIZE 64
+#define CYGNUM_CALL_IF_VERSION 0
+#define CYGNUM_CALL_IF_available_1 1
+#define CYGNUM_CALL_IF_available_2 2
+#define CYGNUM_CALL_IF_available_3 3
+#define CYGNUM_CALL_IF_KILL_VECTOR 4
+#define CYGNUM_CALL_IF_CONSOLE_PROCS 5
+#define CYGNUM_CALL_IF_DEBUG_PROCS 6
+#define CYGNUM_CALL_IF_FLUSH_DCACHE 7
+#define CYGNUM_CALL_IF_FLUSH_ICACHE 8
+#define CYGNUM_CALL_IF_available_9 9
+#define CYGNUM_CALL_IF_available_10 10
+#define CYGNUM_CALL_IF_available_11 11
+#define CYGNUM_CALL_IF_SET_DEBUG_COMM 12
+#define CYGNUM_CALL_IF_SET_CONSOLE_COMM 13
+#define CYGNUM_CALL_IF_MONITOR_VERSION 14
+#define CYGNUM_CALL_IF_DBG_SYSCALL 15
+#define CYGNUM_CALL_IF_RESET 16
+#define CYGNUM_CALL_IF_CONSOLE_INTERRUPT_FLAG 17
+#define CYGNUM_CALL_IF_DELAY_US 18
+#define CYGNUM_CALL_IF_DBG_DATA 19
+#define CYGNUM_CALL_IF_FLASH_CFG_OP 20
+#define CYGNUM_CALL_IF_MONITOR_RETURN 21
+#define CYGNUM_CALL_IF_FLASH_FIS_OP 22
+#define CYGNUM_CALL_IF_FLASH_FIS_OP2 23
+
+#define CYGNUM_CALL_IF_LAST_ENTRY CYGNUM_CALL_IF_FLASH_FIS_OP2
+
+#define CYGNUM_CALL_IF_INSTALL_BPT_FN 35
+
+#define CYGNUM_CALL_IF_TABLE_SIZE 64
externC volatile CYG_ADDRWORD hal_virtual_vector_table[CYGNUM_CALL_IF_TABLE_SIZE];
// Table version contains version information for both the CALL table
// itself (the number of the last active entry in the table), and the
// COMM table (the size of the table).
-#define CYGNUM_CALL_IF_TABLE_VERSION_CALL CYGNUM_CALL_IF_LAST_ENTRY
-#define CYGNUM_CALL_IF_TABLE_VERSION_CALL_HACK (CYGNUM_CALL_IF_TABLE_SIZE+1)
-#define CYGNUM_CALL_IF_TABLE_VERSION_CALL_MAX CYGNUM_CALL_IF_TABLE_SIZE
-#define CYGNUM_CALL_IF_TABLE_VERSION_COMM CYGNUM_COMM_IF_TABLE_SIZE
-#define CYGNUM_CALL_IF_TABLE_VERSION_CALL_MASK 0x0000ffff
-#define CYGNUM_CALL_IF_TABLE_VERSION_COMM_MASK 0xffff0000
-#define CYGNUM_CALL_IF_TABLE_VERSION_COMM_shift 16
+#define CYGNUM_CALL_IF_TABLE_VERSION_CALL CYGNUM_CALL_IF_LAST_ENTRY
+#define CYGNUM_CALL_IF_TABLE_VERSION_CALL_HACK (CYGNUM_CALL_IF_TABLE_SIZE+1)
+#define CYGNUM_CALL_IF_TABLE_VERSION_CALL_MAX CYGNUM_CALL_IF_TABLE_SIZE
+#define CYGNUM_CALL_IF_TABLE_VERSION_COMM CYGNUM_COMM_IF_TABLE_SIZE
+#define CYGNUM_CALL_IF_TABLE_VERSION_CALL_MASK 0x0000ffff
+#define CYGNUM_CALL_IF_TABLE_VERSION_COMM_MASK 0xffff0000
+#define CYGNUM_CALL_IF_TABLE_VERSION_COMM_shift 16
// These are special debug/console procs IDs
// allowing the application to temporarily disable mangling
// or temporarily switch in different console procs.
#define CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT -1
-#define CYGNUM_CALL_IF_SET_COMM_ID_EMPTY -2
-#define CYGNUM_CALL_IF_SET_COMM_ID_MANGLER -3
+#define CYGNUM_CALL_IF_SET_COMM_ID_EMPTY -2
+#define CYGNUM_CALL_IF_SET_COMM_ID_MANGLER -3
// The below is a (messy) attempt at adding some type safety to the
// above array. At the same time, the accessors allow the
typedef int (__call_if_set_console_comm_t)(int __comm_id);
typedef void* __call_if_dbg_data_t;
typedef int (__call_if_dbg_syscall_t) (enum dbg_syscall_ids id,
- union dbg_thread_syscall_parms *p );
+ union dbg_thread_syscall_parms *p);
typedef void (__call_if_reset_t)(void);
typedef int __call_if_console_interrupt_flag_t;
typedef void (__call_if_delay_us_t)(cyg_int32 usecs);
// This allows a single virtual vector interface, with widely varying functionality
//
struct cyg_fconfig {
- char *key; // Datum 'key'
- int keylen; // Length of key
- void *val; // Pointer to data
- int type; // Type of datum
- int offset; // Offset within data (used by _NEXT)
+ char *key; // Datum 'key'
+ int keylen; // Length of key
+ void *val; // Pointer to data
+ int type; // Type of datum
+ int offset; // Offset within data (used by _NEXT)
};
typedef cyg_bool (__call_if_flash_cfg_op_fn_t)(int __oper, struct cyg_fconfig *__data);
#ifndef CYGACC_CALL_IF_DEFINED
-#define __data_VV(_n_,_tt_) \
-static __inline__ _tt_ \
-__call_vv_##_n_(void) \
-{ \
- return ((_tt_)hal_virtual_vector_table[_n_]); \
+#define __data_VV(_n_,_tt_) \
+static __inline__ _tt_ \
+__call_vv_##_n_(void) \
+{ \
+ return ((_tt_)hal_virtual_vector_table[_n_]); \
}
-#define __call_VV0(_n_,_tt_,_rt_) \
-static __inline__ _rt_ \
-__call_vv_##_n_(void) \
-{ \
- _rt_ res; \
- _ENTER_MONITOR(); \
- res = ((_tt_ *)hal_virtual_vector_table[_n_])(); \
- _EXIT_MONITOR(); \
- return res; \
+#define __call_VV0(_n_,_tt_,_rt_) \
+static __inline__ _rt_ \
+__call_vv_##_n_(void) \
+{ \
+ _rt_ res; \
+ _ENTER_MONITOR(); \
+ res = ((_tt_ *)hal_virtual_vector_table[_n_])(); \
+ _EXIT_MONITOR(); \
+ return res; \
}
-#define __call_voidVV0(_n_,_tt_,_rt_) \
-static __inline__ _rt_ \
-__call_vv_##_n_(void) \
-{ \
- _ENTER_MONITOR(); \
- ((_tt_ *)hal_virtual_vector_table[_n_])(); \
- _EXIT_MONITOR(); \
+#define __call_voidVV0(_n_,_tt_,_rt_) \
+static __inline__ _rt_ \
+__call_vv_##_n_(void) \
+{ \
+ _ENTER_MONITOR(); \
+ ((_tt_ *)hal_virtual_vector_table[_n_])(); \
+ _EXIT_MONITOR(); \
}
-#define __call_VV1(_n_,_tt_,_rt_,_t1_) \
-static __inline__ _rt_ \
-__call_vv_##_n_(_t1_ _p1_) \
-{ \
- _rt_ res; \
- _ENTER_MONITOR(); \
- res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_); \
- _EXIT_MONITOR(); \
- return res; \
+#define __call_VV1(_n_,_tt_,_rt_,_t1_) \
+static __inline__ _rt_ \
+__call_vv_##_n_(_t1_ _p1_) \
+{ \
+ _rt_ res; \
+ _ENTER_MONITOR(); \
+ res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_); \
+ _EXIT_MONITOR(); \
+ return res; \
}
-#define __call_voidVV1(_n_,_tt_,_rt_,_t1_) \
-static __inline__ _rt_ \
-__call_vv_##_n_(_t1_ _p1_) \
-{ \
- _ENTER_MONITOR(); \
- ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_); \
- _EXIT_MONITOR(); \
+#define __call_voidVV1(_n_,_tt_,_rt_,_t1_) \
+static __inline__ _rt_ \
+__call_vv_##_n_(_t1_ _p1_) \
+{ \
+ _ENTER_MONITOR(); \
+ ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_); \
+ _EXIT_MONITOR(); \
}
-#define __call_VV2(_n_,_tt_,_rt_,_t1_,_t2_) \
-static __inline__ _rt_ \
-__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_) \
-{ \
- _rt_ res; \
- _ENTER_MONITOR(); \
- res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_); \
- _EXIT_MONITOR(); \
- return res; \
+#define __call_VV2(_n_,_tt_,_rt_,_t1_,_t2_) \
+static __inline__ _rt_ \
+__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_) \
+{ \
+ _rt_ res; \
+ _ENTER_MONITOR(); \
+ res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_); \
+ _EXIT_MONITOR(); \
+ return res; \
}
-#define __call_voidVV2(_n_,_tt_,_rt_,_t1_,_t2_) \
-static __inline__ _rt_ \
-__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_) \
-{ \
- _ENTER_MONITOR(); \
- ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_); \
- _EXIT_MONITOR(); \
+#define __call_voidVV2(_n_,_tt_,_rt_,_t1_,_t2_) \
+static __inline__ _rt_ \
+__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_) \
+{ \
+ _ENTER_MONITOR(); \
+ ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_); \
+ _EXIT_MONITOR(); \
}
-#define __call_VV3(_n_,_tt_,_rt_,_t1_,_t2_,_t3_) \
-static __inline__ _rt_ \
-__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_) \
-{ \
- _rt_ res; \
- _ENTER_MONITOR(); \
- res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_); \
- _EXIT_MONITOR(); \
- return res; \
+#define __call_VV3(_n_,_tt_,_rt_,_t1_,_t2_,_t3_) \
+static __inline__ _rt_ \
+__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_) \
+{ \
+ _rt_ res; \
+ _ENTER_MONITOR(); \
+ res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_); \
+ _EXIT_MONITOR(); \
+ return res; \
}
-#define __call_voidVV3(_n_,_tt_,_rt_,_t1_,_t2_,_t3_) \
-static __inline__ _rt_ \
-__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_) \
-{ \
- _ENTER_MONITOR(); \
- ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_); \
- _EXIT_MONITOR(); \
+#define __call_voidVV3(_n_,_tt_,_rt_,_t1_,_t2_,_t3_) \
+static __inline__ _rt_ \
+__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_) \
+{ \
+ _ENTER_MONITOR(); \
+ ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_); \
+ _EXIT_MONITOR(); \
}
-#define __call_VV4(_n_,_tt_,_rt_,_t1_,_t2_,_t3_,_t4_) \
-static __inline__ _rt_ \
-__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_, _t4_ _p4_) \
-{ \
- _rt_ res; \
- _ENTER_MONITOR(); \
- res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_,_p4_); \
- _EXIT_MONITOR(); \
- return res; \
+#define __call_VV4(_n_,_tt_,_rt_,_t1_,_t2_,_t3_,_t4_) \
+static __inline__ _rt_ \
+__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_, _t4_ _p4_) \
+{ \
+ _rt_ res; \
+ _ENTER_MONITOR(); \
+ res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_,_p4_); \
+ _EXIT_MONITOR(); \
+ return res; \
}
-#define __call_voidVV4(_n_,_tt_,_rt_,_t1_,_t2_,_t3_,_t4_) \
-static __inline__ _rt_ \
-__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_, _t4_ _p4_) \
-{ \
- _ENTER_MONITOR(); \
- ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_,_p4_); \
- _EXIT_MONITOR(); \
+#define __call_voidVV4(_n_,_tt_,_rt_,_t1_,_t2_,_t3_,_t4_) \
+static __inline__ _rt_ \
+__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_, _t4_ _p4_) \
+{ \
+ _ENTER_MONITOR(); \
+ ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_,_p4_); \
+ _EXIT_MONITOR(); \
}
-#define CYGACC_DATA_VV(t,e) __call_vv_##e()
-#define CYGACC_CALL_VV0(t,e) __call_vv_##e
-#define CYGACC_CALL_VV1(t,e,p1) __call_vv_##e((p1))
-#define CYGACC_CALL_VV2(t,e,p1,p2) __call_vv_##e((p1),(p2))
-#define CYGACC_CALL_VV3(t,e,p1,p2,p3) __call_vv_##e((p1),(p2),(p3))
+#define CYGACC_DATA_VV(t,e) __call_vv_##e()
+#define CYGACC_CALL_VV0(t,e) __call_vv_##e
+#define CYGACC_CALL_VV1(t,e,p1) __call_vv_##e((p1))
+#define CYGACC_CALL_VV2(t,e,p1,p2) __call_vv_##e((p1),(p2))
+#define CYGACC_CALL_VV3(t,e,p1,p2,p3) __call_vv_##e((p1),(p2),(p3))
#define CYGACC_CALL_VV4(t,e,p1,p2,p3,p4) __call_vv_##e((p1),(p2),(p3),(p4))
#define CYGACC_CALL_IF_VERSION() \
//
// Access persistent data store - kept in FLASH or EEPROM by RedBoot
//
-#define CYGNUM_CALL_IF_FLASH_CFG_GET (0) // Get a particular fconfig key
-#define CYGNUM_CALL_IF_FLASH_CFG_NEXT (1) // Enumerate keys (get the next one)
-#define CYGNUM_CALL_IF_FLASH_CFG_SET (2) // Update particular fconfig key
+#define CYGNUM_CALL_IF_FLASH_CFG_GET 0 // Get a particular fconfig key
+#define CYGNUM_CALL_IF_FLASH_CFG_NEXT 1 // Enumerate keys (get the next one)
+#define CYGNUM_CALL_IF_FLASH_CFG_SET 2 // Update particular fconfig key
#define CYGACC_CALL_IF_FLASH_CFG_OP2(_o_,_d_) \
CYGACC_CALL_VV2(__call_if_flash_cfg_op_fn_t*, CYGNUM_CALL_IF_FLASH_CFG_OP, (_o_),(_d_))
__call_VV2(CYGNUM_CALL_IF_FLASH_CFG_OP, __call_if_flash_cfg_op_fn_t, cyg_bool, int, struct cyg_fconfig *)
static __inline__ cyg_bool
__call_if_flash_cfg_op(int op, char *key, void *data, int type)
{
- struct cyg_fconfig info;
- info.key = key;
- info.val = data;
- info.type = type;
- info.offset = 0;
- return CYGACC_CALL_IF_FLASH_CFG_OP2(op, &info);
+ struct cyg_fconfig info;
+ info.key = key;
+ info.val = data;
+ info.type = type;
+ info.offset = 0;
+ return CYGACC_CALL_IF_FLASH_CFG_OP2(op, &info);
}
#define CYGACC_CALL_IF_FLASH_CFG_OP(_o_,_k_,_d_,_t_) \
__call_if_flash_cfg_op(_o_,_k_,_d_,_t_)
__call_VV3(CYGNUM_CALL_IF_FLASH_FIS_OP, __call_if_flash_fis_op_fn_t, cyg_bool, int, char *, void *)
#define CYGACC_CALL_IF_FLASH_FIS_OP_SET(_x_) \
hal_virtual_vector_table[CYGNUM_CALL_IF_FLASH_FIS_OP]=(CYG_ADDRWORD)(_x_)
-#define CYGNUM_CALL_IF_FLASH_FIS_GET_FLASH_BASE (0)
-#define CYGNUM_CALL_IF_FLASH_FIS_GET_SIZE (1)
-#define CYGNUM_CALL_IF_FLASH_FIS_GET_MEM_BASE (2)
-#define CYGNUM_CALL_IF_FLASH_FIS_GET_ENTRY_POINT (3)
-#define CYGNUM_CALL_IF_FLASH_FIS_GET_DATA_LENGTH (4)
-#define CYGNUM_CALL_IF_FLASH_FIS_GET_DESC_CKSUM (5)
-#define CYGNUM_CALL_IF_FLASH_FIS_GET_FILE_CKSUM (6)
+#define CYGNUM_CALL_IF_FLASH_FIS_GET_FLASH_BASE 0
+#define CYGNUM_CALL_IF_FLASH_FIS_GET_SIZE 1
+#define CYGNUM_CALL_IF_FLASH_FIS_GET_MEM_BASE 2
+#define CYGNUM_CALL_IF_FLASH_FIS_GET_ENTRY_POINT 3
+#define CYGNUM_CALL_IF_FLASH_FIS_GET_DATA_LENGTH 4
+#define CYGNUM_CALL_IF_FLASH_FIS_GET_DESC_CKSUM 5
+#define CYGNUM_CALL_IF_FLASH_FIS_GET_FILE_CKSUM 6
#define CYGACC_CALL_IF_FLASH_FIS_OP2(_o_,_k_,_d_) \
CYGACC_CALL_VV3(__call_if_flash_fis_op2_fn_t*, CYGNUM_CALL_IF_FLASH_FIS_OP2, (_o_),(_k_),(_d_))
__call_VV3(CYGNUM_CALL_IF_FLASH_FIS_OP2, __call_if_flash_fis_op2_fn_t, int, int, unsigned int, struct fis_table_entry *)
#define CYGACC_CALL_IF_FLASH_FIS_OP2_SET(_x_) \
hal_virtual_vector_table[CYGNUM_CALL_IF_FLASH_FIS_OP2]=(CYG_ADDRWORD)(_x_)
-#define CYGNUM_CALL_IF_FLASH_FIS_GET_VERSION (0)
-#define CYGNUM_CALL_IF_FLASH_FIS_INIT (1)
-#define CYGNUM_CALL_IF_FLASH_FIS_GET_ENTRY_COUNT (2)
-#define CYGNUM_CALL_IF_FLASH_FIS_GET_ENTRY (3)
-#define CYGNUM_CALL_IF_FLASH_FIS_START_UPDATE (4)
-#define CYGNUM_CALL_IF_FLASH_FIS_FINISH_UPDATE (5)
-#define CYGNUM_CALL_IF_FLASH_FIS_MODIFY_ENTRY (6)
-
+#define CYGNUM_CALL_IF_FLASH_FIS_GET_VERSION 0
+#define CYGNUM_CALL_IF_FLASH_FIS_INIT 1
+#define CYGNUM_CALL_IF_FLASH_FIS_GET_ENTRY_COUNT 2
+#define CYGNUM_CALL_IF_FLASH_FIS_GET_ENTRY 3
+#define CYGNUM_CALL_IF_FLASH_FIS_START_UPDATE 4
+#define CYGNUM_CALL_IF_FLASH_FIS_FINISH_UPDATE 5
+#define CYGNUM_CALL_IF_FLASH_FIS_MODIFY_ENTRY 6
// These need to be kept uptodate with the (unadorned) masters
// in RedBoot's flash_config.h:
-#define CYGNUM_FLASH_CFG_TYPE_CONFIG_EMPTY 0
-#define CYGNUM_FLASH_CFG_TYPE_CONFIG_BOOL 1
-#define CYGNUM_FLASH_CFG_TYPE_CONFIG_INT 2
-#define CYGNUM_FLASH_CFG_TYPE_CONFIG_STRING 3
-#define CYGNUM_FLASH_CFG_TYPE_CONFIG_SCRIPT 4
-#define CYGNUM_FLASH_CFG_TYPE_CONFIG_IP 5
-#define CYGNUM_FLASH_CFG_TYPE_CONFIG_ESA 6
+#define CYGNUM_FLASH_CFG_TYPE_CONFIG_EMPTY 0
+#define CYGNUM_FLASH_CFG_TYPE_CONFIG_BOOL 1
+#define CYGNUM_FLASH_CFG_TYPE_CONFIG_INT 2
+#define CYGNUM_FLASH_CFG_TYPE_CONFIG_STRING 3
+#define CYGNUM_FLASH_CFG_TYPE_CONFIG_SCRIPT 4
+#define CYGNUM_FLASH_CFG_TYPE_CONFIG_IP 5
+#define CYGNUM_FLASH_CFG_TYPE_CONFIG_ESA 6
#endif // CYGACC_CALL_IF_DEFINED
#else
#if defined(CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT) \
- || defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)
+ || defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)
// Then other code might invoke this macro
-#define HAL_CTRLC_CHECK(a1,a2) (0) // Nothing, no CTRLC here
+#define HAL_CTRLC_CHECK(a1,a2) 0 // Nothing, no CTRLC here
#endif
#endif // CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
// Purpose: Helper functions for stub, specific to eCos HAL
// Description: Parts of the GDB stub requirements are provided by
// the eCos HAL, rather than target and/or board specific
-// code.
+// code.
//
//####DESCRIPTIONEND####
//
HAL_SavedRegisters *_hal_registers;
target_register_t registers[HAL_STUB_REGISTERS_SIZE];
target_register_t alt_registers[HAL_STUB_REGISTERS_SIZE] ; // Thread or saved process state
-target_register_t * _registers = registers; // Pointer to current set of registers
+target_register_t *_registers = registers; // Pointer to current set of registers
#ifndef CYGPKG_REDBOOT
target_register_t orig_registers[HAL_STUB_REGISTERS_SIZE]; // Registers to get back to original state
#endif
// Not all GDBs understand this.
static const char * const _hw_stop_str[] = {
- "",
- "hbreak",
- "watch",
- "rwatch",
- "awatch"
+ "",
+ "hbreak",
+ "watch",
+ "rwatch",
+ "awatch"
};
#endif // HAL_STUB_HW_SEND_STOP_REASON_TEXT
#ifndef CYGARC_STUB_REGISTER_ACCESS_DEFINED
// Return the currently-saved value corresponding to register REG of
// the exception context.
-target_register_t
+target_register_t
get_register (regnames_t reg)
{
- return _registers[reg];
+ return _registers[reg];
}
#endif
int
get_register_valid (regnames_t reg)
{
- return _registers_valid[reg];
+ return _registers_valid[reg];
}
#endif
#ifndef CYGARC_STUB_REGISTER_ACCESS_DEFINED
// Store VALUE in the register corresponding to WHICH in the exception
// context.
-void
+void
put_register (regnames_t which, target_register_t value)
{
#ifdef CYGPKG_HAL_MIPS_VR4300
- // This is a rather nasty kludge to compensate for the fact that
- // the VR4300 GDB is rather old and does not support proper 64 bit
- // registers. The only time this really matters is when setting
- // the PC after loading an executable. So here we detect this case
- // and artificially sign extend it.
-
- if( which == PC && (value & 0x0000000080000000ULL ) )
- {
- value |= 0xFFFFFFFF00000000ULL;
- }
-#endif
- _registers[which] = value;
+ // This is a rather nasty kludge to compensate for the fact that
+ // the VR4300 GDB is rather old and does not support proper 64 bit
+ // registers. The only time this really matters is when setting
+ // the PC after loading an executable. So here we detect this case
+ // and artificially sign extend it.
+
+ if( which == PC && (value & 0x0000000080000000ULL ) )
+ {
+ value |= 0xFFFFFFFF00000000ULL;
+ }
+#endif
+ _registers[which] = value;
}
#endif // CYGARC_STUB_REGISTER_ACCESS_DEFINED
#endif
// Write C to the current serial port.
-void
+void
putDebugChar (int c)
{
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
- __call_if_debug_procs_t __debug_procs = CYGACC_CALL_IF_DEBUG_PROCS();
- CYGACC_COMM_IF_PUTC(*__debug_procs, c);
+ __call_if_debug_procs_t __debug_procs = CYGACC_CALL_IF_DEBUG_PROCS();
+ CYGACC_COMM_IF_PUTC(*__debug_procs, c);
#elif defined(CYGPKG_CYGMON)
- ecos_bsp_console_putc(c);
+ ecos_bsp_console_putc(c);
#else
- HAL_STUB_PLATFORM_PUT_CHAR(c);
+ HAL_STUB_PLATFORM_PUT_CHAR(c);
#endif
}
// Read one character from the current serial port.
-int
+int
getDebugChar (void)
{
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
- __call_if_debug_procs_t __debug_procs = CYGACC_CALL_IF_DEBUG_PROCS();
- return CYGACC_COMM_IF_GETC(*__debug_procs);
+ __call_if_debug_procs_t __debug_procs = CYGACC_CALL_IF_DEBUG_PROCS();
+ return CYGACC_COMM_IF_GETC(*__debug_procs);
#elif defined(CYGPKG_CYGMON)
- return ecos_bsp_console_getc();
+ return ecos_bsp_console_getc();
#else
- return HAL_STUB_PLATFORM_GET_CHAR();
+ return HAL_STUB_PLATFORM_GET_CHAR();
#endif
}
hal_flush_output(void)
{
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
- __call_if_debug_procs_t __debug_procs = CYGACC_CALL_IF_DEBUG_PROCS();
- CYGACC_COMM_IF_CONTROL(*__debug_procs, __COMMCTL_FLUSH_OUTPUT);
+ __call_if_debug_procs_t __debug_procs = CYGACC_CALL_IF_DEBUG_PROCS();
+ CYGACC_COMM_IF_CONTROL(*__debug_procs, __COMMCTL_FLUSH_OUTPUT);
#endif
}
// Set the baud rate for the current serial port.
-void
-__set_baud_rate (int baud)
+void
+__set_baud_rate (int baud)
{
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
- __call_if_debug_procs_t __debug_procs = CYGACC_CALL_IF_DEBUG_PROCS();
- CYGACC_COMM_IF_CONTROL(*__debug_procs, __COMMCTL_SETBAUD, baud);
+ __call_if_debug_procs_t __debug_procs = CYGACC_CALL_IF_DEBUG_PROCS();
+ CYGACC_COMM_IF_CONTROL(*__debug_procs, __COMMCTL_SETBAUD, baud);
#elif defined(CYGPKG_CYGMON)
- // FIXME!
+ // FIXME!
#else
- HAL_STUB_PLATFORM_SET_BAUD_RATE(baud);
+ HAL_STUB_PLATFORM_SET_BAUD_RATE(baud);
#endif
}
typedef struct
{
- t_inst *targetAddr;
- t_inst savedInstr;
+ t_inst *targetAddr;
+ t_inst savedInstr;
} instrBuffer;
static instrBuffer break_buffer;
volatile int cyg_hal_gdb_running_step = 0;
-void
+void
cyg_hal_gdb_place_break (target_register_t pc)
{
- cyg_hal_gdb_interrupt( pc ); // Let's hope this becomes a drop-through:
+ cyg_hal_gdb_interrupt( pc ); // Let's hope this becomes a drop-through:
}
-void
+void
cyg_hal_gdb_interrupt (target_register_t pc)
{
- t_inst break_inst = HAL_BREAKINST;
+ t_inst break_inst = HAL_BREAKINST;
- CYGARC_HAL_SAVE_GP();
+ CYGARC_HAL_SAVE_GP();
- // Clear flag that we Continued instead of Stepping
- cyg_hal_gdb_running_step = 0;
- // and override existing break? So that a ^C takes effect...
- if (NULL != break_buffer.targetAddr)
- cyg_hal_gdb_remove_break( (target_register_t)break_buffer.targetAddr );
+ // Clear flag that we Continued instead of Stepping
+ cyg_hal_gdb_running_step = 0;
+ // and override existing break? So that a ^C takes effect...
+ if (NULL != break_buffer.targetAddr)
+ cyg_hal_gdb_remove_break( (target_register_t)break_buffer.targetAddr );
- if (NULL == break_buffer.targetAddr) {
- // Not always safe to read/write directly to program
- // memory due to possibly unaligned instruction, use the
- // provided memory functions instead.
- __read_mem_safe(&break_buffer.savedInstr, (t_inst*)pc, HAL_BREAKINST_SIZE);
- __write_mem_safe(&break_inst, (t_inst*)pc, HAL_BREAKINST_SIZE);
+ if (NULL == break_buffer.targetAddr) {
+ // Not always safe to read/write directly to program
+ // memory due to possibly unaligned instruction, use the
+ // provided memory functions instead.
+ __read_mem_safe(&break_buffer.savedInstr, (t_inst*)pc, HAL_BREAKINST_SIZE);
+ __write_mem_safe(&break_inst, (t_inst*)pc, HAL_BREAKINST_SIZE);
- // Save the PC where we put the break, so we can remove
- // it after the target takes the break.
- break_buffer.targetAddr = (t_inst*)pc;
+ // Save the PC where we put the break, so we can remove
+ // it after the target takes the break.
+ break_buffer.targetAddr = (t_inst*)pc;
- __data_cache(CACHE_FLUSH);
- __instruction_cache(CACHE_FLUSH);
- }
+ __data_cache(CACHE_FLUSH);
+ __instruction_cache(CACHE_FLUSH);
+ }
- CYGARC_HAL_RESTORE_GP();
+ CYGARC_HAL_RESTORE_GP();
}
-int
+int
cyg_hal_gdb_remove_break (target_register_t pc)
{
- if ( cyg_hal_gdb_running_step )
- return 0;
+ if ( cyg_hal_gdb_running_step )
+ return 0;
- if ((t_inst*)pc == break_buffer.targetAddr) {
+ if ((t_inst*)pc == break_buffer.targetAddr) {
- __write_mem_safe(&break_buffer.savedInstr, (t_inst*)pc, HAL_BREAKINST_SIZE);
- break_buffer.targetAddr = NULL;
+ __write_mem_safe(&break_buffer.savedInstr, (t_inst*)pc, HAL_BREAKINST_SIZE);
+ break_buffer.targetAddr = NULL;
- __data_cache(CACHE_FLUSH);
- __instruction_cache(CACHE_FLUSH);
- return 1;
- }
- return 0;
+ __data_cache(CACHE_FLUSH);
+ __instruction_cache(CACHE_FLUSH);
+ return 1;
+ }
+ return 0;
}
-int
+int
cyg_hal_gdb_break_is_set (void)
{
- if (NULL != break_buffer.targetAddr) {
- return 1;
- }
- return 0;
+ if (NULL != break_buffer.targetAddr) {
+ return 1;
+ }
+ return 0;
}
#endif // CYGPKG_HAL_ARM
static void
interruptible(int state)
{
- static int __interrupts_suspended = 0;
+ static int __interrupts_suspended = 0;
- if (state) {
- __interrupts_suspended--;
- if (0 >= __interrupts_suspended) {
- __interrupts_suspended = 0;
+ if (state) {
+ __interrupts_suspended--;
+ if (0 >= __interrupts_suspended) {
+ __interrupts_suspended = 0;
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT // this _check_ should go away
- {
- hal_virtual_comm_table_t* __chan;
- __chan = CYGACC_CALL_IF_DEBUG_PROCS();
- CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_IRQ_ENABLE);
- }
-#else
- if (__interruptible_control)
- __interruptible_control(1);
+ {
+ hal_virtual_comm_table_t* __chan;
+ __chan = CYGACC_CALL_IF_DEBUG_PROCS();
+ CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_IRQ_ENABLE);
+ }
+#else
+ if (__interruptible_control)
+ __interruptible_control(1);
#endif
- }
- } else {
- __interrupts_suspended++;
- if (1 == __interrupts_suspended)
+ }
+ } else {
+ __interrupts_suspended++;
+ if (1 == __interrupts_suspended)
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT // this _check_ should go away
- {
- hal_virtual_comm_table_t* __chan;
- __chan = CYGACC_CALL_IF_DEBUG_PROCS();
- CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_IRQ_DISABLE);
- }
-#else
- if (__interruptible_control)
- __interruptible_control(0);
+ {
+ hal_virtual_comm_table_t* __chan;
+ __chan = CYGACC_CALL_IF_DEBUG_PROCS();
+ CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_IRQ_DISABLE);
+ }
+#else
+ if (__interruptible_control)
+ __interruptible_control(0);
#endif
- }
+ }
}
//-----------------------------------------------------------------------------
static void
return_from_stub(int exit_status)
{
- CYGACC_CALL_IF_MONITOR_RETURN(exit_status);
+ CYGACC_CALL_IF_MONITOR_RETURN(exit_status);
}
#endif
// Called at stub *kill*
-static void
+static void
handle_exception_exit( void )
{
#ifdef CYGPKG_REDBOOT
#ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
- { // Reset the timer to default and cancel any callback
- extern void sys_profile_reset(void);
- sys_profile_reset();
- }
+ { // Reset the timer to default and cancel any callback
+ extern void sys_profile_reset(void);
+ sys_profile_reset();
+ }
#endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
- set_pc((target_register_t)return_from_stub);
+ set_pc((target_register_t)return_from_stub);
#else
- int i;
+ int i;
- for (i = 0; i < (sizeof(registers)/sizeof(registers[0])); i++)
- registers[i] = orig_registers[i];
+ for (i = 0; i < (sizeof(registers)/sizeof(registers[0])); i++)
+ registers[i] = orig_registers[i];
#endif
}
// Called at stub *entry*
-static void
+static void
handle_exception_cleanup( void )
{
#ifndef CYGPKG_REDBOOT
- static int orig_registers_set = 0;
+ static int orig_registers_set = 0;
#endif
- interruptible(0);
+ interruptible(0);
- // Expand the HAL_SavedRegisters structure into the GDB register
- // array format.
- HAL_GET_GDB_REGISTERS(®isters[0], _hal_registers);
- _registers = ®isters[0];
+ // Expand the HAL_SavedRegisters structure into the GDB register
+ // array format.
+ HAL_GET_GDB_REGISTERS(®isters[0], _hal_registers);
+ _registers = ®isters[0];
#ifndef CYGPKG_REDBOOT
- if (!orig_registers_set) {
- int i;
- for (i = 0; i < (sizeof(registers)/sizeof(registers[0])); i++)
- orig_registers[i] = registers[i];
- _registers = &orig_registers[0];
- if (__is_breakpoint_function ())
- __skipinst ();
- _registers = ®isters[0];
- orig_registers_set = 1;
- }
+ if (!orig_registers_set) {
+ int i;
+ for (i = 0; i < (sizeof(registers)/sizeof(registers[0])); i++)
+ orig_registers[i] = registers[i];
+ _registers = &orig_registers[0];
+ if (__is_breakpoint_function ())
+ __skipinst ();
+ _registers = ®isters[0];
+ orig_registers_set = 1;
+ }
#endif
-
+
#ifdef HAL_STUB_PLATFORM_STUBS_FIXUP
- // Some architectures may need to fix the PC in case of a partial
- // or fully executed trap instruction. GDB only takes correct action
- // when the PC is pointing to the breakpoint instruction it set.
- //
- // Most architectures would leave PC pointing at the trap
- // instruction itself though, and so do not need to do anything
- // special.
- HAL_STUB_PLATFORM_STUBS_FIXUP();
+ // Some architectures may need to fix the PC in case of a partial
+ // or fully executed trap instruction. GDB only takes correct action
+ // when the PC is pointing to the breakpoint instruction it set.
+ //
+ // Most architectures would leave PC pointing at the trap
+ // instruction itself though, and so do not need to do anything
+ // special.
+ HAL_STUB_PLATFORM_STUBS_FIXUP();
#endif
#ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
- // If we continued instead of stepping, when there was a break set
- // ie. we were stepping within a critical region, clear the break, and
- // that flag. If we stopped for some other reason, this has no effect.
- if ( cyg_hal_gdb_running_step ) {
- cyg_hal_gdb_running_step = 0;
- cyg_hal_gdb_remove_break(get_register (PC));
- }
-
- // FIXME: (there may be a better way to do this)
- // If we hit a breakpoint set by the gdb interrupt stub, make it
- // seem like an interrupt rather than having hit a breakpoint.
- cyg_hal_gdb_break = cyg_hal_gdb_remove_break(get_register (PC));
+ // If we continued instead of stepping, when there was a break set
+ // ie. we were stepping within a critical region, clear the break, and
+ // that flag. If we stopped for some other reason, this has no effect.
+ if ( cyg_hal_gdb_running_step ) {
+ cyg_hal_gdb_running_step = 0;
+ cyg_hal_gdb_remove_break(get_register (PC));
+ }
+
+ // FIXME: (there may be a better way to do this)
+ // If we hit a breakpoint set by the gdb interrupt stub, make it
+ // seem like an interrupt rather than having hit a breakpoint.
+ cyg_hal_gdb_break = cyg_hal_gdb_remove_break(get_register (PC));
#endif
#if defined(HAL_STUB_HW_WATCHPOINT) || defined(HAL_STUB_HW_BREAKPOINT)
- // For HW watchpoint/breakpoint support, we need to know if we
- // stopped because of watchpoint or hw break. We do that here
- // before GDB has a chance to remove the watchpoints and save
- // the information for later use in building response packets.
- _hw_stop_reason = HAL_STUB_IS_STOPPED_BY_HARDWARE(_watch_data_addr);
-#endif
+ // For HW watchpoint/breakpoint support, we need to know if we
+ // stopped because of watchpoint or hw break. We do that here
+ // before GDB has a chance to remove the watchpoints and save
+ // the information for later use in building response packets.
+ _hw_stop_reason = HAL_STUB_IS_STOPPED_BY_HARDWARE(_watch_data_addr);
+#endif
}
// Called at stub *exit*
-static void
+static void
handle_exception_init( void )
{
- // Compact register array again.
- HAL_SET_GDB_REGISTERS(_hal_registers, ®isters[0]);
+ // Compact register array again.
+ HAL_SET_GDB_REGISTERS(_hal_registers, ®isters[0]);
- interruptible(1);
+ interruptible(1);
}
// Initialization.
// Signal handler.
-int
+int
cyg_hal_process_signal (int signal)
{
- // We don't care about the signal (atm).
- return 0;
+ // We don't care about the signal (atm).
+ return 0;
}
// Install the standard set of trap handlers for the stub.
-void
+void
__install_traps (void)
{
- // Set signal handling vector so we can treat 'C<signum>' as 'c'.
- __process_signal_vec = &cyg_hal_process_signal;
- __process_exit_vec = &handle_exception_exit;
+ // Set signal handling vector so we can treat 'C<signum>' as 'c'.
+ __process_signal_vec = &cyg_hal_process_signal;
+ __process_exit_vec = &handle_exception_exit;
- __cleanup_vec = &handle_exception_cleanup;
- __init_vec = &handle_exception_init;
+ __cleanup_vec = &handle_exception_cleanup;
+ __init_vec = &handle_exception_init;
#ifndef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT // this should go away
#ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
- // Control of GDB interrupts.
- __interruptible_control = HAL_STUB_PLATFORM_INTERRUPTIBLE;
+ // Control of GDB interrupts.
+ __interruptible_control = HAL_STUB_PLATFORM_INTERRUPTIBLE;
#endif
#endif
- // Nothing further to do, handle_exception will be called when an
- // exception occurs.
+ // Nothing further to do, handle_exception will be called when an
+ // exception occurs.
}
// Initialize the hardware.
-void
-initHardware (void)
+void
+initHardware (void)
{
- static int initialized = 0;
+ static int initialized = 0;
- if (initialized)
- return;
- initialized = 1;
+ if (initialized)
+ return;
+ initialized = 1;
- // Get serial port initialized.
- HAL_STUB_PLATFORM_INIT_SERIAL();
+ // Get serial port initialized.
+ HAL_STUB_PLATFORM_INIT_SERIAL();
#ifdef HAL_STUB_PLATFORM_INIT
- // If the platform defines any initialization code, call it here.
- HAL_STUB_PLATFORM_INIT();
-#endif
+ // If the platform defines any initialization code, call it here.
+ HAL_STUB_PLATFORM_INIT();
+#endif
#ifndef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT // this should go away
#ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
- // Get interrupt handler initialized.
- HAL_STUB_PLATFORM_INIT_BREAK_IRQ();
+ // Get interrupt handler initialized.
+ HAL_STUB_PLATFORM_INIT_BREAK_IRQ();
#endif
#endif // !CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
}
// Reset the board.
-void
+void
__reset (void)
{
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
- __call_if_reset_t *__rom_reset = CYGACC_CALL_IF_RESET_GET();
- if (__rom_reset)
- (*__rom_reset)();
+ __call_if_reset_t *__rom_reset = CYGACC_CALL_IF_RESET_GET();
+ if (__rom_reset)
+ (*__rom_reset)();
#else
- HAL_PLATFORM_RESET();
+ HAL_PLATFORM_RESET();
#endif
}
void
breakpoint()
{
- HAL_BREAKPOINT(_breakinst);
+ HAL_BREAKPOINT(_breakinst);
}
// This function returns the opcode for a 'trap' instruction.
-unsigned long
+unsigned long
__break_opcode ()
{
- return HAL_BREAKINST;
+ return HAL_BREAKINST;
}
#endif
//-----------------------------------------------------------------------------
// Write the 'T' packet in BUFFER. SIGVAL is the signal the program received.
-void
+void
__build_t_packet (int sigval, char *buf)
{
- target_register_t addr;
- char *ptr = buf;
- target_register_t extend_val = 0;
+ target_register_t addr;
+ char *ptr = buf;
+ target_register_t extend_val = 0;
- *ptr++ = 'T';
- *ptr++ = __tohex (sigval >> 4);
- *ptr++ = __tohex (sigval);
+ *ptr++ = 'T';
+ *ptr++ = __tohex (sigval >> 4);
+ *ptr++ = __tohex (sigval);
#ifdef CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT
- // Include thread ID if thread manipulation is required.
- {
- int id = dbg_currthread_id ();
-
- if (id != 0) {
- *ptr++ = 't';
- *ptr++ = 'h';
- *ptr++ = 'r';
- *ptr++ = 'e';
- *ptr++ = 'a';
- *ptr++ = 'd';
- *ptr++ = ':';
+ // Include thread ID if thread manipulation is required.
+ {
+ int id = dbg_currthread_id ();
+
+ if (id != 0) {
+ *ptr++ = 't';
+ *ptr++ = 'h';
+ *ptr++ = 'r';
+ *ptr++ = 'e';
+ *ptr++ = 'a';
+ *ptr++ = 'd';
+ *ptr++ = ':';
#if (CYG_BYTEORDER == CYG_LSBFIRST)
- // FIXME: Temporary workaround for PR 18903. Thread ID must be
- // big-endian in the T packet.
- {
- unsigned char* bep = (unsigned char*)&id;
- int be_id;
-
- be_id = id;
- *bep++ = (be_id >> 24) & 0xff ;
- *bep++ = (be_id >> 16) & 0xff ;
- *bep++ = (be_id >> 8) & 0xff ;
- *bep++ = (be_id & 0xff) ;
- }
+ // FIXME: Temporary workaround for PR 18903. Thread ID must be
+ // big-endian in the T packet.
+ {
+ unsigned char* bep = (unsigned char*)&id;
+ int be_id;
+
+ be_id = id;
+ *bep++ = (be_id >> 24) & 0xff ;
+ *bep++ = (be_id >> 16) & 0xff ;
+ *bep++ = (be_id >> 8) & 0xff ;
+ *bep++ = (be_id & 0xff) ;
+ }
#endif
- ptr = __mem2hex((char *)&id, ptr, sizeof(id), 0);
- *ptr++ = ';';
+ ptr = __mem2hex((char *)&id, ptr, sizeof(id), 0);
+ *ptr++ = ';';
+ }
}
- }
#endif
#ifdef HAL_STUB_HW_WATCHPOINT
- switch(_hw_stop_reason) {
- case HAL_STUB_HW_STOP_WATCH:
- case HAL_STUB_HW_STOP_RWATCH:
- case HAL_STUB_HW_STOP_AWATCH:
+ switch(_hw_stop_reason) {
+ case HAL_STUB_HW_STOP_WATCH:
+ case HAL_STUB_HW_STOP_RWATCH:
+ case HAL_STUB_HW_STOP_AWATCH:
#ifdef HAL_STUB_HW_SEND_STOP_REASON_TEXT
- // Not all GDBs understand this.
- strcpy(ptr, _hw_stop_str[_hw_stop_reason]);
- ptr += strlen(_hw_stop_str[_hw_stop_reason]);
+ // Not all GDBs understand this.
+ strcpy(ptr, _hw_stop_str[_hw_stop_reason]);
+ ptr += strlen(_hw_stop_str[_hw_stop_reason]);
#endif
- *ptr++ = ':';
- // Send address MSB first
- ptr += __intToHex(ptr, (target_register_t)_watch_data_addr,
- sizeof(_watch_data_addr) * 8);
- *ptr++ = ';';
- break;
- default:
- break;
- }
+ *ptr++ = ':';
+ // Send address MSB first
+ ptr += __intToHex(ptr, (target_register_t)_watch_data_addr,
+ sizeof(_watch_data_addr) * 8);
+ *ptr++ = ';';
+ break;
+ default:
+ break;
+ }
#endif
- *ptr++ = __tohex (PC >> 4);
- *ptr++ = __tohex (PC);
- *ptr++ = ':';
- addr = get_register (PC);
- if (sizeof(addr) < REGSIZE(PC))
- {
- // GDB is expecting REGSIZE(PC) number of bytes.
- // We only have sizeof(addr) number. Let's fill
- // the appropriate number of bytes intelligently.
+ *ptr++ = __tohex (PC >> 4);
+ *ptr++ = __tohex (PC);
+ *ptr++ = ':';
+ addr = get_register (PC);
+ if (sizeof(addr) < REGSIZE(PC))
+ {
+ // GDB is expecting REGSIZE(PC) number of bytes.
+ // We only have sizeof(addr) number. Let's fill
+ // the appropriate number of bytes intelligently.
#ifdef CYGARC_SIGN_EXTEND_REGISTERS
- {
- unsigned long bits_in_addr = (sizeof(addr) << 3); // ie Size in bytes * 8
- target_register_t sign_bit_mask = (1 << (bits_in_addr - 1));
- if ((addr & sign_bit_mask) == sign_bit_mask)
- extend_val = ~0;
- }
+ {
+ unsigned long bits_in_addr = (sizeof(addr) << 3); // ie Size in bytes * 8
+ target_register_t sign_bit_mask = (1 << (bits_in_addr - 1));
+ if ((addr & sign_bit_mask) == sign_bit_mask)
+ extend_val = ~0;
+ }
#endif
- }
+ }
#if (CYG_BYTEORDER == CYG_MSBFIRST)
- ptr = __mem2hex((char *)&extend_val, ptr, REGSIZE(PC) - sizeof(addr), 0);
+ ptr = __mem2hex((char *)&extend_val, ptr, REGSIZE(PC) - sizeof(addr), 0);
#endif
- ptr = __mem2hex((char *)&addr, ptr, sizeof(addr), 0);
+ ptr = __mem2hex((char *)&addr, ptr, sizeof(addr), 0);
#if (CYG_BYTEORDER == CYG_LSBFIRST)
- ptr = __mem2hex((char *)&extend_val, ptr, REGSIZE(PC) - sizeof(addr), 0);
+ ptr = __mem2hex((char *)&extend_val, ptr, REGSIZE(PC) - sizeof(addr), 0);
#endif
- *ptr++ = ';';
-
- *ptr++ = __tohex (SP >> 4);
- *ptr++ = __tohex (SP);
- *ptr++ = ':';
- addr = (target_register_t) get_register (SP);
- if (sizeof(addr) < REGSIZE(SP))
- {
- // GDB is expecting REGSIZE(SP) number of bytes.
- // We only have sizeof(addr) number. Let's fill
- // the appropriate number of bytes intelligently.
- extend_val = 0;
+ *ptr++ = ';';
+
+ *ptr++ = __tohex (SP >> 4);
+ *ptr++ = __tohex (SP);
+ *ptr++ = ':';
+ addr = (target_register_t) get_register (SP);
+ if (sizeof(addr) < REGSIZE(SP))
+ {
+ // GDB is expecting REGSIZE(SP) number of bytes.
+ // We only have sizeof(addr) number. Let's fill
+ // the appropriate number of bytes intelligently.
+ extend_val = 0;
#ifdef CYGARC_SIGN_EXTEND_REGISTERS
- {
- unsigned long bits_in_addr = (sizeof(addr) << 3); // ie Size in bytes * 8
- target_register_t sign_bit_mask = (1 << (bits_in_addr - 1));
- if ((addr & sign_bit_mask) == sign_bit_mask)
- extend_val = ~0;
- }
+ {
+ unsigned long bits_in_addr = (sizeof(addr) << 3); // ie Size in bytes * 8
+ target_register_t sign_bit_mask = (1 << (bits_in_addr - 1));
+ if ((addr & sign_bit_mask) == sign_bit_mask)
+ extend_val = ~0;
+ }
#endif
- ptr = __mem2hex((char *)&extend_val, ptr, REGSIZE(SP) - sizeof(addr), 0);
- }
- ptr = __mem2hex((char *)&addr, ptr, sizeof(addr), 0);
- *ptr++ = ';';
-
- HAL_STUB_ARCH_T_PACKET_EXTRAS(ptr);
-
- *ptr++ = 0;
+ ptr = __mem2hex((char *)&extend_val, ptr, REGSIZE(SP) - sizeof(addr), 0);
+ }
+ ptr = __mem2hex((char *)&addr, ptr, sizeof(addr), 0);
+ *ptr++ = ';';
+
+ HAL_STUB_ARCH_T_PACKET_EXTRAS(ptr);
+
+ *ptr++ = 0;
}
//-----------------------------------------------------------------------------
// Cache functions.
-// Perform the specified operation on the instruction cache.
+// Perform the specified operation on the instruction cache.
// Returns 1 if the cache is enabled, 0 otherwise.
-int
+int
__instruction_cache (cache_control_t request)
{
- int state = 1;
-
- switch (request) {
- case CACHE_ENABLE:
- HAL_ICACHE_ENABLE();
- break;
- case CACHE_DISABLE:
- HAL_ICACHE_DISABLE();
- state = 0;
- break;
- case CACHE_FLUSH:
- HAL_ICACHE_SYNC();
- break;
- case CACHE_NOOP:
- /* fall through */
- default:
- break;
- }
+ int state = 1;
+
+ switch (request) {
+ case CACHE_ENABLE:
+ HAL_ICACHE_ENABLE();
+ break;
+ case CACHE_DISABLE:
+ HAL_ICACHE_DISABLE();
+ state = 0;
+ break;
+ case CACHE_FLUSH:
+ HAL_ICACHE_SYNC();
+ break;
+ case CACHE_NOOP:
+ /* fall through */
+ default:
+ break;
+ }
#ifdef HAL_ICACHE_IS_ENABLED
- HAL_ICACHE_IS_ENABLED(state);
+ HAL_ICACHE_IS_ENABLED(state);
#endif
- return state;
+ return state;
}
-// Perform the specified operation on the data cache.
+// Perform the specified operation on the data cache.
// Returns 1 if the cache is enabled, 0 otherwise.
-int
+int
__data_cache (cache_control_t request)
{
- int state = 1;
-
- switch (request) {
- case CACHE_ENABLE:
- HAL_DCACHE_ENABLE();
- break;
- case CACHE_DISABLE:
- HAL_DCACHE_DISABLE();
- state = 0;
- break;
- case CACHE_FLUSH:
- HAL_DCACHE_SYNC();
- break;
- case CACHE_NOOP:
- /* fall through */
- default:
- break;
- }
+ int state = 1;
+
+ switch (request) {
+ case CACHE_ENABLE:
+ HAL_DCACHE_ENABLE();
+ break;
+ case CACHE_DISABLE:
+ HAL_DCACHE_DISABLE();
+ state = 0;
+ break;
+ case CACHE_FLUSH:
+ HAL_DCACHE_SYNC();
+ break;
+ case CACHE_NOOP:
+ /* fall through */
+ default:
+ break;
+ }
#ifdef HAL_DCACHE_IS_ENABLED
- HAL_DCACHE_IS_ENABLED(state);
+ HAL_DCACHE_IS_ENABLED(state);
#endif
- return state;
+ return state;
}
//-----------------------------------------------------------------------------
void* volatile __mem_fault_handler = (void *)0;
-/* These are the "arguments" to __do_read_mem and __do_write_mem,
+/* These are the "arguments" to __do_read_mem and __do_write_mem,
which are passed as globals to avoid squeezing them thru
__set_mem_fault_trap. */
static void
__do_copy_mem (unsigned char* src, unsigned char* dst)
{
- unsigned long *long_dst;
- unsigned long *long_src;
- unsigned short *short_dst;
- unsigned short *short_src;
-
- // Zero memCount is not really an error, but the goto is necessary to
- // keep some compilers from reordering stuff across the 'err' label.
- if (memCount == 0) goto err;
-
- __mem_fault = 1; /* Defaults to 'fail'. Is cleared */
- /* when the copy loop completes. */
- __mem_fault_handler = &&err;
-
- // See if it's safe to do multi-byte, aligned operations
- while (memCount) {
- if ((memCount >= sizeof(long)) &&
- (((target_register_t)dst & (sizeof(long)-1)) == 0) &&
- (((target_register_t)src & (sizeof(long)-1)) == 0)) {
-
- long_dst = (unsigned long *)dst;
- long_src = (unsigned long *)src;
-
- *long_dst++ = *long_src++;
- memCount -= sizeof(long);
-
- dst = (unsigned char *)long_dst;
- src = (unsigned char *)long_src;
- } else if ((memCount >= sizeof(short)) &&
- (((target_register_t)dst & (sizeof(short)-1)) == 0) &&
- (((target_register_t)src & (sizeof(short)-1)) == 0)) {
-
- short_dst = (unsigned short *)dst;
- short_src = (unsigned short *)src;
-
- *short_dst++ = *short_src++;
- memCount -= sizeof(short);
-
- dst = (unsigned char *)short_dst;
- src = (unsigned char *)short_src;
- } else {
- *dst++ = *src++;
- memCount--;
- }
- }
-
- __mem_fault = 0;
-
- err:
- __mem_fault_handler = (void *)0;
+ unsigned long *long_dst;
+ unsigned long *long_src;
+ unsigned short *short_dst;
+ unsigned short *short_src;
+
+ // Zero memCount is not really an error, but the goto is necessary to
+ // keep some compilers from reordering stuff across the 'err' label.
+ if (memCount == 0) goto err;
+
+ __mem_fault = 1; /* Defaults to 'fail'. Is cleared */
+ /* when the copy loop completes. */
+ __mem_fault_handler = &&err;
+
+ // See if it's safe to do multi-byte, aligned operations
+ while (memCount) {
+ if ((memCount >= sizeof(long)) &&
+ (((target_register_t)dst & (sizeof(long)-1)) == 0) &&
+ (((target_register_t)src & (sizeof(long)-1)) == 0)) {
+
+ long_dst = (unsigned long *)dst;
+ long_src = (unsigned long *)src;
+
+ *long_dst++ = *long_src++;
+ memCount -= sizeof(long);
+
+ dst = (unsigned char *)long_dst;
+ src = (unsigned char *)long_src;
+ } else if ((memCount >= sizeof(short)) &&
+ (((target_register_t)dst & (sizeof(short)-1)) == 0) &&
+ (((target_register_t)src & (sizeof(short)-1)) == 0)) {
+
+ short_dst = (unsigned short *)dst;
+ short_src = (unsigned short *)src;
+
+ *short_dst++ = *short_src++;
+ memCount -= sizeof(short);
+
+ dst = (unsigned char *)short_dst;
+ src = (unsigned char *)short_src;
+ } else {
+ *dst++ = *src++;
+ memCount--;
+ }
+ }
+
+ __mem_fault = 0;
+
+err:
+ __mem_fault_handler = (void *)0;
}
/*
int
__read_mem_safe (void *dst, void *src, int count)
{
- if( !CYG_HAL_STUB_PERMIT_DATA_READ( src, count ) )
- return 0;
+ if( !CYG_HAL_STUB_PERMIT_DATA_READ( src, count ) )
+ return 0;
- memCount = count;
- __do_copy_mem((unsigned char*) src, (unsigned char*) dst);
- return count - memCount; // return number of bytes successfully read
+ memCount = count;
+ __do_copy_mem((unsigned char*) src, (unsigned char*) dst);
+ return count - memCount; // return number of bytes successfully read
}
/*
int
__write_mem_safe (void *src, void *dst, int count)
{
- if( !CYG_HAL_STUB_PERMIT_DATA_READ( dst, count ) )
- return 0;
+ if( !CYG_HAL_STUB_PERMIT_DATA_READ( dst, count ) )
+ return 0;
- memCount = count;
- __do_copy_mem((unsigned char*) src, (unsigned char*) dst);
- return count - memCount; // return number of bytes successfully written
+ memCount = count;
+ __do_copy_mem((unsigned char*) src, (unsigned char*) dst);
+ return count - memCount; // return number of bytes successfully written
}
#ifdef TARGET_HAS_HARVARD_MEMORY
static void
__do_copy_from_progmem (unsigned char* src, unsigned char* dst)
{
- unsigned long *long_dst;
- unsigned long *long_src;
- unsigned short *short_dst;
- unsigned short *short_src;
-
- // Zero memCount is not really an error, but the goto is necessary to
- // keep some compilers from reordering stuff across the 'err' label.
- if (memCount == 0) goto err;
-
- __mem_fault = 1; /* Defaults to 'fail'. Is cleared */
- /* when the copy loop completes. */
- __mem_fault_handler = &&err;
-
- // See if it's safe to do multi-byte, aligned operations
- while (memCount) {
- if ((memCount >= sizeof(long)) &&
- (((target_register_t)dst & (sizeof(long)-1)) == 0) &&
- (((target_register_t)src & (sizeof(long)-1)) == 0)) {
-
- long_dst = (unsigned long *)dst;
- long_src = (unsigned long *)src;
-
- *long_dst++ = __read_prog_uint32(long_src++);
- memCount -= sizeof(long);
-
- dst = (unsigned char *)long_dst;
- src = (unsigned char *)long_src;
- } else if ((memCount >= sizeof(short)) &&
- (((target_register_t)dst & (sizeof(short)-1)) == 0) &&
- (((target_register_t)src & (sizeof(short)-1)) == 0)) {
-
- short_dst = (unsigned short *)dst;
- short_src = (unsigned short *)src;
-
- *short_dst++ = __read_prog_uint16(short_src++);
- memCount -= sizeof(short);
-
- dst = (unsigned char *)short_dst;
- src = (unsigned char *)short_src;
- } else {
- *dst++ = __read_prog_uint8(src++);
- memCount--;
- }
- }
-
- __mem_fault = 0;
-
- err:
- __mem_fault_handler = (void *)0;
+ unsigned long *long_dst;
+ unsigned long *long_src;
+ unsigned short *short_dst;
+ unsigned short *short_src;
+
+ // Zero memCount is not really an error, but the goto is necessary to
+ // keep some compilers from reordering stuff across the 'err' label.
+ if (memCount == 0) goto err;
+
+ __mem_fault = 1; /* Defaults to 'fail'. Is cleared */
+ /* when the copy loop completes. */
+ __mem_fault_handler = &&err;
+
+ // See if it's safe to do multi-byte, aligned operations
+ while (memCount) {
+ if ((memCount >= sizeof(long)) &&
+ (((target_register_t)dst & (sizeof(long)-1)) == 0) &&
+ (((target_register_t)src & (sizeof(long)-1)) == 0)) {
+
+ long_dst = (unsigned long *)dst;
+ long_src = (unsigned long *)src;
+
+ *long_dst++ = __read_prog_uint32(long_src++);
+ memCount -= sizeof(long);
+
+ dst = (unsigned char *)long_dst;
+ src = (unsigned char *)long_src;
+ } else if ((memCount >= sizeof(short)) &&
+ (((target_register_t)dst & (sizeof(short)-1)) == 0) &&
+ (((target_register_t)src & (sizeof(short)-1)) == 0)) {
+
+ short_dst = (unsigned short *)dst;
+ short_src = (unsigned short *)src;
+
+ *short_dst++ = __read_prog_uint16(short_src++);
+ memCount -= sizeof(short);
+
+ dst = (unsigned char *)short_dst;
+ src = (unsigned char *)short_src;
+ } else {
+ *dst++ = __read_prog_uint8(src++);
+ memCount--;
+ }
+ }
+
+ __mem_fault = 0;
+
+err:
+ __mem_fault_handler = (void *)0;
}
static void
__do_copy_to_progmem (unsigned char* src, unsigned char* dst)
{
- unsigned long *long_dst;
- unsigned long *long_src;
- unsigned short *short_dst;
- unsigned short *short_src;
-
- // Zero memCount is not really an error, but the goto is necessary to
- // keep some compilers from reordering stuff across the 'err' label.
- if (memCount == 0) goto err;
-
- __mem_fault = 1; /* Defaults to 'fail'. Is cleared */
- /* when the copy loop completes. */
- __mem_fault_handler = &&err;
-
- // See if it's safe to do multi-byte, aligned operations
- while (memCount) {
- if ((memCount >= sizeof(long)) &&
- (((target_register_t)dst & (sizeof(long)-1)) == 0) &&
- (((target_register_t)src & (sizeof(long)-1)) == 0)) {
-
- long_dst = (unsigned long *)dst;
- long_src = (unsigned long *)src;
-
- __write_prog_uint32(long_dst++, *long_src++);
- memCount -= sizeof(long);
-
- dst = (unsigned char *)long_dst;
- src = (unsigned char *)long_src;
- } else if ((memCount >= sizeof(short)) &&
- (((target_register_t)dst & (sizeof(short)-1)) == 0) &&
- (((target_register_t)src & (sizeof(short)-1)) == 0)) {
-
- short_dst = (unsigned short *)dst;
- short_src = (unsigned short *)src;
-
- __write_prog_uint16(short_dst++, *short_src++);
- memCount -= sizeof(short);
-
- dst = (unsigned char *)short_dst;
- src = (unsigned char *)short_src;
- } else {
- __write_prog_uint8(dst++, *src++);
- memCount--;
- }
- }
-
- __mem_fault = 0;
-
- err:
- __mem_fault_handler = (void *)0;
+ unsigned long *long_dst;
+ unsigned long *long_src;
+ unsigned short *short_dst;
+ unsigned short *short_src;
+
+ // Zero memCount is not really an error, but the goto is necessary to
+ // keep some compilers from reordering stuff across the 'err' label.
+ if (memCount == 0) goto err;
+
+ __mem_fault = 1; /* Defaults to 'fail'. Is cleared */
+ /* when the copy loop completes. */
+ __mem_fault_handler = &&err;
+
+ // See if it's safe to do multi-byte, aligned operations
+ while (memCount) {
+ if ((memCount >= sizeof(long)) &&
+ (((target_register_t)dst & (sizeof(long)-1)) == 0) &&
+ (((target_register_t)src & (sizeof(long)-1)) == 0)) {
+
+ long_dst = (unsigned long *)dst;
+ long_src = (unsigned long *)src;
+
+ __write_prog_uint32(long_dst++, *long_src++);
+ memCount -= sizeof(long);
+
+ dst = (unsigned char *)long_dst;
+ src = (unsigned char *)long_src;
+ } else if ((memCount >= sizeof(short)) &&
+ (((target_register_t)dst & (sizeof(short)-1)) == 0) &&
+ (((target_register_t)src & (sizeof(short)-1)) == 0)) {
+
+ short_dst = (unsigned short *)dst;
+ short_src = (unsigned short *)src;
+
+ __write_prog_uint16(short_dst++, *short_src++);
+ memCount -= sizeof(short);
+
+ dst = (unsigned char *)short_dst;
+ src = (unsigned char *)short_src;
+ } else {
+ __write_prog_uint8(dst++, *src++);
+ memCount--;
+ }
+ }
+
+ __mem_fault = 0;
+
+err:
+ __mem_fault_handler = (void *)0;
}
/*
int
__read_progmem_safe (void *dst, void *src, int count)
{
- if( !CYG_HAL_STUB_PERMIT_CODE_READ( src, count ) )
- return 0;
+ if( !CYG_HAL_STUB_PERMIT_CODE_READ( src, count ) )
+ return 0;
- memCount = count;
- __do_copy_from_progmem((unsigned char*) src, (unsigned char*) dst);
- return count - memCount; // return number of bytes successfully read
+ memCount = count;
+ __do_copy_from_progmem((unsigned char*) src, (unsigned char*) dst);
+ return count - memCount; // return number of bytes successfully read
}
/*
int
__write_progmem_safe (void *src, void *dst, int count)
{
- if( !CYG_HAL_STUB_PERMIT_CODE_WRITE( dst, count ) )
- return 0;
+ if( !CYG_HAL_STUB_PERMIT_CODE_WRITE( dst, count ) )
+ return 0;
- memCount = count;
- __do_copy_to_progmem((unsigned char*) src, (unsigned char*) dst);
- return count - memCount; // return number of bytes successfully written
+ memCount = count;
+ __do_copy_to_progmem((unsigned char*) src, (unsigned char*) dst);
+ return count - memCount; // return number of bytes successfully written
}
#endif
//-----------------------------------------------------------------------------
// Target extras?!
-int
+int
__process_target_query(char * pkt, char * out, int maxOut)
{ return 0 ; }
-int
+int
__process_target_set(char * pkt, char * out, int maxout)
{ return 0 ; }
-int
+int
__process_target_packet(char * pkt, char * out, int maxout)
{ return 0 ; }
// GDB string output, making sure interrupts are disabled.
// This function gets used by some diag output functions.
-void
+void
hal_output_gdb_string(target_register_t str, int string_len)
{
- unsigned long __state;
- HAL_DISABLE_INTERRUPTS(__state);
- __output_gdb_string(str, string_len);
- HAL_RESTORE_INTERRUPTS(__state);
+ unsigned long __state;
+ HAL_DISABLE_INTERRUPTS(__state);
+ __output_gdb_string(str, string_len);
+ HAL_RESTORE_INTERRUPTS(__state);
}
#endif // CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
// Author(s): Red Hat, nickg
// Contributors: Red Hat, nickg
// Date: 1998-08-25
-// Purpose:
+// Purpose:
// Description: Provides multi-threaded debug support
-// Usage:
+// Usage:
//
//####DESCRIPTIONEND####
//
// #ifdef __ECOS__
#include <pkgconf/hal.h>
-#if defined(CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT) \
- && defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
+#if defined(CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT) && \
+ defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
// #endif // __ECOS__
/* FIXME: Scan this module for correct sizes of fields in packets */
#endif
#define DEBUG_THREADS 1
-#define UNIT_TEST 0
-#define GDB_MOCKUP 0
+#define UNIT_TEST 0
+#define GDB_MOCKUP 0
#define STUB_BUF_MAX 300 /* for range checking of packet lengths */
-
+
#include "thread-pkts.h"
#ifdef __ECOS__
/*
* Export the continue and "general" (context) thread IDs from GDB.
*/
-int _gdb_cont_thread ;
-int _gdb_general_thread ;
+int _gdb_cont_thread;
+int _gdb_general_thread;
#if !defined(PKT_DEBUG)
#define PKT_DEBUG 0
#endif
-extern void output_string(char * message) ;
+extern void output_string(char *message);
#if PKT_DEBUG
-void output_threadid(char * title,threadref * ref) ;
+void output_threadid(char *title, threadref *ref);
#warning "PKT_DEBUG macros engaged"
-#define PKT_TRACE(title,packet) \
-{ output_string(title) ; output_string(packet) ; output_string("\n") ;}
+#define PKT_TRACE(title, packet) \
+{ output_string(title); output_string(packet); output_string("\n");}
#else
-#define PKT_TRACE(title,packet) {}
-#endif
+#define PKT_TRACE(title, packet) {}
+#endif
/* This is going to be irregular because the various implementations
alt_stub_registers
*/
-extern target_register_t * _registers ;
- /* A pointer to the current set of registers */
+extern target_register_t *_registers;
+ /* A pointer to the current set of registers */
extern target_register_t registers[]; /* The current saved registers */
-extern target_register_t alt_registers[] ;
- /* Thread or saved process state */
+extern target_register_t alt_registers[];
+ /* Thread or saved process state */
-static void stub_copy_registers(
- target_register_t * dest,
- target_register_t *src
- )
+static void stub_copy_registers(target_register_t *dest,
+ target_register_t *src)
{
- target_register_t * limit ;
- limit = dest + NUMREGS ;
+ target_register_t *limit;
+ limit = dest + NUMREGS;
- while (dest < limit) *dest++ = *src++ ;
+ while (dest < limit) *dest++ = *src++;
}
#ifdef __ECOS__
-void __stub_copy_registers(target_register_t * dest,
- target_register_t *src)
+void __stub_copy_registers(target_register_t *dest,
+ target_register_t *src)
{
- stub_copy_registers(dest, src);
+ stub_copy_registers(dest, src);
}
#endif // __ECOS__
-extern int stubhex(char ch) ;
+extern int stubhex(char ch);
/* ----- STUB_PACK_NAK ----------------------------------- */
/* Pack an error response into the response packet */
-char * stub_pack_nak(char * outbuf)
+char *stub_pack_nak(char *outbuf)
{
- *outbuf++ = 'E' ;
- *outbuf++ = '0' ;
- *outbuf++ = '2' ;
- return outbuf ;
+ *outbuf++ = 'E';
+ *outbuf++ = '0';
+ *outbuf++ = '2';
+ return outbuf;
} /* stub_pack_nak */
/* ----- STUB_PACK_ACK -------------------------- */
/* Pack an OK achnowledgement */
-char * stub_pack_ack(char * outbuf)
+char *stub_pack_ack(char *outbuf)
{
- *outbuf++ = 'O' ;
- *outbuf++ = 'K' ;
- return outbuf ;
+ *outbuf++ = 'O';
+ *outbuf++ = 'K';
+ return outbuf;
} /* stub_pack_ack */
/* ------- STUB_UNPACK_INT ------------------------------- */
/* This is where I wish functions could return several values
I would also advance the buffer pointer */
-int stub_unpack_int(char * buff,int fieldlength)
+int stub_unpack_int(char *buff, int fieldlength)
{
- int retval = 0 ;
- int nibble ;
- while (fieldlength)
- { nibble = stubhex(*buff++) ;
- retval |= nibble ;
- fieldlength-- ;
- if (fieldlength) retval = retval << 4 ;
- }
- return retval ;
+ int retval = 0;
+ int nibble;
+ while (fieldlength)
+ { nibble = stubhex(*buff++);
+ retval |= nibble;
+ fieldlength--;
+ if (fieldlength) retval = retval << 4;
+ }
+ return retval;
} /* stub_unpack_int */
-static char * unpack_byte(char * buf, int * value)
+static char *unpack_byte(char *buf, int *value)
{
- *value = stub_unpack_int(buf,2) ;
- return buf + 2 ;
+ *value = stub_unpack_int(buf, 2);
+ return buf + 2;
}
-static char * unpack_int(char * buf, int * value)
+static char *unpack_int(char *buf, int *value)
{
- *value = stub_unpack_int(buf,8) ;
- return buf + 8 ;
+ *value = stub_unpack_int(buf, 8);
+ return buf + 8;
}
/* We are NOT depending upon extensive libraries */
-static int ishex(char ch,int *val)
+static int ishex(char ch, int *val)
{
- if ((ch >= 'a') && (ch <= 'f'))
- { *val =ch - 'a' + 10 ; return 1 ; }
- if ((ch >= 'A') && (ch <= 'F'))
- { *val = ch - 'A' + 10 ; return 1 ;}
- if ((ch >= '0') && (ch <= '9'))
- { *val = ch - '0' ; return 1 ; }
- return 0 ;
+ if ((ch >= 'a') && (ch <= 'f')) {
+ *val = ch - 'a' + 10;
+ return 1;
+ }
+ if ((ch >= 'A') && (ch <= 'F')) {
+ *val = ch - 'A' + 10;
+ return 1;
+ }
+ if ((ch >= '0') && (ch <= '9')) {
+ *val = ch - '0';
+ return 1;
+ }
+ return 0;
} /* ishex */
-static char * unpack_nibble(char * buf,int * val)
+static char *unpack_nibble(char *buf, int *val)
{
- ishex(*buf++,val) ;
- return buf ;
+ ishex(*buf++, val);
+ return buf;
}
static const char hexchars[] = "0123456789abcdef";
-static char * pack_hex_byte(char * pkt, unsigned char byte)
+static char *pack_hex_byte(char *pkt, unsigned char byte)
{
- *pkt++ = hexchars[(byte >> 4) & 0xf] ;
- *pkt++ = hexchars[(byte & 0xf)] ;
- return pkt ;
+ *pkt++ = hexchars[(byte >> 4) & 0xf];
+ *pkt++ = hexchars[(byte & 0xf)];
+ return pkt;
} /* pack_hex_byte */
#ifndef __ECOS__
/* ---- STUB_PACK_VARLEN_HEX ------------------------------------- */
/* Format a variable length stream of hex bytes */
-static char * pack_varlen_hex(
- char * pkt,
- unsigned int value)
+static char *pack_varlen_hex(
+ char *pkt,
+ unsigned int value)
{
- int i ;
- static unsigned char n[8] ;
- if (value == 0)
- {
- *pkt++ = '0' ;
- return pkt ;
- }
- else
- {
- i = 8 ;
- while (i-- >= 0 ) /* unpack nibbles into a char array */
- {
- n[i] = value & 0x0f ;
- value = value >> 4 ;
- }
- i = 0 ; /* we had decrmented it to -1 */
- while (n[i] == 0 ) i++ ; /* drop leading zeroes */
- while (i++ < 8) *pkt++ = hexchars[n[i]] ; /* pack the number */
- }
- return pkt ;
+ int i;
+ static unsigned char n[8];
+ if (value == 0)
+ {
+ *pkt++ = '0';
+ return pkt;
+ }
+ else
+ {
+ i = 8;
+ while (i-- >= 0 ) /* unpack nibbles into a char array */
+ {
+ n[i] = value & 0x0f;
+ value = value >> 4;
+ }
+ i = 0; /* we had decrmented it to -1 */
+ while (n[i] == 0 ) i++; /* drop leading zeroes */
+ while (i++ < 8) *pkt++ = hexchars[n[i]]; /* pack the number */
+ }
+ return pkt;
} /* pack_varlen_hex */
#endif // !__ECOS__
/* This unpacks hex strings that may have been packed using sprintf(%x) */
/* We assume some non-hex delimits them */
-char * unpack_varlen_hex(
- char * buff, /* packet to parse */
- int * result)
+char *unpack_varlen_hex(
+ char *buff, /* packet to parse */
+ int *result)
{
- int nibble ;
- int retval ;
- retval = 0 ;
-
- while (ishex(*buff,&nibble))
- {
- buff++ ;
- retval = retval << 4 ;
- retval |= nibble & 0x0f ;
- }
- *result = retval ;
- return buff ;
+ int nibble;
+ int retval;
+ retval = 0;
+
+ while (ishex(*buff, &nibble))
+ {
+ buff++;
+ retval = retval << 4;
+ retval |= nibble & 0x0f;
+ }
+ *result = retval;
+ return buff;
} /* stub_unpack_varlen_int */
#define BUFTHREADIDSIZ 16 /* encode 64 bits in 16 chars of hex */
-static char * unpack_threadid(char * inbuf, threadref * id)
+static char *unpack_threadid(char *inbuf, threadref *id)
{
- char * altref ;
- char * limit = inbuf + BUFTHREADIDSIZ ;
- int x,y ;
- altref = (char *) id ;
-
- while (inbuf < limit)
- {
- x = stubhex(*inbuf++) ;
- y = stubhex(*inbuf++) ;
- *altref++ = (x << 4) | y ;
- }
- return inbuf ;
+ char *altref;
+ char *limit = inbuf + BUFTHREADIDSIZ;
+ int x, y;
+ altref = (char *)id;
+
+ while (inbuf < limit)
+ {
+ x = stubhex(*inbuf++);
+ y = stubhex(*inbuf++);
+ *altref++ = (x << 4) | y;
+ }
+ return inbuf;
} /* unpack_threadid */
/* Pack an integer use leading zeroes */
-static char * pack_int(char * buf,int value)
+static char *pack_int(char *buf, int value)
{
- buf = pack_hex_byte(buf,(value>> 24)& 0xff) ;
- buf = pack_hex_byte(buf,(value >>16)& 0xff) ;
- buf = pack_hex_byte(buf,(value >>8) & 0x0ff) ;
- buf = pack_hex_byte(buf,(value & 0xff)) ;
- return buf ;
+ buf = pack_hex_byte(buf, (value >> 24) & 0xff);
+ buf = pack_hex_byte(buf, (value >> 16) & 0xff);
+ buf = pack_hex_byte(buf, (value >> 8) & 0x0ff);
+ buf = pack_hex_byte(buf, value & 0xff);
+ return buf;
} /* pack_int */
preclude filtering for # I am assuming this is a constraint.
*/
-static char * pack_raw_string(char * pkt,char * string)
+static char *pack_raw_string(char *pkt, char *string)
{
- char ch ;
- while (0 != (ch = *string++)) *pkt++ = ch ;
- return pkt ;
+ char ch;
+ while (0 != (ch = *string++)) *pkt++ = ch;
+ return pkt;
}
-static char * pack_string(
- char * pkt,
- char * string)
+static char *pack_string(
+ char *pkt,
+ char *string)
{
- char ch ;
+ char ch;
#ifdef __ECOS__
- int len = 0;
- char *s = string;
- while( *s++ ) len++;
+ int len = 0;
+ char *s = string;
+ while( *s++ ) len++;
#else // __ECOS__
- int len ;
- len = strlen(string) ;
+ int len;
+ len = strlen(string);
#endif // __ECOS
- if (len > 200 ) len = 200 ; /* Bigger than most GDB packets, junk??? */
- pkt = pack_hex_byte(pkt,len) ;
- while (len-- > 0)
- {
- ch = *string++ ;
- if ((ch == '\0') || (ch == '#')) ch = '*' ; /* Protect encapsulation */
- *pkt++ = ch ;
- }
- return pkt ;
+ if (len > 200 ) len = 200; /* Bigger than most GDB packets, junk??? */
+ pkt = pack_hex_byte(pkt, len);
+ while (len-- > 0)
+ {
+ ch = *string++;
+ if ((ch == '\0') || (ch == '#')) ch = '*'; /* Protect encapsulation */
+ *pkt++ = ch;
+ }
+ return pkt;
} /* pack_string */
/* Convert a binary 64 bit threadid and pack it into a xmit buffer */
/* Return the advanced buffer pointer */
-static char * pack_threadid(char * pkt, threadref * id)
+static char *pack_threadid(char *pkt, threadref *id)
{
- char * limit ;
- unsigned char * altid ;
- altid = (unsigned char *) id ;
- limit = pkt + BUFTHREADIDSIZ ;
- while (pkt < limit) pkt = pack_hex_byte(pkt,*altid++) ;
- return pkt ;
+ char *limit;
+ unsigned char *altid;
+ altid = (unsigned char *)id;
+ limit = pkt + BUFTHREADIDSIZ;
+ while (pkt < limit) pkt = pack_hex_byte(pkt, *altid++);
+ return pkt;
} /* stub_pack_threadid */
/* UNFORTUNATELY, not all of the extended debugging system has yet been
These routines do the conversion.
An array of bytes is the correct treatment of an opaque identifier.
ints have endian issues.
- */
+*/
-static void int_to_threadref(threadref * id, int value)
+static void int_to_threadref(threadref *id, int value)
{
- unsigned char * scan ;
- scan = (unsigned char *) id ;
- {
- int i = 4 ;
- while (i--) *scan++ = 0 ;
- }
- *scan++ = (value >> 24) & 0xff ;
- *scan++ = (value >> 16) & 0xff ;
- *scan++ = (value >> 8) & 0xff ;
- *scan++ = (value & 0xff) ;
+ unsigned char *scan;
+ scan = (unsigned char *)id;
+ {
+ int i = 4;
+ while (i--) *scan++ = 0;
+ }
+ *scan++ = (value >> 24) & 0xff;
+ *scan++ = (value >> 16) & 0xff;
+ *scan++ = (value >> 8) & 0xff;
+ *scan++ = (value & 0xff);
}
-static int threadref_to_int(threadref * ref)
+static int threadref_to_int(threadref *ref)
{
- int value = 0 ;
- unsigned char * scan ;
- int i ;
-
- scan = (char *) ref ;
- scan += 4 ;
- i = 4 ;
- while (i-- > 0) value = (value << 8) | ((*scan++) & 0xff) ;
- return value ;
+ int value = 0;
+ unsigned char *scan;
+ int i;
+
+ scan = (char *)ref;
+ scan += 4;
+ i = 4;
+ while (i-- > 0) value = (value << 8) | ((*scan++) & 0xff);
+ return value;
} /* threadref_to_int */
-void copy_threadref(threadref * dest, threadref * src)
+void copy_threadref(threadref *dest, threadref *src)
{
- int i ;
- unsigned char * csrc, * cdest ;
- csrc = (unsigned char *) src ;
- cdest = (unsigned char *) dest ;
- i = 8 ;
- while (i--) *cdest++ = *csrc++ ;
+ int i;
+ unsigned char *csrc, *cdest;
+ csrc = (unsigned char *)src;
+ cdest = (unsigned char *)dest;
+ i = 8;
+ while (i--) *cdest++ = *csrc++;
}
int threadmatch(
- threadref * dest ,
- threadref * src
- )
+ threadref *dest,
+ threadref *src
+ )
{
- unsigned char * srcp, * destp ;
- int i , result ;
- srcp = (char *) src ;
- destp = (char *) dest ;
- i = 8 ;
- result = 1 ;
- while (i-- > 0 ) result &= (*srcp++ == *destp++) ? 1 : 0 ;
- return result ;
-} /* threadmatch */
+ unsigned char *srcp, *destp;
+ int i, result;
+ srcp = (char *)src;
+ destp = (char *)dest;
+ i = 8;
+ result = 1;
+ while (i-- > 0 ) result &= (*srcp++ == *destp++) ? 1 : 0;
+ return result;
+} /* threadmatch */
-static char * Tpkt_threadtag = "thread:" ;
+static char *Tpkt_threadtag = "thread:";
/* ----- STUB_PACK_TPKT_THREADID ------------------------------------ */
/* retreive, tag and insert a thread identifier into a T packet. */
/* Insert nothing if the thread identifier is not available */
-char * stub_pack_Tpkt_threadid(char * pkt)
+char *stub_pack_Tpkt_threadid(char *pkt)
{
- static threadref thread ;
- int fmt = 0 ; /* old format */
- PKT_TRACE("Tpkt-id","---") ;
- if (dbg_currthread(&thread))
- {
- pkt = pack_raw_string(pkt,Tpkt_threadtag) ;
- if (fmt)
- pkt = pack_threadid(pkt,&thread) ;
- else
- /* Until GDB lengthens its thread ids, we have to MASH
- the threadid into somthing shorter. PLEASE FIX GDB */
- pkt = pack_int(pkt,threadref_to_int(&thread)) ;
- *pkt++ = ';' ; /* terminate variable length int */
- *pkt = '\0' ; /* Null terminate to allow string to be printed, no++ */
- }
- PKT_TRACE("packedTpkt","--") ;
- return pkt ;
+ static threadref thread;
+ int fmt = 0; /* old format */
+ PKT_TRACE("Tpkt-id", "---");
+ if (dbg_currthread(&thread))
+ {
+ pkt = pack_raw_string(pkt, Tpkt_threadtag);
+ if (fmt)
+ pkt = pack_threadid(pkt, &thread);
+ else
+ /* Until GDB lengthens its thread ids, we have to MASH
+ the threadid into somthing shorter. PLEASE FIX GDB */
+ pkt = pack_int(pkt, threadref_to_int(&thread));
+ *pkt++ = ';' ; /* terminate variable length int */
+ *pkt = '\0'; /* Null terminate to allow string to be printed, no++ */
+ }
+ PKT_TRACE("packedTpkt", "--");
+ return pkt;
} /* stub_pack_Tpkt_threadid */
long stub_get_currthread (void)
{
- threadref thread ;
-
- if (dbg_currthread(&thread))
- return threadref_to_int(&thread) ;
- else
- return 0 ;
+ threadref thread;
+
+ if (dbg_currthread(&thread))
+ return threadref_to_int(&thread);
+ else
+ return 0;
}
void stub_pkt_currthread(
- char * inbuf,
- char * outbuf,
- int bufmax)
+ char *inbuf,
+ char *outbuf,
+ int bufmax)
{
- threadref thread ;
- char * base_out ;
- base_out = outbuf ;
-
- if (dbg_currthread(&thread))
- {
- *outbuf++ = 'Q' ;
- *outbuf++ = 'C' ; /* FIXME: Is this a reasonable code */
- outbuf = pack_int(outbuf, threadref_to_int(&thread)) ; /* Short form */
- }
- else outbuf = stub_pack_nak(outbuf) ;
- *outbuf = '\0' ; /* terminate response packet */
- PKT_TRACE("stub_pkt_currthread(resp) ",base_out) ;
+ threadref thread;
+ char *base_out;
+ base_out = outbuf;
+
+ if (dbg_currthread(&thread))
+ {
+ *outbuf++ = 'Q';
+ *outbuf++ = 'C'; /* FIXME: Is this a reasonable code */
+ outbuf = pack_int(outbuf, threadref_to_int(&thread)); /* Short form */
+ }
+ else outbuf = stub_pack_nak(outbuf);
+ *outbuf = '\0'; /* terminate response packet */
+ PKT_TRACE("stub_pkt_currthread(resp) ", base_out);
} /* stub_pkt_currthread */
/* ----- STUB_PKT_THREAD_ALIVE --------------------------------- */
static int thread_alive (int id)
{
- threadref thread ;
- struct cygmon_thread_debug_info info ;
-
- int_to_threadref(&thread, id) ;
- if (dbg_threadinfo(&thread, &info) &&
- info.context_exists)
- return 1 ;
- else
- return 0 ;
+ threadref thread;
+ struct cygmon_thread_debug_info info;
+
+ int_to_threadref(&thread, id);
+ if (dbg_threadinfo(&thread, &info) &&
+ info.context_exists)
+ return 1;
+ else
+ return 0;
}
-void stub_pkt_thread_alive(char * inbuf,
- char * outbuf,
- int bufmax)
+void stub_pkt_thread_alive(char *inbuf,
+ char *outbuf,
+ int bufmax)
{
- char * prebuf = inbuf ;
- int result ;
-
- if (prebuf != (inbuf = unpack_varlen_hex(inbuf,&result)))
- {
- if (thread_alive(result))
- {
- outbuf = stub_pack_ack(outbuf) ;
- *outbuf = '\0' ;
- return ;
- }
- }
- outbuf = stub_pack_nak(outbuf) ;
- *outbuf = '\0' ; /* terminate the response message */
+ char *prebuf = inbuf;
+ int result;
+
+ if (prebuf != (inbuf = unpack_varlen_hex(inbuf, &result)))
+ {
+ if (thread_alive(result))
+ {
+ outbuf = stub_pack_ack(outbuf);
+ *outbuf = '\0';
+ return;
+ }
+ }
+ outbuf = stub_pack_nak(outbuf);
+ *outbuf = '\0'; /* terminate the response message */
} /* stub_pkt_thread_alive */
-
+
/* ----- STUB_PKT_CHANGETHREAD ------------------------------- */
/* Switch the display of registers to that of a saved context */
capability. Therefore, the option to change the context back does
call the function to change registers. Also, there is no
forced context switch.
- 'p' - New format, long long threadid, no special cases
- 'c' - Old format, id for continue, 32 bit threadid max, possably less
- -1 means continue all threads
- 'g' - Old Format, id for general use (other than continue)
-
- replies:
- OK for success
- ENN for error
- */
+ 'p' - New format, long long threadid, no special cases
+ 'c' - Old format, id for continue, 32 bit threadid max, possably less
+ -1 means continue all threads
+ 'g' - Old Format, id for general use (other than continue)
+
+ replies:
+ OK for success
+ ENN for error
+*/
void stub_pkt_changethread(
- char * inbuf,
- char * outbuf,
- int bufmax)
+ char *inbuf,
+ char *outbuf,
+ int bufmax)
{
- threadref id ;
- int idefined = -1 ;
- char ch ;
- PKT_TRACE("setthread-pkt ",inbuf) ;
-
- /* Parse the incoming packet for a thread identifier */
- switch (ch = *inbuf++ ) /* handle various packet formats */
- {
- case 'p' : /* New format: mode:8,threadid:64 */
- inbuf = unpack_nibble(inbuf,&idefined) ;
- inbuf = unpack_threadid(inbuf,&id) ; /* even if startflag */
- break ;
- case 'c' : /* old format , specify thread for continue */
- if (inbuf[0] == '-' && inbuf[1] == '1') /* Hc-1 */
- _gdb_cont_thread = 0 ;
- else
- inbuf = unpack_varlen_hex(inbuf, &_gdb_cont_thread) ;
-
- if (_gdb_cont_thread == 0 || /* revert to any old thread */
- thread_alive(_gdb_cont_thread)) /* specified thread is alive */
- outbuf = stub_pack_ack(outbuf) ;
- else
- outbuf = stub_pack_nak(outbuf) ;
- break ;
- case 'g' : /* old format, specify thread for general operations */
- /* OLD format: parse a variable length hex string */
- /* OLD format consider special thread ids */
- {
- inbuf = unpack_varlen_hex(inbuf, &_gdb_general_thread) ;
- int_to_threadref(&id, _gdb_general_thread) ;
- switch (_gdb_general_thread)
- {
- case 0 : /* pick a thread, any thread */
- idefined = 2 ; /* select original interrupted context */
- break ;
- case -1 : /* all threads */
- idefined = 2 ;
- break ;
- default :
- idefined = 1 ; /* select the specified thread */
- break ;
- }
- }
- break ;
- default:
- outbuf = stub_pack_nak(outbuf) ;
- break ;
- } /* handle various packet formats */
-
- switch (idefined)
- {
- case -1 :
- /* Packet not supported, already NAKed, no further action */
- break ;
- case 0 :
- /* Switch back to interrupted context */
- _registers = ®isters[0] ;
- break ;
- case 1 :
- /* copy the saved registers into the backup registers */
- stub_copy_registers(alt_registers,registers) ;
- /* The OS will now update the values it has in a saved process context*/
- if (dbg_getthreadreg(&id,NUMREGS,&alt_registers[0]))
- {
- /* switch the registers pointer */
- _registers = &alt_registers[0] ;
- outbuf = stub_pack_ack(outbuf) ;
- }
- else
- outbuf = stub_pack_nak(outbuf) ;
- break ;
- case 2 :
- /* switch to interrupted context */
- outbuf = stub_pack_ack(outbuf) ;
- break ;
- default:
- outbuf = stub_pack_nak(outbuf) ;
- break ;
- }
- *outbuf = '\0' ; /* Terminate response pkt */
+ threadref id;
+ int idefined = -1;
+ char ch;
+ PKT_TRACE("setthread-pkt ", inbuf);
+
+ /* Parse the incoming packet for a thread identifier */
+ switch (ch = *inbuf++ ) /* handle various packet formats */
+ {
+ case 'p' : /* New format: mode:8, threadid:64 */
+ inbuf = unpack_nibble(inbuf, &idefined);
+ inbuf = unpack_threadid(inbuf, &id); /* even if startflag */
+ break;
+ case 'c' : /* old format, specify thread for continue */
+ if (inbuf[0] == '-' && inbuf[1] == '1') /* Hc-1 */
+ _gdb_cont_thread = 0;
+ else
+ inbuf = unpack_varlen_hex(inbuf, &_gdb_cont_thread);
+
+ if (_gdb_cont_thread == 0 || /* revert to any old thread */
+ thread_alive(_gdb_cont_thread)) /* specified thread is alive */
+ outbuf = stub_pack_ack(outbuf);
+ else
+ outbuf = stub_pack_nak(outbuf);
+ break;
+ case 'g' : /* old format, specify thread for general operations */
+ /* OLD format: parse a variable length hex string */
+ /* OLD format consider special thread ids */
+ {
+ inbuf = unpack_varlen_hex(inbuf, &_gdb_general_thread);
+ int_to_threadref(&id, _gdb_general_thread);
+ switch (_gdb_general_thread)
+ {
+ case 0 : /* pick a thread, any thread */
+ idefined = 2; /* select original interrupted context */
+ break;
+ case -1 : /* all threads */
+ idefined = 2;
+ break;
+ default :
+ idefined = 1; /* select the specified thread */
+ break;
+ }
+ }
+ break;
+ default:
+ outbuf = stub_pack_nak(outbuf);
+ break;
+ } /* handle various packet formats */
+
+ switch (idefined)
+ {
+ case -1 :
+ /* Packet not supported, already NAKed, no further action */
+ break;
+ case 0 :
+ /* Switch back to interrupted context */
+ _registers = ®isters[0];
+ break;
+ case 1 :
+ /* copy the saved registers into the backup registers */
+ stub_copy_registers(alt_registers, registers);
+ /* The OS will now update the values it has in a saved process context*/
+ if (dbg_getthreadreg(&id, NUMREGS, &alt_registers[0]))
+ {
+ /* switch the registers pointer */
+ _registers = &alt_registers[0];
+ outbuf = stub_pack_ack(outbuf);
+ }
+ else
+ outbuf = stub_pack_nak(outbuf);
+ break;
+ case 2 :
+ /* switch to interrupted context */
+ outbuf = stub_pack_ack(outbuf);
+ break;
+ default:
+ outbuf = stub_pack_nak(outbuf);
+ break;
+ }
+ *outbuf = '\0'; /* Terminate response pkt */
} /* stub_pkt_changethread */
/* This may be part of a multipacket transaction */
/* It would be hard to tell in the response packet the difference
between the end of list and an error in threadid encoding.
- */
+*/
-void stub_pkt_getthreadlist(char * inbuf,
- char * outbuf,
- int bufmax)
+void stub_pkt_getthreadlist(char *inbuf,
+ char *outbuf,
+ int bufmax)
{
- char * count_ptr ;
- char * done_ptr ;
- char * limit ;
- int start_flag , batchsize , result , count ;
- static threadref lastthread, nextthread ;
+ char *count_ptr;
+ char *done_ptr;
+ char *limit;
+ int start_flag = 0, batchsize, result, count;
+ static threadref lastthread, nextthread;
#if PKT_DEBUG
- char * r_base = outbuf ;
-#endif
- PKT_TRACE("pkt_getthreadlist: ",inbuf) ;
-
- count = 0 ;
- inbuf = unpack_nibble(inbuf,&start_flag) ;
- inbuf = unpack_byte(inbuf,&batchsize) ;
- inbuf = unpack_threadid(inbuf,&lastthread) ; /* even if startflag */
-
- /* Start building response packet */
- limit = outbuf + (bufmax - BUFTHREADIDSIZ - 10) ; /* id output packing limit */
- *outbuf++ = 'Q' ;
- *outbuf++ = 'M' ;
-
- /* Default values for count and done fields, save ptr to repatch */
- count_ptr = outbuf ; /* save to repatch count */
- outbuf = pack_hex_byte(outbuf,0) ;
- done_ptr = outbuf ; /* Backpatched later */
- *outbuf++ = '0' ; /* Done = 0 by default */
- outbuf = pack_threadid(outbuf,&lastthread) ;
-
- /* Loop through the threadid packing */
- while ((outbuf < limit) && (count < batchsize))
- {
- result = dbg_threadlist(start_flag,&lastthread,&nextthread) ;
- start_flag = 0 ; /* redundant but effective */
- if (!result)
- { *done_ptr = '1' ; /* pack the done flag */
- break ;
- }
+ char *r_base = outbuf;
+#endif
+ PKT_TRACE("pkt_getthreadlist: ", inbuf);
+
+ count = 0;
+ inbuf = unpack_nibble(inbuf, &start_flag);
+ inbuf = unpack_byte(inbuf, &batchsize);
+ inbuf = unpack_threadid(inbuf, &lastthread); /* even if startflag */
+
+ /* Start building response packet */
+ limit = outbuf + (bufmax - BUFTHREADIDSIZ - 10); /* id output packing limit */
+ *outbuf++ = 'Q' ;
+ *outbuf++ = 'M' ;
+
+ /* Default values for count and done fields, save ptr to repatch */
+ count_ptr = outbuf; /* save to repatch count */
+ outbuf = pack_hex_byte(outbuf, 0);
+ done_ptr = outbuf; /* Backpatched later */
+ *outbuf++ = '0'; /* Done = 0 by default */
+ outbuf = pack_threadid(outbuf, &lastthread);
+
+ /* Loop through the threadid packing */
+ while ((outbuf < limit) && (count < batchsize)) {
+ result = dbg_threadlist(start_flag, &lastthread, &nextthread);
+ start_flag = 0; /* redundant but effective */
+ if (!result) {
+ *done_ptr = '1'; /* pack the done flag */
+ break;
+ }
#if 0 /* DEBUG */
- if (threadmatch(&lastthread,&nextthread))
- {
- output_string("FAIL: Threadlist, not incrementing\n") ;
- *done_ptr = '1' ;
- break ;
- }
-#endif
- count++ ;
- outbuf = pack_threadid(outbuf,&nextthread) ;
- copy_threadref(&lastthread,&nextthread) ;
- }
- pack_hex_byte(count_ptr,count) ;/* backpatch, Pack the count field */
- *outbuf = '\0' ;
- PKT_TRACE("pkt_getthreadlist(resp) ",r_base) ;
+ if (threadmatch(&lastthread, &nextthread)) {
+ output_string("FAIL: Threadlist, not incrementing\n");
+ *done_ptr = '1';
+ break;
+ }
+#endif
+ count++;
+ outbuf = pack_threadid(outbuf, &nextthread);
+ copy_threadref(&lastthread, &nextthread);
+ }
+ pack_hex_byte(count_ptr, count);/* backpatch, Pack the count field */
+ *outbuf = '\0';
+ PKT_TRACE("pkt_getthreadlist(resp) ", r_base);
} /* pkt_getthreadlist */
/* Get the detailed information about a specific thread or process */
/*
-Encoding:
- 'Q':8,'P':8,mask:16
-
- Mask Fields
- threadid:1, # always request threadid
- context_exists:2,
- display:4,
- unique_name:8,
- more_display:16
- */
+ Encoding:
+ 'Q':8, 'P':8, mask:16
+
+ Mask Fields
+ threadid:1, # always request threadid
+ context_exists:2,
+ display:4,
+ unique_name:8,
+ more_display:16
+*/
void stub_pkt_getthreadinfo(
- char * inbuf,
- char * outbuf,
- int bufmax)
+ char *inbuf,
+ char *outbuf,
+ int bufmax)
{
- int mask ;
- int result ;
- threadref thread ;
- struct cygmon_thread_debug_info info ;
-
- info.context_exists = 0 ;
- info.thread_display = 0 ;
- info.unique_thread_name = 0 ;
- info.more_display = 0 ;
-
- /* Assume the packet identification chars have already been
- discarded by the packet demultiples routines */
- PKT_TRACE("PKT getthreadinfo",inbuf) ;
-
- inbuf = unpack_int(inbuf,&mask) ;
- inbuf = unpack_threadid(inbuf,&thread) ;
-
- result = dbg_threadinfo(&thread,&info) ; /* Make system call */
-
- if (result)
- {
- *outbuf++ = 'q' ;
- *outbuf++ = 'p' ;
- outbuf = pack_int(outbuf,mask) ;
- outbuf = pack_threadid(outbuf,&info.thread_id) ; /* echo threadid */
- if (mask & 2) /* context-exists */
- {
- outbuf = pack_int(outbuf,2) ; /* tag */
- outbuf = pack_hex_byte(outbuf,2) ; /* length */
- outbuf = pack_hex_byte(outbuf,info.context_exists) ;
- }
- if ((mask & 4) && info.thread_display)/* display */
- {
- outbuf = pack_int(outbuf,4) ; /* tag */
- outbuf = pack_string(outbuf,info.thread_display) ;
- }
- if ((mask & 8) && info.unique_thread_name) /* unique_name */
- {
- outbuf = pack_int(outbuf,8) ;
- outbuf = pack_string(outbuf,info.unique_thread_name) ;
- }
- if ((mask & 16) && info.more_display) /* more display */
- {
- outbuf = pack_int(outbuf,16) ; /* tag 16 */
- outbuf = pack_string(outbuf,info.more_display) ;
- }
- }
- else
- {
- PKT_TRACE("FAIL: dbg_threadinfo\n", "") ;
- outbuf = stub_pack_nak(outbuf) ;
- }
- *outbuf = '\0' ;
+ int mask;
+ int result;
+ threadref thread;
+ struct cygmon_thread_debug_info info;
+
+ info.context_exists = 0;
+ info.thread_display = 0;
+ info.unique_thread_name = 0;
+ info.more_display = 0;
+
+ /* Assume the packet identification chars have already been
+ discarded by the packet demultiples routines */
+ PKT_TRACE("PKT getthreadinfo", inbuf);
+
+ inbuf = unpack_int(inbuf, &mask);
+ inbuf = unpack_threadid(inbuf, &thread);
+
+ result = dbg_threadinfo(&thread, &info); /* Make system call */
+
+ if (result)
+ {
+ *outbuf++ = 'q';
+ *outbuf++ = 'p';
+ outbuf = pack_int(outbuf, mask);
+ outbuf = pack_threadid(outbuf, &info.thread_id); /* echo threadid */
+ if (mask & 2) /* context-exists */
+ {
+ outbuf = pack_int(outbuf, 2); /* tag */
+ outbuf = pack_hex_byte(outbuf, 2); /* length */
+ outbuf = pack_hex_byte(outbuf, info.context_exists);
+ }
+ if ((mask & 4) && info.thread_display)/* display */
+ {
+ outbuf = pack_int(outbuf, 4); /* tag */
+ outbuf = pack_string(outbuf, info.thread_display);
+ }
+ if ((mask & 8) && info.unique_thread_name) /* unique_name */
+ {
+ outbuf = pack_int(outbuf, 8);
+ outbuf = pack_string(outbuf, info.unique_thread_name);
+ }
+ if ((mask & 16) && info.more_display) /* more display */
+ {
+ outbuf = pack_int(outbuf, 16); /* tag 16 */
+ outbuf = pack_string(outbuf, info.more_display);
+ }
+ }
+ else
+ {
+ PKT_TRACE("FAIL: dbg_threadinfo\n", "");
+ outbuf = stub_pack_nak(outbuf);
+ }
+ *outbuf = '\0';
} /* stub_pkt_getthreadinfo */
int stub_lock_scheduler(int lock, /* 0 to unlock, 1 to lock */
- int mode, /* 0 for step, 1 for continue */
- long id) /* current thread */
+ int mode, /* 0 for step, 1 for continue */
+ long id) /* current thread */
{
- threadref thread;
+ threadref thread;
- int_to_threadref(&thread, id) ;
- return dbg_scheduler(&thread, lock, mode) ;
+ int_to_threadref(&thread, id);
+ return dbg_scheduler(&thread, lock, mode);
}
-\f
+
#if GDB_MOCKUP
/* ------ MATCHED GDB SIDE PACKET ENCODING AND PARSING ----------------- */
-char * pack_nibble(char * buf, int nibble)
+char *pack_nibble(char *buf, int nibble)
{
- *buf++ = hexchars[(nibble & 0x0f)] ;
- return buf ;
+ *buf++ = hexchars[(nibble & 0x0f)];
+ return buf;
} /* pack_nibble */
#if 0
-static char * unpack_short(char * buf,int * value)
+static char *unpack_short(char *buf, int *value)
{
- *value = stub_unpack_int(buf,4) ;
- return buf + 4 ;
+ *value = stub_unpack_int(buf, 4);
+ return buf + 4;
}
-static char * pack_short(
- char * buf,
- unsigned int value)
+static char *pack_short(
+ char *buf,
+ unsigned int value)
{
- buf = pack_hex_byte(buf,(value >> 8) & 0xff) ;
- buf = pack_hex_byte(buf,(value & 0xff)) ;
- return buf ;
+ buf = pack_hex_byte(buf, (value >> 8) & 0xff);
+ buf = pack_hex_byte(buf, (value & 0xff));
+ return buf;
} /* pack_short */
#endif
/* Generally, I dont bury xmit and receive calls inside packet formatters
and parsers
- */
+*/
/* ----- PACK_SETTHREAD_REQUEST ------------------------------------- */
/* Encoding: ??? decode gdb/remote.c
- 'Q':8,'p':8,idefined:8,threadid:32 ;
- */
-
-char * pack_setthread_request(
- char * buf,
- char fmt, /* c,g or, p */
- int idformat ,
- threadref * threadid )
+ 'Q':8, 'p':8, idefined:8, threadid:32;
+*/
+
+char *pack_setthread_request(
+ char *buf,
+ char fmt, /* c, g or, p */
+ int idformat,
+ threadref * threadid )
{
- *buf++ = fmt ;
-
- if (fmt == 'p')
- { /* pack the long form */
- buf = pack_nibble(buf,idformat) ;
- buf = pack_threadid(buf,threadid) ;
- }
- else
- { /* pack the shorter form - Serious truncation */
- /* There are reserved identifieds 0 , -1 */
- int quickref = threadref_to_int(threadid) ;
- buf = pack_varlen_hex(buf,quickref) ;
- }
- *buf++ = '\0' ; /* end_of_packet */
- return buf ;
+ *buf++ = fmt;
+
+ if (fmt == 'p')
+ { /* pack the long form */
+ buf = pack_nibble(buf, idformat);
+ buf = pack_threadid(buf, threadid) ;
+ }
+ else
+ { /* pack the shorter form - Serious truncation */
+ /* There are reserved identifieds 0, -1 */
+ int quickref = threadref_to_int(threadid);
+ buf = pack_varlen_hex(buf, quickref);
+ }
+ *buf++ = '\0'; /* end_of_packet */
+ return buf;
} /* pack_setthread_request */
/* -------- PACK_THREADLIST-REQUEST --------------------------------- */
-/* Format: i'Q':8,i"L":8,initflag:8,batchsize:16,lastthreadid:32 */
+/* Format: i'Q':8, i"L":8, initflag:8, batchsize:16, lastthreadid:32 */
-char * pack_threadlist_request(
- char * pkt,
- int startflag,
- int threadcount,
- threadref * nextthread
- )
+char *pack_threadlist_request(
+ char *pkt,
+ int startflag,
+ int threadcount,
+ threadref *nextthread
+ )
{
- *pkt++ = 'q' ;
- *pkt++ = 'L' ;
- pkt = pack_nibble(pkt,startflag) ; /* initflag 1 bytes */
- pkt = pack_hex_byte(pkt,threadcount) ; /* threadcount 2 bytes */
- pkt = pack_threadid(pkt,nextthread) ; /* 64 bit thread identifier */
- *pkt = '\0' ;
- return pkt ;
+ *pkt++ = 'q';
+ *pkt++ = 'L';
+ pkt = pack_nibble(pkt, startflag); /* initflag 1 bytes */
+ pkt = pack_hex_byte(pkt, threadcount); /* threadcount 2 bytes */
+ pkt = pack_threadid(pkt, nextthread); /* 64 bit thread identifier */
+ *pkt = '\0';
+ return pkt;
} /* remote_threadlist_request */
/* ---------- PARSE_THREADLIST_RESPONSE ------------------------------------ */
-/* Encoding: 'q':8,'M':8,count:16,done:8,argthreadid:64,(threadid:64)* */
+/* Encoding: 'q':8, 'M':8, count:16, done:8, argthreadid:64, (threadid:64)* */
int parse_threadlist_response(
- char * pkt,
- threadref * original_echo,
- threadref * resultlist,
- int * doneflag)
+ char *pkt,
+ threadref *original_echo,
+ threadref *resultlist,
+ int *doneflag)
{
- char * limit ;
- int count, resultcount , done ;
- resultcount = 0 ;
-
- /* assume the 'q' and 'M chars have been stripped */
- PKT_TRACE("parse-threadlist-response ",pkt) ;
- limit = pkt + (STUB_BUF_MAX - BUFTHREADIDSIZ) ; /* done parse past here */
- pkt = unpack_byte(pkt,&count) ; /* count field */
- pkt = unpack_nibble(pkt,&done) ;
- /* The first threadid is the argument threadid */
- pkt = unpack_threadid(pkt,original_echo) ; /* should match query packet */
- while ((count-- > 0) && (pkt < limit))
- {
- pkt = unpack_threadid(pkt,resultlist++) ;
- resultcount++ ;
- }
- if (doneflag) *doneflag = done ;
- return resultcount ; /* successvalue */
+ char *limit;
+ int count, resultcount, done;
+ resultcount = 0;
+
+ /* assume the 'q' and 'M chars have been stripped */
+ PKT_TRACE("parse-threadlist-response ", pkt);
+ limit = pkt + (STUB_BUF_MAX - BUFTHREADIDSIZ); /* done parse past here */
+ pkt = unpack_byte(pkt, &count) ; /* count field */
+ pkt = unpack_nibble(pkt, &done);
+ /* The first threadid is the argument threadid */
+ pkt = unpack_threadid(pkt, original_echo); /* should match query packet */
+ while ((count-- > 0) && (pkt < limit))
+ {
+ pkt = unpack_threadid(pkt, resultlist++);
+ resultcount++;
+ }
+ if (doneflag) *doneflag = done;
+ return resultcount; /* successvalue */
} /* parse_threadlist_response */
-
+
struct gdb_ext_thread_info
{
- threadref threadid ;
- int active ;
- char display[256] ;
- char shortname[32] ;
- char more_display[256] ;
-} ;
+ threadref threadid;
+ int active;
+ char display[256];
+ char shortname[32];
+ char more_display[256];
+};
/* ----- PACK_THREAD_INFO_REQUEST -------------------------------- */
-/*
- threadid:1, # always request threadid
- context_exists:2,
- display:4,
- unique_name:8,
- more_display:16
- */
+/*
+ threadid:1, # always request threadid
+ context_exists:2,
+ display:4,
+ unique_name:8,
+ more_display:16
+*/
-/* Encoding: 'Q':8,'P':8,mask:32,threadid:64 */
+/* Encoding: 'Q':8, 'P':8, mask:32, threadid:64 */
-char * pack_threadinfo_request(char * pkt,
- int mode,
- threadref * id
- )
+char *pack_threadinfo_request(char *pkt,
+ int mode,
+ threadref *id
+ )
{
- *pkt++ = 'Q' ;
- *pkt++ = 'P' ;
- pkt = pack_int(pkt,mode) ; /* mode */
- pkt = pack_threadid(pkt,id) ; /* threadid */
- *pkt = '\0' ; /* terminate */
- return pkt ;
+ *pkt++ = 'Q';
+ *pkt++ = 'P';
+ pkt = pack_int(pkt, mode); /* mode */
+ pkt = pack_threadid(pkt, id); /* threadid */
+ *pkt = '\0'; /* terminate */
+ return pkt;
} /* pack_thread_info_request */
-static char * unpack_string(
- char * src,
- char * dest,
- int length)
+static char *unpack_string(
+ char *src,
+ char *dest,
+ int length)
{
- while (length--) *dest++ = *src++ ;
- *dest = '\0' ;
- return src ;
+ while (length--) *dest++ = *src++;
+ *dest = '\0';
+ return src;
} /* unpack_string */
-void output_threadid(char * title,threadref * ref)
+void output_threadid(char *title, threadref *ref)
{
- char hexid[20] ;
- pack_threadid(&hexid[0],ref) ; /* Convert threead id into hex */
- hexid[16] = 0 ;
- output_string(title) ;
- output_string(&hexid[0]) ;
- output_string("\n") ;
+ char hexid[20];
+ pack_threadid(&hexid[0], ref); /* Convert threead id into hex */
+ hexid[16] = 0;
+ output_string(title);
+ output_string(&hexid[0]);
+ output_string("\n");
}
/* ------ REMOTE_UPK_THREAD_INFO_RESPONSE ------------------------------- */
/* Unpack the response of a detailed thread info packet */
-/* Encoding: i'Q':8,i'R':8,argmask:16,threadid:64,(tag:8,length:16,data:x)* */
+/* Encoding: i'Q':8, i'R':8, argmask:16, threadid:64, (tag:8, length:16, data:x)* */
#define TAG_THREADID 1
#define TAG_EXISTS 2
#define TAG_DISPLAY 4
#define TAG_THREADNAME 8
-#define TAG_MOREDISPLAY 16
+#define TAG_MOREDISPLAY 16
int remote_upk_thread_info_response(
- char * pkt,
- threadref * expectedref ,
- struct gdb_ext_thread_info * info)
+ char *pkt,
+ threadref *expectedref,
+ struct gdb_ext_thread_info *info)
{
- int mask, length ;
- unsigned int tag ;
- threadref ref ;
- char * limit = pkt + 500 ; /* plausable parsing limit */
- int retval = 1 ;
-
- PKT_TRACE("upk-threadinfo ",pkt) ;
-
- /* info->threadid = 0 ; FIXME: implement zero_threadref */
- info->active = 0 ;
- info->display[0] = '\0' ;
- info->shortname[0] = '\0' ;
- info->more_display[0] = '\0' ;
-
- /* Assume the characters indicating the packet type have been stripped */
- pkt = unpack_int(pkt,&mask) ; /* arg mask */
- pkt = unpack_threadid(pkt , &ref) ;
-
- if (! threadmatch(&ref,expectedref))
- { /* This is an answer to a different request */
- output_string("FAIL Thread mismatch\n") ;
- output_threadid("ref ",&ref) ;
- output_threadid("expected ",expectedref) ;
- return 0 ;
- }
- copy_threadref(&info->threadid,&ref) ;
-
- /* Loop on tagged fields , try to bail if somthing goes wrong */
- if (mask==0) output_string("OOPS NO MASK \n") ;
-
- while ((pkt < limit) && mask && *pkt) /* packets are terminated with nulls */
- {
- pkt = unpack_int(pkt,&tag) ; /* tag */
- pkt = unpack_byte(pkt,&length) ; /* length */
- if (! (tag & mask)) /* tags out of synch with mask */
- {
- output_string("FAIL: threadinfo tag mismatch\n") ;
- retval = 0 ;
- break ;
- }
- if (tag == TAG_THREADID)
- {
- output_string("unpack THREADID\n") ;
- if (length != 16)
- {
- output_string("FAIL: length of threadid is not 16\n") ;
- retval = 0 ;
- break ;
- }
- pkt = unpack_threadid(pkt,&ref) ;
- mask = mask & ~ TAG_THREADID ;
- continue ;
- }
- if (tag == TAG_EXISTS)
- {
- info->active = stub_unpack_int(pkt,length) ;
- pkt += length ;
- mask = mask & ~(TAG_EXISTS) ;
- if (length > 8)
- {
- output_string("FAIL: 'exists' length too long\n") ;
- retval = 0 ;
- break ;
- }
- continue ;
- }
- if (tag == TAG_THREADNAME)
- {
- pkt = unpack_string(pkt,&info->shortname[0],length) ;
- mask = mask & ~TAG_THREADNAME ;
- continue ;
- }
- if (tag == TAG_DISPLAY)
- {
- pkt = unpack_string(pkt,&info->display[0],length) ;
- mask = mask & ~TAG_DISPLAY ;
- continue ;
- }
- if (tag == TAG_MOREDISPLAY)
- {
- pkt = unpack_string(pkt,&info->more_display[0],length) ;
- mask = mask & ~TAG_MOREDISPLAY ;
- continue ;
- }
- output_string("FAIL: unknown info tag\n") ;
- break ; /* Not a tag we know about */
- }
- return retval ;
+ int mask, length;
+ unsigned int tag;
+ threadref ref;
+ char *limit = pkt + 500; /* plausable parsing limit */
+ int retval = 1;
+
+ PKT_TRACE("upk-threadinfo ", pkt);
+
+ /* info->threadid = 0; FIXME: implement zero_threadref */
+ info->active = 0;
+ info->display[0] = '\0';
+ info->shortname[0] = '\0';
+ info->more_display[0] = '\0';
+
+ /* Assume the characters indicating the packet type have been stripped */
+ pkt = unpack_int(pkt, &mask); /* arg mask */
+ pkt = unpack_threadid(pkt, &ref);
+
+ if (! threadmatch(&ref, expectedref))
+ { /* This is an answer to a different request */
+ output_string("FAIL Thread mismatch\n");
+ output_threadid("ref ", &ref);
+ output_threadid("expected ", expectedref);
+ return 0;
+ }
+ copy_threadref(&info->threadid, &ref);
+
+ /* Loop on tagged fields, try to bail if somthing goes wrong */
+ if (mask==0) output_string("OOPS NO MASK \n");
+
+ while ((pkt < limit) && mask && *pkt) /* packets are terminated with nulls */
+ {
+ pkt = unpack_int(pkt, &tag); /* tag */
+ pkt = unpack_byte(pkt, &length); /* length */
+ if (! (tag & mask)) /* tags out of synch with mask */
+ {
+ output_string("FAIL: threadinfo tag mismatch\n");
+ retval = 0;
+ break;
+ }
+ if (tag == TAG_THREADID)
+ {
+ output_string("unpack THREADID\n");
+ if (length != 16)
+ {
+ output_string("FAIL: length of threadid is not 16\n");
+ retval = 0;
+ break;
+ }
+ pkt = unpack_threadid(pkt, &ref);
+ mask = mask & ~ TAG_THREADID;
+ continue;
+ }
+ if (tag == TAG_EXISTS)
+ {
+ info->active = stub_unpack_int(pkt, length);
+ pkt += length;
+ mask = mask & ~(TAG_EXISTS);
+ if (length > 8)
+ {
+ output_string("FAIL: 'exists' length too long\n");
+ retval = 0;
+ break;
+ }
+ continue;
+ }
+ if (tag == TAG_THREADNAME)
+ {
+ pkt = unpack_string(pkt, &info->shortname[0], length);
+ mask = mask & ~TAG_THREADNAME;
+ continue;
+ }
+ if (tag == TAG_DISPLAY)
+ {
+ pkt = unpack_string(pkt, &info->display[0], length);
+ mask = mask & ~TAG_DISPLAY;
+ continue;
+ }
+ if (tag == TAG_MOREDISPLAY)
+ {
+ pkt = unpack_string(pkt, &info->more_display[0], length);
+ mask = mask & ~TAG_MOREDISPLAY;
+ continue;
+ }
+ output_string("FAIL: unknown info tag\n");
+ break; /* Not a tag we know about */
+ }
+ return retval ;
} /* parse-thread_info_response */
/* ---- REMOTE_PACK_CURRTHREAD_REQUEST ---------------------------- */
/* This is a request to emit the T packet */
-/* FORMAT: 'q':8,'C' */
+/* FORMAT: 'q':8, 'C' */
-char * remote_pack_currthread_request(char * pkt )
+char *remote_pack_currthread_request(char *pkt )
{
- *pkt++ = 'q' ;
- *pkt++ = 'C' ;
- *pkt = '\0' ;
- return pkt ;
+ *pkt++ = 'q';
+ *pkt++ = 'C';
+ *pkt = '\0';
+ return pkt;
} /* remote_pack_currthread_request */
int remote_upk_currthread_response(
- char * pkt,
- int *thr ) /* Parse a T packet */
+ char *pkt,
+ int *thr ) /* Parse a T packet */
{
- int retval = 0 ;
- PKT_TRACE("upk-currthreadresp ",pkt) ;
+ int retval = 0;
+ PKT_TRACE("upk-currthreadresp ", pkt);
#if 0
- {
- static char threadtag[8] = "thread" ;
- int retval = 0 ;
- int i , found ;
- char ch ;
- int quickid ;
-
- /* Unpack as a t packet */
- while (((ch = *pkt++) != ':') /* scan for : thread */
- && (ch != '\0')) /* stop at end of packet */
-
- {
- found = 0 ;
- i = 0 ;
- while ((ch = *pkt++) == threadtag[i++]) ;
- if (i == 8) /* string match "thread" */
- {
- pkt = unpack_varlen_hex(pkt,&quickid) ;
- retval = 1;
- break ;
- }
- retval = 0 ;
- }
- }
+ {
+ static char threadtag[8] = "thread";
+ int retval = 0;
+ int i, found;
+ char ch;
+ int quickid;
+
+ /* Unpack as a t packet */
+ while (((ch = *pkt++) != ':') /* scan for : thread */
+ && (ch != '\0')) /* stop at end of packet */
+
+ {
+ found = 0;
+ i = 0;
+ while ((ch = *pkt++) == threadtag[i++]);
+ if (i == 8) /* string match "thread" */
+ {
+ pkt = unpack_varlen_hex(pkt, &quickid);
+ retval = 1;
+ break;
+ }
+ retval = 0;
+ }
+ }
#else
- pkt = unpack_threadid(pkt, thr) ;
- retval = 1 ;
-#endif
- return retval ;
+ pkt = unpack_threadid(pkt, thr);
+ retval = 1;
+#endif
+ return retval;
} /* remote_upk_currthread_response */
/* -------- REMOTE_UPK-SIMPLE_ACK --------------------------------- */
/* Decode a response which is eother "OK" or "Enn"
- fillin error code, fillin pkfag-1== undef, 0==nak, 1 == ack ;
+ fillin error code, fillin pkfag-1== undef, 0==nak, 1 == ack;
return advanced packet pointer */
-char * remote_upk_simple_ack(
- char * buf,
- int * pkflag,
- int * errcode)
+char *remote_upk_simple_ack(
+ char *buf,
+ int *pkflag,
+ int *errcode)
{
- int lclerr = 0 ;
- char ch = *buf++ ;
- int retval = -1 ; /* Undefined ACK , a protocol error */
- if (ch == 'E') /* NAK */
- {
- buf = unpack_byte(buf,&lclerr) ;
- retval = 0 ; /* transaction failed, explicitly */
- }
- else
- if ((ch == 'O') && (*buf++ == 'K')) /* ACK */
- retval = 1 ; /* transaction succeeded */
- *pkflag = retval ;
- *errcode = lclerr ;
- return buf ;
+ int lclerr = 0;
+ char ch = *buf++;
+ int retval = -1; /* Undefined ACK, a protocol error */
+ if (ch == 'E') /* NAK */
+ {
+ buf = unpack_byte(buf, &lclerr);
+ retval = 0; /* transaction failed, explicitly */
+ }
+ else
+ if ((ch == 'O') && (*buf++ == 'K')) /* ACK */
+ retval = 1; /* transaction succeeded */
+ *pkflag = retval;
+ *errcode = lclerr;
+ return buf;
} /* remote-upk_simple_ack */
/* -------- PACK_THREADALIVE_REQUEST ------------------------------- */
-char * pack_threadalive_request(
- char * buf,
- threadref * threadid)
+char *pack_threadalive_request(
+ char *buf,
+ threadref *threadid)
{
- *buf++ = 'T' ;
- buf = pack_threadid(buf,threadid) ;
- *buf = '\0' ;
- return buf ;
+ *buf++ = 'T';
+ buf = pack_threadid(buf, threadid);
+ *buf = '\0';
+ return buf;
} /* pack_threadalive_request */
-
+
#endif /* GDB_MOCKUP */
-\f
+
/* ---------------------------------------------------------------------- */
/* UNIT_TESTS SUBSECTION */
/* ---------------------------------------------------------------------- */
#if UNIT_TEST
-extern void output_string(char * message) ;
-static char test_req[400] ;
-static char t_response[400] ;
+extern void output_string(char *message);
+static char test_req[400];
+static char t_response[400];
/* ----- DISPLAY_THREAD_INFO ---------------------------------------------- */
/* Use local cygmon string output utiities */
-void display_thread_info(struct gdb_ext_thread_info * info)
+void display_thread_info(struct gdb_ext_thread_info *info)
{
- output_threadid("Threadid: ",&info->threadid) ;
- /* short name */
- output_string("Name: ") ; output_string(info->shortname) ; output_string("\n");
- /* format display state */
- output_string("State: ") ; output_string(info->display) ; output_string("\n") ;
- /* additional data */
- output_string("other: ");output_string(info->more_display);
- output_string("\n\n");
+ output_threadid("Threadid: ", &info->threadid);
+ /* short name */
+ output_string("Name: "); output_string(info->shortname); output_string("\n");
+ /* format display state */
+ output_string("State: "); output_string(info->display); output_string("\n");
+ /* additional data */
+ output_string("other: ");output_string(info->more_display);
+ output_string("\n\n");
} /* display_thread_info */
/* --- CURRTHREAD-TEST -------------------------------------------- */
-static int currthread_test(threadref * thread)
+static int currthread_test(threadref *thread)
{
- int result ;
- int threadid ;
- output_string("TEST: currthread\n") ;
- remote_pack_currthread_request(test_req) ;
- stub_pkt_currthread(test_req+2,t_response,STUB_BUF_MAX) ;
- result = remote_upk_currthread_response(t_response+2, &threadid) ;
- if (result)
- {
- output_string("PASS getcurthread\n") ;
- /* FIXME: print the thread */
- }
- else
- output_string("FAIL getcurrthread\n") ;
- return result ;
+ int result;
+ int threadid;
+ output_string("TEST: currthread\n");
+ remote_pack_currthread_request(test_req);
+ stub_pkt_currthread(test_req+2, t_response, STUB_BUF_MAX);
+ result = remote_upk_currthread_response(t_response+2, &threadid);
+ if (result)
+ {
+ output_string("PASS getcurthread\n");
+ /* FIXME: print the thread */
+ }
+ else
+ output_string("FAIL getcurrthread\n");
+ return result;
} /* currthread_test */
/* ------ SETTHREAD_TEST ------------------------------------------- */
- /* use a known thread from previous test */
+/* use a known thread from previous test */
-static int setthread_test(threadref * thread)
+static int setthread_test(threadref *thread)
{
- int result, errcode ;
- output_string("TEST: setthread\n") ;
-
- pack_setthread_request(test_req,'p',1,thread) ;
- stub_pkt_changethread(test_req,t_response,STUB_BUF_MAX) ;
- remote_upk_simple_ack(t_response,&result,&errcode) ;
- switch (result)
- {
- case 0 :
- output_string("FAIL setthread\n") ;
- break ;
- case 1 :
- output_string("PASS setthread\n") ;
- break ;
- default :
- output_string("FAIL setthread -unrecognized response\n") ;
- break ;
- }
- return result ;
+ int result, errcode;
+ output_string("TEST: setthread\n");
+
+ pack_setthread_request(test_req, 'p', 1, thread);
+ stub_pkt_changethread(test_req, t_response, STUB_BUF_MAX);
+ remote_upk_simple_ack(t_response, &result, &errcode);
+ switch (result)
+ {
+ case 0 :
+ output_string("FAIL setthread\n");
+ break;
+ case 1 :
+ output_string("PASS setthread\n");
+ break;
+ default :
+ output_string("FAIL setthread -unrecognized response\n");
+ break;
+ }
+ return result;
} /* setthread_test */
/* ------ THREADACTIVE_TEST ---------------------- */
- /* use known thread */
- /* pack threadactive packet */
- /* process threadactive packet */
- /* parse threadactive response */
- /* check results */
+/* use known thread */
+/* pack threadactive packet */
+/* process threadactive packet */
+/* parse threadactive response */
+/* check results */
-int threadactive_test(threadref * thread)
+int threadactive_test(threadref *thread)
{
- int result ;
- int errcode ;
- output_string("TEST: threadactive\n") ;
- pack_threadalive_request(test_req,thread) ;
- stub_pkt_thread_alive(test_req+1,t_response,STUB_BUF_MAX);
- remote_upk_simple_ack(t_response,&result,&errcode) ;
- switch (result)
- {
- case 0 :
- output_string("FAIL threadalive\n") ;
- break ;
- case 1 :
- output_string("PASS threadalive\n") ;
- break ;
- default :
- output_string("FAIL threadalive -unrecognized response\n") ;
- break ;
- }
- return result ;
+ int result;
+ int errcode;
+ output_string("TEST: threadactive\n");
+ pack_threadalive_request(test_req, thread);
+ stub_pkt_thread_alive(test_req+1, t_response, STUB_BUF_MAX);
+ remote_upk_simple_ack(t_response, &result, &errcode);
+ switch (result)
+ {
+ case 0 :
+ output_string("FAIL threadalive\n");
+ break;
+ case 1 :
+ output_string("PASS threadalive\n");
+ break;
+ default :
+ output_string("FAIL threadalive -unrecognized response\n");
+ break;
+ }
+ return result;
} /* threadactive_test */
/* ------ REMOTE_GET_THREADINFO -------------------------------------- */
int remote_get_threadinfo(
- threadref * threadid,
- int fieldset , /* TAG mask */
- struct gdb_ext_thread_info * info
- )
+ threadref *threadid,
+ int fieldset, /* TAG mask */
+ struct gdb_ext_thread_info *info
+ )
{
- int result ;
- pack_threadinfo_request(test_req,fieldset,threadid) ;
- stub_pkt_getthreadinfo(test_req+2,t_response,STUB_BUF_MAX) ;
- result = remote_upk_thread_info_response(t_response+2,threadid,info) ;
- return result ;
+ int result;
+ pack_threadinfo_request(test_req, fieldset, threadid);
+ stub_pkt_getthreadinfo(test_req+2, t_response, STUB_BUF_MAX);
+ result = remote_upk_thread_info_response(t_response+2, threadid, info);
+ return result;
} /* remote_get-thrreadinfo */
-static struct gdb_ext_thread_info test_info ;
+static struct gdb_ext_thread_info test_info;
-static int get_and_display_threadinfo(threadref * thread)
+static int get_and_display_threadinfo(threadref *thread)
{
- int mode ;
- int result ;
- /* output_string("TEST: get and display threadinfo\n") ; */
-
- mode = TAG_THREADID | TAG_EXISTS | TAG_THREADNAME
- | TAG_MOREDISPLAY | TAG_DISPLAY ;
- result = remote_get_threadinfo(thread,mode,&test_info) ;
- if (result) display_thread_info(&test_info) ;
+ int mode;
+ int result;
+ /* output_string("TEST: get and display threadinfo\n"); */
+
+ mode = TAG_THREADID | TAG_EXISTS | TAG_THREADNAME
+ | TAG_MOREDISPLAY | TAG_DISPLAY;
+ result = remote_get_threadinfo(thread, mode, &test_info);
+ if (result) display_thread_info(&test_info);
#if 0 /* silent subtest */
- if (result)
- output_string("PASS: get_and_display threadinfo\n") ;
- else
- output_string("FAIL: get_and_display threadinfo\n") ;
-#endif
- return result ;
+ if (result)
+ output_string("PASS: get_and_display threadinfo\n");
+ else
+ output_string("FAIL: get_and_display threadinfo\n");
+#endif
+ return result;
} /* get-and-display-threadinfo */
/* ----- THREADLIST_TEST ------------------------------------------ */
#define TESTLISTSIZE 16
#define TLRSIZ 2
-static threadref test_threadlist[TESTLISTSIZE] ;
+static threadref test_threadlist[TESTLISTSIZE];
static int threadlist_test(void)
{
- int done, i , result_count ;
- int startflag = 1 ;
- int result = 1 ;
- int loopcount = 0 ;
- static threadref nextthread ;
- static threadref echo_nextthread ;
-
- output_string("TEST: threadlist\n") ;
-
- done = 0 ;
- while (! done)
- {
- if (loopcount++ > 10)
- {
- result = 0 ;
- output_string("FAIL: Threadlist test -infinite loop-\n") ;
- break ;
- }
- pack_threadlist_request(test_req,startflag,TLRSIZ,&nextthread) ;
- startflag = 0 ; /* clear for later iterations */
- stub_pkt_getthreadlist(test_req+2,t_response,STUB_BUF_MAX);
- result_count = parse_threadlist_response(t_response+2,
- &echo_nextthread,
- &test_threadlist[0],&done) ;
- if (! threadmatch(&echo_nextthread,&nextthread))
- {
- output_string("FAIL: threadlist did not echo arg thread\n");
- result = 0 ;
- break ;
- }
- if (result_count <= 0)
- {
- if (done != 0)
- { output_string("FAIL threadlist_test, failed to get list");
- result = 0 ;
- }
- break ;
- }
- if (result_count > TLRSIZ)
- {
- output_string("FAIL: threadlist response longer than requested\n") ;
- result = 0 ;
- break ;
- }
- /* Setup to resume next batch of thread references , set nestthread */
- copy_threadref(&nextthread,&test_threadlist[result_count-1]) ;
- /* output_threadid("last-of-batch",&nextthread) ; */
- i = 0 ;
- while (result_count--)
- {
- if (0) /* two display alternatives */
- output_threadid("truncatedisplay",&test_threadlist[i++]) ;
- else
- get_and_display_threadinfo(&test_threadlist[i++]) ;
- }
-
- }
- if (!result)
- output_string("FAIL: threadlist test\n") ;
- else output_string("PASS: Threadlist test\n") ;
- return result ;
+ int done, i, result_count;
+ int startflag = 1;
+ int result = 1;
+ int loopcount = 0;
+ static threadref nextthread;
+ static threadref echo_nextthread;
+
+ output_string("TEST: threadlist\n");
+
+ done = 0;
+ while (! done) {
+ if (loopcount++ > 10) {
+ result = 0;
+ output_string("FAIL: Threadlist test -infinite loop-\n");
+ break;
+ }
+ pack_threadlist_request(test_req, startflag, TLRSIZ, &nextthread);
+ startflag = 0; /* clear for later iterations */
+ stub_pkt_getthreadlist(test_req+2, t_response, STUB_BUF_MAX);
+ result_count = parse_threadlist_response(t_response+2,
+ &echo_nextthread,
+ &test_threadlist[0], &done);
+ if (! threadmatch(&echo_nextthread, &nextthread)) {
+ output_string("FAIL: threadlist did not echo arg thread\n");
+ result = 0;
+ break;
+ }
+ if (result_count <= 0) {
+ if (done != 0)
+ { output_string("FAIL threadlist_test, failed to get list");
+ result = 0;
+ }
+ break;
+ }
+ if (result_count > TLRSIZ) {
+ output_string("FAIL: threadlist response longer than requested\n");
+ result = 0;
+ break;
+ }
+ /* Setup to resume next batch of thread references, set nestthread */
+ copy_threadref(&nextthread, &test_threadlist[result_count-1]);
+ /* output_threadid("last-of-batch", &nextthread); */
+ i = 0;
+ while (result_count--) {
+ if (0) /* two display alternatives */
+ output_threadid("truncatedisplay", &test_threadlist[i++]);
+ else
+ get_and_display_threadinfo(&test_threadlist[i++]);
+ }
+
+ }
+ if (!result)
+ output_string("FAIL: threadlist test\n");
+ else output_string("PASS: Threadlist test\n");
+ return result;
} /* threadlist_test */
-static threadref testthread ;
+static threadref testthread;
int test_thread_support(void)
{
- int result = 1 ;
- output_string("TESTING Thread support infrastructure\n") ;
- stub_pack_Tpkt_threadid(test_req) ;
- PKT_TRACE("packing the threadid -> ",test_req) ;
- result &= currthread_test(&testthread) ;
- result &= get_and_display_threadinfo(&testthread) ;
- result &= threadlist_test() ;
- result &= setthread_test(&testthread) ;
- if (result)
- output_string("PASS: UNITTEST Thread support\n") ;
- else
- output_string("FAIL: UNITTEST Thread support\n") ;
- return result ;
+ int result = 1;
+ output_string("TESTING Thread support infrastructure\n");
+ stub_pack_Tpkt_threadid(test_req);
+ PKT_TRACE("packing the threadid -> ", test_req);
+ result &= currthread_test(&testthread);
+ result &= get_and_display_threadinfo(&testthread);
+ result &= threadlist_test();
+ result &= setthread_test(&testthread);
+ if (result)
+ output_string("PASS: UNITTEST Thread support\n");
+ else
+ output_string("FAIL: UNITTEST Thread support\n");
+ return result;
} /* test-thread_support */
#endif /* UNIT_TEST */