Example #1
0
Tree asgntree(int op, Tree l, Tree r) {
    Type aty, ty;

    r = pointer(r);
    ty = assign(l->type, r);
    if (ty)
        r = cast(r, ty);
    else {
        typeerror(ASGN, l, r);
        if (r->type == voidtype)
            r = retype(r, inttype);
        ty = r->type;
    }
    if (l->op != FIELD)
        l = lvalue(l);
    aty = l->type;
    if (isptr(aty))
        aty = unqual(aty)->type;
    if (isconst(aty)
            || (isstruct(aty) && unqual(aty)->u.sym->u.s.cfields)) {
        if (isaddrop(l->op)
                && !l->u.sym->computed && !l->u.sym->generated)
            error("assignment to const identifier `%s'\n",
                  l->u.sym->name);
        else
            error("assignment to const location\n");
    }
    if (l->op == FIELD) {
        long n = 8 * l->u.field->type->size - fieldsize(l->u.field);
        if (n > 0 && isunsigned(l->u.field->type))
            r = bittree(BAND, r,
                        cnsttree(r->type, (unsigned long)fieldmask(l->u.field)));
        else if (n > 0) {
            if (r->op == CNST + I) {
                n = r->u.v.i;
                if (n & (1 << (fieldsize(l->u.field) - 1)))
                    n |= ~0UL << fieldsize(l->u.field);
                r = cnsttree(r->type, n);
            } else
                r = shtree(RSH,
                           shtree(LSH, r, cnsttree(inttype, n)),
                           cnsttree(inttype, n));
        }
    }
    if (isstruct(ty) && isaddrop(l->op) && iscallb(r))
        return tree(RIGHT, ty,
                    tree(CALL + B, ty, r->kids[0]->kids[0], l),
                    idtree(l->u.sym));
    return tree(mkop(op, ty), ty, l, r);
}
Example #2
0
File: tree.c Project: UraKn0x/gbdk
/* printtree1 - recursively print tree p */
static void printtree1(Tree p, int fd, int lev) {
	FILE *f = fd == 1 ? stdout : stderr;
	int i;
	static char blanks[] = "                                                   ";

	if (p == 0 || *printed(i = nodeid(p)))
		return;
	fprint(f, "#%d%S%S", i, blanks, i < 10 ? 2 : i < 100 ? 1 : 0, blanks, lev);
	fprint(f, "%s %t", opname(p->op), p->type);
	*printed(i) = 1;
	for (i = 0; i < NELEMS(p->kids); i++)
		if (p->kids[i])
			fprint(f, " #%d", nodeid(p->kids[i]));
	if (p->op == FIELD && p->u.field)
		fprint(f, " %s %d..%d", p->u.field->name,
			fieldsize(p->u.field) + fieldright(p->u.field), fieldright(p->u.field));
	else if (generic(p->op) == CNST)
		fprint(f, " %s", vtoa(p->type, p->u.v));
	else if (p->u.sym)
		fprint(f, " %s", p->u.sym->name);
	if (p->node)
		fprint(f, " node=%p", p->node);
	fprint(f, "\n");
	for (i = 0; i < NELEMS(p->kids); i++)
		printtree1(p->kids[i], fd, lev + 1);
}
Example #3
0
/*
 * emittype - emit ty's type number, emitting its definition if necessary.
 * Returns the output column number after emission; col is the approximate
 * output column before emission and is used to emit continuation lines for long
 * struct, union, and enum types. Continuations are not emitted for other types,
 * even if the definition is long. lev is the depth of calls to emittype.
 */
