Exemple #1
0
static uae_u32 REGPARAM2 dev_abortio (TrapContext *context)
{
	uae_u32 request = m68k_areg (regs, 1);
	struct devstruct *dev = getdevstruct (get_long (request + 24));

	if (!dev) {
		put_byte (request + 31, 32);
		return get_byte (request + 31);
	}
	abort_async (dev, request);
	return 0;
}
Exemple #2
0
static PyObject *
l_set(void *ptr, PyObject *value, Py_ssize_t size)
{
	long val;
	long x;
	if (get_long(value, &val) < 0)
		return NULL;
	memcpy(&x, ptr, sizeof(x));
	x = SET(x, val, size);
	memcpy(ptr, &x, sizeof(x));
	_RET(value);
}
Exemple #3
0
static uae_u32 packetfilter (TrapContext *ctx, uaecptr hook, uaecptr ios2, uaecptr data)
{
	uae_u32 a2, v;

	a2 = m68k_areg (regs, 2);
	m68k_areg (regs, 0) = hook;
	m68k_areg (regs, 2) = ios2;
	m68k_areg (regs, 1) = data;
	v = CallFunc (ctx, get_long (hook + 8));
	m68k_areg (regs, 2) = a2;
	return v;
}
Exemple #4
0
void
make_RTStruct(ea_t adr, size_t namelen)
{
  /* form struct */
  do_unknown_range(adr, RT_len, true);
  doDwrd(adr,4);
  doDwrd(adr+4,4);
  doDwrd(adr+8,4);
  doDwrd(adr+12,4);
  doDwrd(adr+16,4);
//  doDwrd(adr+20,4);
  /* add dref to class name */
  ea_t ptr = get_long(adr);
  make_ascii_string(ptr, namelen, ASCSTR_C);
  add_dref(adr, ptr, dr_O);
  op_offset(adr, OPND_MASK, REF_OFF32, ptr);
  rp_set_comment(adr+4, "Size", false);
  /* add cref to constructor */
  ptr = get_long(adr+12);
  if ( ptr )
  {
    add_cref(adr+12, ptr, fl_CN);
    op_offset(adr+12, OPND_MASK, REF_OFF32, ptr);
  }
  /* add dref to base class struct */
  ptr = get_long(adr+16);
  if ( ptr )
  {
    add_dref(adr+16,ptr,dr_O);
    op_offset(adr+16, OPND_MASK, REF_OFF32, ptr);
  }
  /* add dref to next class */
/*  ptr = get_long(adr+20);
  if ( ptr )
  {
    add_dref(adr+20,ptr,dr_O);
    op_offset(adr+20, OPND_MASK, REF_OFF32, ptr);
  }
*/
}
Exemple #5
0
void make_vtbl_entry(ea_t ea)
{
  ea_t ref;
  do_unknown_range(ea, sizeof(ea), false);
#ifdef __EA64__
  doQwrd(ea, sizeof(ea));
  ref = get_long(ea);
#else
  doDwrd(ea, sizeof(ea));
  ref = get_qword(ea);
#endif /* __EA64__ */
  do_dref(ea, ref);
}
Exemple #6
0
gboolean
gsq_source_process (GsqQuerier *querier, guint16 qport,
		const gchar *data, gssize size)
{
	Private *priv = gsq_querier_get_pdata (querier);
	if (!priv) {
		priv = g_slice_new0 (Private);
		priv->packets = g_array_new (FALSE, TRUE, sizeof (Packet));
		gsq_querier_set_pdata (querier, priv);
	}
	
	/* check if this packet belongs to the querier */
	if (qport != gsq_querier_get_qport (querier)) {
		guint16 port = gsq_querier_get_gport (querier);
		if (!(port == qport || (port == 0 && qport == 27015)))
			return FALSE;
	}
	
	gchar *p = (gchar *) data;
	gint format = get_long (&p);
	
	if (format == -1) {
		if (!source_process2 (querier, p, size))
			return FALSE;
	} else if (format == -2) {
		gint reqid, maxpackets, numpacket;
		gboolean compressed;
		guint16 length;
		
		reqid = get_long (&p);
		compressed = reqid >> 31;
		
		if (*((gint32 *) (p + 1)) == -1) {
			/* GoldSource way */
			guint8 c = gsq_get_uint8 (&p);
			maxpackets = c & 0x0F;
			numpacket = c >> 4;
			length = size - (p - data);
		} else {
Exemple #7
0
void main(void) {
   long data;
   
   report_line_number = 0;
   filter_clear();
   
   while( TRUE ) {
      fprintf(PC, "  Enter data point: ");
      data = get_long();
      data = filter_data(data);      
      report_data_line(data);
   }
}
Exemple #8
0
int slave_read(){
    int i;
    verbose(L_SLVE,"%s:",slv_name);
    while((i=get_long(in))>=0){
        switch(i){
            case    ACT_NOP:break;
            case     ACT_ON:w_init();break;
            case    ACT_OFF:w_close();break;
            case  ACT_SLEEP:w_delayMicroseconds(get_long(in));break;
            case  ACT_WRITE:w_gpio_write(get_long(in),get_long(in));break;
            case   ACT_FSEL:w_gpio_fsel(get_long(in),get_long(in));break;
            case ACT_SETPUD:w_gpio_set_pud(get_long(in),get_long(in));break;
        }
    }
}
Exemple #9
0
int load_main(const char *outfile_name)
{
	FILE *o;
	int i, c, len;
	if ((len = get_short()) < 0) exit(1);
	for (i=0; i<len; i++) {
		if ((c = getchar()) == EOF) exit(1);
	}
	find_key(0x00);
	find_key(0x01);
	find_key(0x61);
	print_string("design: ");
	find_key(0x62);
	print_string("part:   ");
	find_key(0x63);
	print_string("date:   ");
	find_key(0x64);
	print_string("time:   ");
	find_key(0x65);
	len = get_long();
	printf("length: %d\n", len);
	if (outfile_name == NULL) {
		for (i=0; i<len/4; i++) {
			printf(" 0x%.8x\n", get_long());
		}
	} else if ((o=fopen(outfile_name,"w"))!=NULL) {
		for (i=0; i<len; i++) {
			fputc(getchar(),o);
		}
		if (fclose(o)) {
			perror("fclose");
			unlink(outfile_name);
		} else {
			printf("wrote:  %s\n",outfile_name);
		}
	}
	return 0;
}
Exemple #10
0
/* Ugly hack for >2M chip RAM in single pool
 * We can't add it any later or early boot menu
 * stops working because it sets kicktag at the end
 * of chip ram...
 */
static void addextrachip (uae_u32 sysbase)
{
	if (currprefs.chipmem_size <= 0x00200000)
		return;
	if (sysbase & 0x80000001)
		return;
	if (!valid_address (sysbase, 1000))
		return;
	uae_u32 ml = get_long (sysbase + 322);
	if (!valid_address (ml, 32))
		return;
	uae_u32 next;
	while ((next = get_long (ml))) {
		if (!valid_address (ml, 32))
			return;
		uae_u32 upper = get_long (ml + 24);
		uae_u32 lower = get_long (ml + 20);
		if (lower & ~0xffff) {
			ml = next;
			continue;
		}
		uae_u16 attr = get_word (ml + 14);
		if ((attr & 0x8002) != 2) {
			ml = next;
			continue;
		}
		if (upper >= currprefs.chipmem_size)
			return;
		uae_u32 added = currprefs.chipmem_size - upper;
		uae_u32 first = get_long (ml + 16);
		put_long (ml + 24, currprefs.chipmem_size); // mh_Upper
		put_long (ml + 28, get_long (ml + 28) + added); // mh_Free
		uae_u32 next;
		while (first) {
			next = first;
			first = get_long (next);
		}
		uae_u32 bytes = get_long (next + 4);
		if (next + bytes == 0x00200000) {
			put_long (next + 4, currprefs.chipmem_size - next);
		} else {
			put_long (0x00200000 + 0, 0);
			put_long (0x00200000 + 4, added);
			put_long (next, 0x00200000);
		}
		return;
	}
}
static int
get_ulong(PyObject *v, unsigned long *p)
{
	if (PyLong_Check(v)) {
		unsigned long x = PyLong_AsUnsignedLong(v);
		if (x == (unsigned long)(-1) && PyErr_Occurred())
			return -1;
		*p = x;
		return 0;
	}
	else {
		return get_long(v, (long *)p);
	}
}
Exemple #12
0
/* Horror function - tries to recognize CRuntimeClass */
size_t
check_for_RTStruct(ea_t adr)
{
  if ( !is_defined_area(adr, RT_len) )
   return 0;
  size_t namesize = rp_is_class_name(get_long(adr)); /* check for name */
  ulong schema = get_long(adr + 8);
  if ( schema != 0xffff && schema)	/* all schemas must be 0xffff or 0
   See afx.h for IMPLEMENT_SERIAL, IMPLEMENT_DYNAMIC & IMPLEMENT_DYNCREATE macros */
   return 0;
  if ( is_contain_ptr(adr + 16) )
   return namesize; /* Yes - possible we really have CRuntimeClass :-) */
  if ( 0 != get_long(adr + 16) )
   return 0; /* bad addr ? */
#if 0 
  /* This code is very strange - CRunTimeClass has size only 20 bytes... */
  if ( is_contain_ptr(adr + 20) )
   return namesize;
  if (0 != get_long(adr + 20) )
   return 0;
#endif
  return namesize;
}
static int
lp_int(char *p, PyObject *v, const formatdef *f)
{
	long x;
	int i;
	if (get_long(v, &x) < 0)
		return -1;
	i = f->size;
	do {
		*p++ = (char)x;
		x >>= 8;
	} while (--i > 0);
	return 0;
}
Exemple #14
0
/* try to find this class or one of parent class in our pdb pool */
pdb_class *try_to_find_this_or_parent(ea_t ea, char **name, bool *free_name, bool *named)
{
  // 1st - lets check if have some fuzzy name as first entry to VTBL
  if ( !p_pool || !name )
   return NULL;
  *named = false;
  pdb_class *res = try_find_by_name(ea, name, free_name);
  if ( res )
  {
    set_vtbl_name(*name, ea);
    return res;
  }
  return try_to_find_from_rt(get_long(ea), name, free_name);
}
Exemple #15
0
static PyObject *
l_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
    long val;
    long field;
    if (get_long(value, &val) < 0)
        return NULL;
    memcpy(&field, ptr, sizeof(field));
    field = SWAP_LONG(field);
    field = (long)SET(field, val, size);
    field = SWAP_LONG(field);
    memcpy(ptr, &field, sizeof(field));
    _RET(value);
}
Exemple #16
0
static PyObject *
i_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
    long val;
    int field;
    if (get_long(value, &val) < 0)
        return NULL;
    memcpy(&field, ptr, sizeof(field));
    field = SWAP_INT(field);
    field = SET(field, (int)val, size);
    field = SWAP_INT(field);
    memcpy(ptr, &field, sizeof(field));
    _RET(value);
}
static int
np_byte(char *p, PyObject *v, const formatdef *f)
{
	long x;
	if (get_long(v, &x) < 0)
		return -1;
	if (x < -128 || x > 127){
		PyErr_SetString(StructError,
				"byte format requires -128<=number<=127");
		return -1;
	}
	*p = (char)x;
	return 0;
}
Exemple #18
0
static PyObject *
h_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
    long val;
    short field;
    if (get_long(value, &val) < 0)
        return NULL;
    memcpy(&field, ptr, sizeof(field));
    field = SWAP_2(field);
    field = SET(short, field, val, size);
    field = SWAP_2(field);
    memcpy(ptr, &field, sizeof(field));
    _RET(value);
}
static int
np_ubyte(char *p, PyObject *v, const formatdef *f)
{
	long x;
	if (get_long(v, &x) < 0)
		return -1;
	if (x < 0 || x > 255){
		PyErr_SetString(StructError,
				"ubyte format requires 0<=number<=255");
		return -1;
	}
	*p = (char)x;
	return 0;
}
Exemple #20
0
static int
np_int(char *p, PyObject *v, const formatdef *f)
{
	long x;
	int y;
	if (get_long(v, &x) < 0)
		return -1;
#if (SIZEOF_LONG > SIZEOF_INT)
	if ((x < ((long)INT_MIN)) || (x > ((long)INT_MAX)))
		RANGE_ERROR(x, f, 0, -1);
#endif
	y = (int)x;
	memcpy(p, (char *)&y, sizeof y);
	return 0;
}
Exemple #21
0
static void uae4all_reset(void)
{
    int i;
#if !defined(USE_CYCLONE_CORE) && !defined(USE_FAME_CORE_ARM2)
    m68k_set_context(&micontexto);
#endif
    m68k_reset();
    for(i=1; i<8; i++)
#if defined(DEBUG_INTERRUPTS)
        M68KCONTEXT.interrupts[i]=0xFF;
#else
        M68KCONTEXT.interrupts[i]=0x18+i;
#endif
    M68KCONTEXT.interrupts[0]=0;
    m68k_irq_update(0);
    mispcflags=0;
    _68k_areg(7) = get_long (0x00f80000);
    _68k_setpc(get_long (0x00f80004));
    //_68k_sreg = 0x2700; // already done by m68k_reset()
    mispcflags=0;
#ifdef DEBUG_FRAMERATE
    uae4all_update_time();
#endif
}
Exemple #22
0
//----------------------------------------------------------------------
ea_t find_first_insn_in_packet(ea_t ea)
{
  if ( !is_spec_ea(ea) )
  {
    while ( (ea & 0x1F) != 0 )
    {
      ea_t ea2 = prev_not_tail(ea);
      if ( ea2 == BADADDR
        || !isCode(get_flags_novalue(ea2))
        || (get_long(ea2) & BIT0) == 0 ) break;
      ea = ea2;
    }
  }
  return ea;
}
Exemple #23
0
static uint32_t REGPARAM2 dev_close (TrapContext *context)
{
	uint32_t request = m68k_areg (regs, 1);
	struct devstruct *dev;

	dev = getdevstruct (get_long (request + 24));
	if (!dev)
		return 0;
	if (log_uaeserial)
		write_log (_T("%s:%d close, req=%x\n"), getdevname(), dev->unit, request);
	dev_close_3 (dev);
	put_long (request + 24, 0);
	put_word (m68k_areg (regs, 6) + 32, get_word (m68k_areg (regs, 6) + 32) - 1);
	return 0;
}
Exemple #24
0
bool UAECALL uae_ppc_io_mem_read(uint32_t addr, uint32_t *data, int size)
{
	uint32_t v;
	bool locked = false;

	while (ppc_thread_running && ppc_cpu_lock_state < 0 && ppc_state);

	if (addr >= 0xdff000 && addr < 0xe00000) {
		int reg = addr & 0x1fe;
		// shortcuts for common registers
		switch (reg) {
			case 0x01c: // INTENAR
			*data = intena;
			return true;
			case 0x01e: // INTREQR
			*data = intreq;
			return true;
		}
	}

	locked = spinlock_pre(addr);
	switch (size)
	{
	case 4:
		v = get_long(addr);
		break;
	case 2:
		v = get_word(addr);
		break;
	case 1:
		v = get_byte(addr);
		break;
	}
	*data = v;
	spinlock_post(locked);

#if PPC_ACCESS_LOG > 0 && PPC_ACCESS_LOG < 2
	if (!valid_address(addr, size)) {
		if (addr >= PPC_DEBUG_ADDR_FROM && addr < PPC_DEBUG_ADDR_TO && addr != 0xdff006)
			write_log(_T("PPC io read %08x=%08x %d\n"), addr, v, size);
	}
#endif
#if PPC_ACCESS_LOG >= 2
	if (addr < 0xb00000 || addr > 0xc00000)
		write_log(_T("PPC read %08x=%08x %d\n"), addr, v, size);
#endif
	return true;
}
Exemple #25
0
/***********************************************************************
 *
 * Function:    unpack_Address
 *
 * Summary:     Fill in the address structure based on the raw record 
 *		data
 *
 * Parameters:  Address_t*, pi_buffer_t *buf
 *
 * Returns:     -1 on error, 0 on success
 *
 ***********************************************************************/
