aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJustin T. Gibbs <gibbs@FreeBSD.org>2000-09-22 22:19:55 +0000
committerJustin T. Gibbs <gibbs@FreeBSD.org>2000-09-22 22:19:55 +0000
commit083d01f20daa36f8f86adcfa820767d031c3e2a8 (patch)
treedc7a9b41b420721ed45807a9b65c71df016ee574 /sys
parentc498406d585c79e655dfd478b6603110bff964e5 (diff)
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm.c35
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm.h4
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm_gram.y41
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm_insformat.h2
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm_scan.l4
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm_symbol.c2
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm_symbol.h11
7 files changed, 91 insertions, 8 deletions
diff --git a/sys/dev/aic7xxx/aicasm/aicasm.c b/sys/dev/aic7xxx/aicasm/aicasm.c
index f17218fb3b26..361d7e833010 100644
--- a/sys/dev/aic7xxx/aicasm/aicasm.c
+++ b/sys/dev/aic7xxx/aicasm/aicasm.c
@@ -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()
{
diff --git a/sys/dev/aic7xxx/aicasm/aicasm.h b/sys/dev/aic7xxx/aicasm/aicasm.h
index 6a3400fda64f..a3b30fe0e5b8 100644
--- a/sys/dev/aic7xxx/aicasm/aicasm.h
+++ b/sys/dev/aic7xxx/aicasm/aicasm.h
@@ -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 *);
diff --git a/sys/dev/aic7xxx/aicasm/aicasm_gram.y b/sys/dev/aic7xxx/aicasm/aicasm_gram.y
index 8a602637145b..8ef77111d91a 100644
--- a/sys/dev/aic7xxx/aicasm/aicasm_gram.y
+++ b/sys/dev/aic7xxx/aicasm/aicasm_gram.y
@@ -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 ':'
{
diff --git a/sys/dev/aic7xxx/aicasm/aicasm_insformat.h b/sys/dev/aic7xxx/aicasm/aicasm_insformat.h
index c729e573b4aa..7c6026090a94 100644
--- a/sys/dev/aic7xxx/aicasm/aicasm_insformat.h
+++ b/sys/dev/aic7xxx/aicasm/aicasm_insformat.h
@@ -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$
*/
diff --git a/sys/dev/aic7xxx/aicasm/aicasm_scan.l b/sys/dev/aic7xxx/aicasm/aicasm_scan.l
index a7a72605d8ef..5709d6ff68d6 100644
--- a/sys/dev/aic7xxx/aicasm/aicasm_scan.l
+++ b/sys/dev/aic7xxx/aicasm/aicasm_scan.l
@@ -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; }
diff --git a/sys/dev/aic7xxx/aicasm/aicasm_symbol.c b/sys/dev/aic7xxx/aicasm/aicasm_symbol.c
index 4f5be1eccd65..1a238507ba7a 100644
--- a/sys/dev/aic7xxx/aicasm/aicasm_symbol.c
+++ b/sys/dev/aic7xxx/aicasm/aicasm_symbol.c
@@ -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$
*/
diff --git a/sys/dev/aic7xxx/aicasm/aicasm_symbol.h b/sys/dev/aic7xxx/aicasm/aicasm_symbol.h
index 8a904c9712a4..ec070c898819 100644
--- a/sys/dev/aic7xxx/aicasm/aicasm_symbol.h
+++ b/sys/dev/aic7xxx/aicasm/aicasm_symbol.h
@@ -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);