static int emittype(Type ty, int lev, int col) {
	int tc = ty->x.typeno;

	if (isconst(ty) || isvolatile(ty)) {
		col = emittype(ty->type, lev, col);
		ty->x.typeno = ty->type->x.typeno;
		ty->x.printed = 1;
		return col;
	}
	if (tc == 0) {
		ty->x.typeno = tc = ++ntypes;
/*              fprint(2,"`%t'=%d\n", ty, tc); */
	}
	print("%d", tc), col += 3;
	if (ty->x.printed)
		return col;
	ty->x.printed = 1;
	switch (ty->op) {
	case VOID:	/* void is defined as itself */
		print("=%d", tc), col += 1+3;
		break;
	case INT:
		if (ty == chartype)	/* plain char is a subrange of itself */
			print("=r%d;%d;%d;", tc, ty->u.sym->u.limits.min.i, ty->u.sym->u.limits.max.i),
				col += 2+3+2*2.408*ty->size+2;
		else			/* other signed ints are subranges of int */
			print("=r1;%D;%D;", ty->u.sym->u.limits.min.i, ty->u.sym->u.limits.max.i),
				col += 4+2*2.408*ty->size+2;
		break;
	case UNSIGNED:
		if (ty == chartype)	/* plain char is a subrange of itself */
			print("=r%d;0;%u;", tc, ty->u.sym->u.limits.max.i),
				col += 2+3+2+2.408*ty->size+1;
		else			/* other signed ints are subranges of int */
			print("=r1;0;%U;", ty->u.sym->u.limits.max.i),
				col += 4+2.408*ty->size+1;
		break;
	case FLOAT:	/* float, double, long double get sizes, not ranges */
		print("=r1;%d;0;", ty->size), col += 4+1+3;
		break;
	case POINTER:
		print("=*"), col += 2;
		col = emittype(ty->type, lev + 1, col);
		break;
	case FUNCTION:
		print("=f"), col += 2;
		col = emittype(ty->type, lev + 1, col);
		break;
	case ARRAY:	/* array includes subscript as an int range */
		if (ty->size && ty->type->size)
			print("=ar1;0;%d;", ty->size/ty->type->size - 1), col += 7+3+1;
		else
			print("=ar1;0;-1;"), col += 10;
		col = emittype(ty->type, lev + 1, col);
		break;
	case STRUCT: case UNION: {
		Field p;
		if (!ty->u.sym->defined) {
			print("=x%c%s:", ty->op == STRUCT ? 's' : 'u', ty->u.sym->name);
			col += 2+1+strlen(ty->u.sym->name)+1;
			break;
		}
		if (lev > 0 && (*ty->u.sym->name < '0' || *ty->u.sym->name > '9')) {
			ty->x.printed = 0;
			break;
		}
		print("=%c%d", ty->op == STRUCT ? 's' : 'u', ty->size), col += 1+1+3;
		for (p = fieldlist(ty); p; p = p->link) {
			if (p->name)
				print("%s:", p->name), col += strlen(p->name)+1;
			else
				print(":"), col += 1;
			col = emittype(p->type, lev + 1, col);
			if (p->lsb)
				print(",%d,%d;", 8*p->offset +
					(IR->little_endian ? fieldright(p) : fieldleft(p)),
					fieldsize(p));
			else
				print(",%d,%d;", 8*p->offset, 8*p->type->size);
			col += 1+3+1+3+1;	/* accounts for ,%d,%d; */
			if (col >= 80 && p->link) {
				print("\\\\\",%d,0,0,0\n.stabs \"", N_LSYM);
				col = 8;
			}
		}
		print(";"), col += 1;
		break;
		}
	case ENUM: {
		Symbol *p;
		if (lev > 0 && (*ty->u.sym->name < '0' || *ty->u.sym->name > '9')) {
			ty->x.printed = 0;
			break;
		}
		print("=e"), col += 2;
		for (p = ty->u.sym->u.idlist; *p; p++) {
			print("%s:%d,", (*p)->name, (*p)->u.value), col += strlen((*p)->name)+3;
			if (col >= 80 && p[1]) {
				print("\\\\\",%d,0,0,0\n.stabs \"", N_LSYM);
				col = 8;
			}
		}
		print(";"), col += 1;
		break;
		}
	default:
		assert(0);
	}
	return col;
}
Example #4
0
    DWORD context
    );

DWORD HDS_IntrThread(
    VOID *pContext
    );


//------------------------------------------------------------------------------
//  Device registry parameters

static const DEVICE_REGISTRY_PARAM s_deviceRegParams[] = {
    {
        L"Priority256", PARAM_DWORD, FALSE,
        offset(HeadsetDevice_t, priority256),
        fieldsize(HeadsetDevice_t, priority256), (VOID*)200
    }, {
        L"HdstDetGpio", PARAM_DWORD, TRUE,
        offset(HeadsetDevice_t, hdstDetGpio),
        fieldsize(HeadsetDevice_t, hdstDetGpio), NULL
    }, {
        L"HdstMuteGpio", PARAM_DWORD, TRUE,
        offset(HeadsetDevice_t, hdstMuteGpio),
        fieldsize(HeadsetDevice_t, hdstMuteGpio), NULL
    }
};