int
unpack_Address(Address_t *addr, const pi_buffer_t *buf, addressType type)
{
	unsigned long	contents,
			v;
	size_t		ofs;

	if (type != address_v1)
		/* Don't support anything else yet */
		return -1;

	if (buf == NULL || buf->data == NULL || buf->used < 9)
		return -1;

	/* get_byte(buffer); gapfill */
	addr->showPhone     = hi(get_byte(buf->data + 1));
	addr->phoneLabel[4] = lo(get_byte(buf->data + 1));
	addr->phoneLabel[3] = hi(get_byte(buf->data + 2));
	addr->phoneLabel[2] = lo(get_byte(buf->data + 2));
	addr->phoneLabel[1] = hi(get_byte(buf->data + 3));
	addr->phoneLabel[0] = lo(get_byte(buf->data + 3));

	contents = get_long(buf->data + 4);

	/* get_byte(buf->data+8) offset */

	ofs = 9;

	/* if(flag & 0x1) { 
	   addr->lastname = strdup((buf->data + ofs);
	   ofs += strlen((buf->data + ofs)) + 1;
	   } else {
	   addr->lastname = 0;
	   } */

	for (v = 0; v < 19; v++) {
		if (contents & (1 << v)) {
			if ((buf->used - ofs) < 1)
				return 0;
			addr->entry[v] = strdup((char *) (buf->data + ofs));
                  	ofs += strlen(addr->entry[v]) + 1;
		} else {
			addr->entry[v] = 0;
		}
	}

	return 0;
}
Exemple #26
0
/* ARGSUSED */
static double guess_numeric_type(Acr_VR_Entry *vr_entry, 
                                 Acr_byte_order byte_order,
                                 char *data, long data_length)
{
   switch (data_length) {
   case ACR_SIZEOF_SHORT:
      return get_short(vr_entry, byte_order, data, data_length);
      break;
   case ACR_SIZEOF_LONG:
      return get_long(vr_entry, byte_order, data, data_length);
      break;
   default:
      return string_to_numeric(vr_entry, byte_order, data, data_length);
   }

}
static void handle_enumeration_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data)
    {
    DNSServiceFlags flags;
    uint32_t interfaceIndex;
    DNSServiceErrorType err;
    char domain[kDNSServiceMaxDomainName];
    int str_error = 0;
	(void)hdr;//Unused

    flags = get_flags(&data);
    interfaceIndex = get_long(&data);
    err = get_error_code(&data);
    if (get_string(&data, domain, kDNSServiceMaxDomainName) < 0) str_error = 1;
	if (!err && str_error) err = kDNSServiceErr_Unknown;
    ((DNSServiceDomainEnumReply)sdr->app_callback)(sdr, flags, interfaceIndex, err, domain, sdr->app_context);
    }
