Add Perforce RCSIDs for easy revision correlation to my local tree.
Add support for constructing a table of critical section regions in the firmware image. The kernel driver will soon have support for single stepping the sequencer outside of a critical region prior to starting exception handling.
This commit is contained in:
parent
872c96a9d4
commit
d98dfab164
@ -28,7 +28,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: //depot/src/aic7xxx/aicasm/aicasm.c#4 $
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
@ -36,6 +36,7 @@
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -76,6 +77,7 @@ char *listfilename;
|
||||
FILE *listfile;
|
||||
|
||||
static STAILQ_HEAD(,instruction) seq_program;
|
||||
struct cs_tailq cs_tailq;
|
||||
struct scope_list scope_stack;
|
||||
symlist_t patch_functions;
|
||||
|
||||
@ -101,6 +103,7 @@ main(int argc, char *argv[])
|
||||
STAILQ_INIT(&patches);
|
||||
SLIST_INIT(&search_path);
|
||||
STAILQ_INIT(&seq_program);
|
||||
TAILQ_INIT(&cs_tailq);
|
||||
SLIST_INIT(&scope_stack);
|
||||
|
||||
/* Set Sentinal scope node */
|
||||
@ -302,6 +305,7 @@ output_code()
|
||||
{
|
||||
struct instruction *cur_instr;
|
||||
patch_t *cur_patch;
|
||||
critical_section_t *cs;
|
||||
symbol_node_t *cur_node;
|
||||
int instrcount;
|
||||
|
||||
@ -370,6 +374,21 @@ struct patch {
|
||||
|
||||
fprintf(ofile, "\n};\n");
|
||||
|
||||
fprintf(ofile,
|
||||
"struct cs {
|
||||
u_int16_t begin;
|
||||
u_int16_t end;
|
||||
} critical_sections[] = {\n");
|
||||
|
||||
for(cs = TAILQ_FIRST(&cs_tailq);
|
||||
cs != NULL;
|
||||
cs = TAILQ_NEXT(cs, links)) {
|
||||
fprintf(ofile, "\t{ %d, %d },\n",
|
||||
cs->begin_addr, cs->end_addr);
|
||||
}
|
||||
|
||||
fprintf(ofile, "\n};\n");
|
||||
|
||||
fprintf(stderr, "%s: %d instructions used\n", appname, instrcount);
|
||||
}
|
||||
|
||||
@ -650,6 +669,20 @@ seq_alloc()
|
||||
return new_instr;
|
||||
}
|
||||
|
||||
critical_section_t *
|
||||
cs_alloc()
|
||||
{
|
||||
critical_section_t *new_cs;
|
||||
|
||||
new_cs= (critical_section_t *)malloc(sizeof(critical_section_t));
|
||||
if (new_cs == NULL)
|
||||
stop("Unable to malloc critical_section object", EX_SOFTWARE);
|
||||
memset(new_cs, 0, sizeof(*new_cs));
|
||||
|
||||
TAILQ_INSERT_TAIL(&cs_tailq, new_cs, links);
|
||||
return new_cs;
|
||||
}
|
||||
|
||||
scope_t *
|
||||
scope_alloc()
|
||||
{
|
||||
|
@ -28,7 +28,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: //depot/src/aic7xxx/aicasm/aicasm.h#3 $
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
@ -62,6 +62,7 @@ typedef enum {
|
||||
SLIST_HEAD(path_list, path_entry);
|
||||
|
||||
extern struct path_list search_path;
|
||||
extern struct cs_tailq cs_tailq;
|
||||
extern struct scope_list scope_stack;
|
||||
extern struct symlist patch_functions;
|
||||
extern int includes_search_curdir; /* False if we've seen -I- */
|
||||
@ -72,5 +73,6 @@ extern char *yyfilename;
|
||||
void stop(const char *errstring, int err_code);
|
||||
void include_file(char *file_name, include_type type);
|
||||
struct instruction *seq_alloc(void);
|
||||
struct critical_section *cs_alloc(void);
|
||||
struct scope *scope_alloc(void);
|
||||
void process_scope(struct scope *);
|
||||
|
@ -29,11 +29,12 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: //depot/src/aic7xxx/aicasm/aicasm_gram.y#4 $
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -62,6 +63,7 @@ static symbol_ref_t sindex;
|
||||
static int instruction_ptr;
|
||||
static int sram_or_scb_offset;
|
||||
static int download_constant_count;
|
||||
static int in_critical_section;
|
||||
|
||||
static void process_bitmask(int mask_type, symbol_t *sym, int mask);
|
||||
static void initialize_symbol(symbol_t *symbol);
|
||||
@ -112,6 +114,10 @@ static int is_download_const(expression_t *immed);
|
||||
|
||||
%token <value> T_MODE
|
||||
|
||||
%token T_BEGIN_CS
|
||||
|
||||
%token T_END_CS
|
||||
|
||||
%token T_BIT
|
||||
|
||||
%token T_MASK
|
||||
@ -184,6 +190,10 @@ program:
|
||||
| program scb
|
||||
| label
|
||||
| program label
|
||||
| critical_section_start
|
||||
| program critical_section_start
|
||||
| critical_section_end
|
||||
| program critical_section_end
|
||||
| conditional
|
||||
| program conditional
|
||||
| code
|
||||
@ -644,6 +654,35 @@ ret:
|
||||
{ $$ = 1; }
|
||||
;
|
||||
|
||||
critical_section_start:
|
||||
T_BEGIN_CS
|
||||
{
|
||||
critical_section_t *cs;
|
||||
|
||||
if (in_critical_section != FALSE) {
|
||||
stop("Critical Section within Critical Section",
|
||||
EX_DATAERR);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
cs = cs_alloc();
|
||||
cs->begin_addr = instruction_ptr;
|
||||
in_critical_section = TRUE;
|
||||
}
|
||||
|
||||
critical_section_end:
|
||||
T_END_CS
|
||||
{
|
||||
critical_section_t *cs;
|
||||
|
||||
if (in_critical_section == FALSE) {
|
||||
stop("Unballanced 'end_cs'", EX_DATAERR);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
cs = TAILQ_LAST(&cs_tailq, cs_tailq);
|
||||
cs->end_addr = instruction_ptr;
|
||||
in_critical_section = FALSE;
|
||||
}
|
||||
|
||||
label:
|
||||
T_SYMBOL ':'
|
||||
{
|
||||
|
@ -29,7 +29,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: //depot/src/aic7xxx/aicasm/aicasm_insformat.h#3 $
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
@ -29,7 +29,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: //depot/src/aic7xxx/aicasm/aicasm_scan.l#3 $
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
@ -126,6 +126,8 @@ RW|RO|WO {
|
||||
yylval.value = WO;
|
||||
return T_MODE;
|
||||
}
|
||||
BEGIN_CRITICAL { return T_BEGIN_CS; }
|
||||
END_CRITICAL { return T_END_CS; }
|
||||
bit { return T_BIT; }
|
||||
mask { return T_MASK; }
|
||||
alias { return T_ALIAS; }
|
||||
|
@ -28,7 +28,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: //depot/src/aic7xxx/aicasm/aicasm_symbol.c#3 $
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
@ -28,7 +28,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: //depot/src/aic7xxx/aicasm/aicasm_symbol.h#3 $
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
@ -117,7 +117,13 @@ typedef struct symbol_ref {
|
||||
typedef struct symbol_node {
|
||||
SLIST_ENTRY(symbol_node) links;
|
||||
symbol_t *symbol;
|
||||
}symbol_node_t;
|
||||
} symbol_node_t;
|
||||
|
||||
typedef struct critical_section {
|
||||
TAILQ_ENTRY(critical_section) links;
|
||||
int begin_addr;
|
||||
int end_addr;
|
||||
} critical_section_t;
|
||||
|
||||
typedef enum {
|
||||
SCOPE_ROOT,
|
||||
@ -143,6 +149,7 @@ typedef struct scope {
|
||||
int func_num;
|
||||
} scope_t;
|
||||
|
||||
TAILQ_HEAD(cs_tailq, critical_section);
|
||||
SLIST_HEAD(scope_list, scope);
|
||||
TAILQ_HEAD(scope_tailq, scope);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user