//------------------------------------------------------------------------------
//
//  Function:  HDS_Init
Example #5
0
    DWORD state;
} KEYPAD_REMAP_STATE;

typedef struct {
    BOOL pending;
    DWORD time;
    BOOL blocked;
} KEYPAD_REPEAT_STATE;

//------------------------------------------------------------------------------
//  Device registry parameters

static const DEVICE_REGISTRY_PARAM g_deviceRegParams[] = {
    {
        L"IrqRow0", PARAM_DWORD, TRUE, offset(KPD_DEVICE, irqs[2]),
        fieldsize(KPD_DEVICE, irqs[2]), NULL
    }, {
        L"IrqRow1", PARAM_DWORD, TRUE, offset(KPD_DEVICE, irqs[3]),
        fieldsize(KPD_DEVICE, irqs[3]), NULL
    }, {
        L"IrqRow2", PARAM_DWORD, TRUE, offset(KPD_DEVICE, irqs[4]),
        fieldsize(KPD_DEVICE, irqs[4]), NULL
    }, {
        L"IrqRow3", PARAM_DWORD, TRUE, offset(KPD_DEVICE, irqs[5]),
        fieldsize(KPD_DEVICE, irqs[5]), NULL
    }, {
        L"IrqRow4", PARAM_DWORD, TRUE, offset(KPD_DEVICE, irqs[6]),
        fieldsize(KPD_DEVICE, irqs[6]), NULL
    }, {
        L"Priority256", PARAM_DWORD, FALSE, offset(KPD_DEVICE, priority256),
        fieldsize(KPD_DEVICE, priority256), (VOID*)100
Example #6
0
} Device_t;

typedef struct {
    DWORD               cookie;
    Device_t           *pDevice;
    HANDLE              hI2C;
    DWORD               subAddress;
} Instance_t;

//------------------------------------------------------------------------------
//  Device registry parameters

static const DEVICE_REGISTRY_PARAM s_deviceRegParams[] = {
    {
        L"Index", PARAM_MULTIDWORD, TRUE, offset(Device_t, index),
        fieldsize(Device_t, index), NULL
    }
};


//------------------------------------------------------------------------------
//  Local Functions
BOOL I2C_Deinit(DWORD context);

//------------------------------------------------------------------------------
//
//  Function:  I2C_Init
//
//  Called by device manager to initialize device.
//
DWORD
Example #7
0
//------------------------------------------------------------------------------
//  Device registry parameters

//	LPTSTR 	name;
//  	DWORD  	type;
//   BOOL   	required;
//   DWORD  	offset;
//   DWORD 	size;
//   PVOID  	pDefault;


static const DEVICE_REGISTRY_PARAM s_deviceRegParams[] = {
    {
        L"Priority256", PARAM_DWORD, FALSE, 
        offset(KeypadDevice_t, priority256),
        fieldsize(KeypadDevice_t, priority256), (VOID*)100
    }, {
        L"EnableWake", PARAM_DWORD, FALSE, 
        offset(KeypadDevice_t, enableWake),
        fieldsize(KeypadDevice_t, enableWake), (VOID*)1
    }, {
        L"ClockDivider", PARAM_DWORD, FALSE, 
        offset(KeypadDevice_t, clockDivider),
        fieldsize(KeypadDevice_t, clockDivider), (VOID*)5
    }, {
        L"DebounceCounter", PARAM_DWORD, FALSE, 
        offset(KeypadDevice_t, debounceCount),
        fieldsize(KeypadDevice_t, debounceCount), (VOID*)4
    }, {
        L"SamplePeriod", PARAM_DWORD, FALSE, 
        offset(KeypadDevice_t, samplePeriod),
Example #8
0
//------------------------------------------------------------------------------
//  Local Functions

BOOL
DMA_Deinit(
    DWORD context
    );


//------------------------------------------------------------------------------
//  Device registry parameters

static const DEVICE_REGISTRY_PARAM s_deviceRegParams[] = {
    {
        L"DmaIndex", PARAM_MULTIDWORD, FALSE, offset(Device_t, SdmaIndex),
        fieldsize(Device_t, SdmaIndex), 0
    }, { 
        L"priority256", PARAM_DWORD, TRUE, offset(Device_t, priority),
        fieldsize(Device_t, priority), (VOID*)97
    }
};


//------------------------------------------------------------------------------
//
//  Function:  InitializeDevice
//
//  Initializes the general system dma controller and camera dma controller.
//
BOOL
InitializeDevice(
    void                              *pPrcmRegistryAddress;
    UINT                               optimizedVoltage;
} VddOptimizationInfo_t;

typedef struct
{
    DWORD                           cookie;
} SmartReflexPolicyContext_t;

//------------------------------------------------------------------------------
//  policy registry parameters
//
static const DEVICE_REGISTRY_PARAM g_policyRegParams[] = {
    {
        L"SensingPeriod", PARAM_DWORD, FALSE, offset(SmartReflexPolicyInfo_t, dwSensingPeriod),
        fieldsize(SmartReflexPolicyInfo_t, dwSensingPeriod), (void*)SENSING_PERIOD
    }, {
        L"SensingDelay", PARAM_DWORD, FALSE, offset(SmartReflexPolicyInfo_t, dwSensingDelay),
        fieldsize(SmartReflexPolicyInfo_t, dwSensingDelay), (void*)SENSING_DELAY
    }, {
        L"LprOffOpm", PARAM_DWORD, FALSE, offset(SmartReflexPolicyInfo_t, dwLprOffOpm),
        fieldsize(SmartReflexPolicyInfo_t, dwLprOffOpm), (void*)kOpm2
    }
};

//-----------------------------------------------------------------------------
//  local variables
//
static SmartReflexPolicyInfo_t          s_SmartReflexLoadPolicyInfo;
static IOCTL_RETENTION_VOLTAGES         s_KernIoCtlInfo;
static DWORD                            s_currentOpm;
Example #10
0
    CRITICAL_SECTION    cs;
    HANDLE              hTWL;
    DWORD               priority256;
    DWORD               VBatRef;
    DWORD               GPChAvgEnable;
    DWORD               UsbBciAvgEnable;
} Device_t;


//------------------------------------------------------------------------------
//  Device registry parameters

static const DEVICE_REGISTRY_PARAM s_deviceRegParams[] = {
    {
        L"Priority256", PARAM_DWORD, FALSE, offset(Device_t, priority256),
        fieldsize(Device_t, priority256), (VOID*)110
    }, {
        L"VBAT-Reference", PARAM_DWORD, FALSE, offset(Device_t, VBatRef),
        fieldsize(Device_t, VBatRef), (VOID*)0x8A2
    }, {
        L"GPChannelAveraging", PARAM_DWORD, FALSE, offset(Device_t, GPChAvgEnable),
        fieldsize(Device_t, GPChAvgEnable), (VOID*)0x0
    },{
        L"USB-BCI Averaging", PARAM_DWORD, FALSE, offset(Device_t, UsbBciAvgEnable),
        fieldsize(Device_t, UsbBciAvgEnable), (VOID*)0x0
    }
};

//------------------------------------------------------------------------------
//  ADC scalars
//
Example #11
0

//-----------------------------------------------------------------------------
// global variables
// Note: global variable prevents to have twio instance of the driver loaded at the same time
static NandDevice_t s_Device;
static HANDLE s_hNand = NULL;


//------------------------------------------------------------------------------
//  Device registry parameters
#ifdef DEVICE_MODE
static const DEVICE_REGISTRY_PARAM g_deviceRegParams[] = {
    {
        L"MemBase", PARAM_MULTIDWORD, TRUE, offset(NandDevice_t, memBase),
        fieldsize(NandDevice_t, memBase), NULL
    }, {
        L"MemLen", PARAM_MULTIDWORD, TRUE, offset(NandDevice_t, memLen),
        fieldsize(NandDevice_t, memLen), NULL
    }, {
        L"Timeout", PARAM_DWORD, FALSE, offset(NandDevice_t, timeout),
        fieldsize(NandDevice_t, timeout), (VOID*)5000
    },{
        L"ECCtype", PARAM_DWORD, FALSE, offset(NandDevice_t, ECCtype),
        fieldsize(NandDevice_t, ECCtype), (VOID*)0
    }
};
#endif

//-----------------------------------------------------------------------------
static BOOL