static int
np_ushort(char *p, PyObject *v, const formatdef *f)
{
	long x;
	unsigned short y;
	if (get_long(v, &x) < 0)
		return -1;
	if (x < 0 || x > USHRT_MAX){
		PyErr_SetString(StructError,
				"short format requires 0<=number<=" STRINGIFY(USHRT_MAX));
		return -1;
	}
	y = (unsigned short)x;
	memcpy(p, (char *)&y, sizeof y);
	return 0;
}
Exemple #29
0
static void
get_player_list (GsqQuerier *querier, gchar *p)
{
	gint8 i, count = gsq_get_uint8 (&p);
	gchar time[16];
	
	for (i = 0; i < count; i++) {
		gsq_get_uint8 (&p);
		gchar *nickname = gsq_get_cstring (&p);			// Nickname
		gint kills = get_long (&p);						// Kills
		format_time (time, 16, get_float (&p));			// Time
		gsq_querier_add_player (querier, nickname, kills, time);
	}
	
	gsq_querier_emit_player_update (querier);
}
Exemple #30
0
void
output_rt_tree(FILE *fp, struct RP_class *root, int margin)
{
  if ( NULL == root )
   return;
  rt_put_margin(margin,fp);
  get_many_bytes(get_long(root->CRuntime), misc_buffer1, root->namelen);
  misc_buffer1[root->namelen] = 0x0;
  if ( root->vtbl )
   fprintf(fp, "%s: adr 0x%X, vtbl 0x%X\n", misc_buffer1, root->CRuntime, root->vtbl);
  else
   fprintf(fp, "%s: adr 0x%X\n", misc_buffer1, root->CRuntime );
  int i;
  margin += 4;
  for ( i = 0; i < root->total; i++ )
   output_rt_tree(fp, root->children[i], margin);
}