Ejemplo n.º 1
0
paddr_t
acpi_find_table(unsigned table_name, unsigned *lenp) {
	static unsigned		num_tbls = -1;
	static paddr_t		*tbl_array;
	paddr_t				tbl_paddr;
	acpi_rsdp			*root;
	acpi_generic		*tbl;
	unsigned			i;
	unsigned			sig;

	if(num_tbls == 0) return NULL_PADDR;
	if(tbl_array == NULL) {
		root = board_find_acpi_rsdp();
		if(root == NULL) {
			num_tbls = 0;
			return NULL_PADDR;
		}
		if(root->v1.Revision == ACPI_RSDP_REVISION_1_0) {
			tbl_paddr = root->v1.RsdtAddress;
			startup_memory_unmap(root);
			tbl = startup_memory_map(0x4096, tbl_paddr, PROT_READ);
			num_tbls = (tbl->hdr.Length - offsetof(acpi_rsdt, Entry)) / sizeof(tbl->rsdt.Entry[0]);
			tbl_array = ws_alloc(num_tbls * sizeof(*tbl_array));
			for(i = 0; i < num_tbls; ++i) {
				tbl_array[i] = tbl->rsdt.Entry[i];
			}
		} else {
			tbl_paddr = root->XsdtAddress;
			startup_memory_unmap(root);
			tbl = startup_memory_map(0x4096, tbl_paddr, PROT_READ);
			num_tbls = (tbl->hdr.Length - offsetof(acpi_xsdt, Entry)) / sizeof(tbl->xsdt.Entry[0]);
			tbl_array = ws_alloc(num_tbls * sizeof(*tbl_array));
			for(i = 0; i < num_tbls; ++i) {
				tbl_array[i] = tbl->xsdt.Entry[i];
			}
		}
		startup_memory_unmap(tbl);
	}
	for(i = 0; i < num_tbls; ++i) {
		tbl_paddr = tbl_array[i];
		tbl = startup_memory_map(sizeof(*tbl), tbl_paddr, PROT_READ);
		sig = tbl->hdr.Signature;
		if(lenp != NULL) *lenp = tbl->hdr.Length;
		startup_memory_unmap(tbl);
		if(sig == table_name) return tbl_paddr;
	}
	return NULL_PADDR;
}
Ejemplo n.º 2
0
/*------------------------------------------------------------------------------
	Preconditions:
	Postconditions:
 *----------------------------------------------------------------------------*/
void atca_cmd_get_picmg_properties( void )
/*----------------------------------------------------------------------------*/
{
	IPMI_WS		*ws;
	GET_PICMG_PROPERTIES_CMD_REQ	cmd_req;
	
	printf( "app_cmd_get_device_id:\n" );

	ws = ws_alloc();
	
	if( !ws ) {
		printf( "app_cmd_get_device_id: ws allocation failed\n" );
		return;
	}

	cmd_req.command = ATCA_CMD_GET_PICMG_PROPERTIES;
	cmd_req.picmg_id = 0;
	
	fill_pkt_out( ws, ( IPMI_CMD_REQ * )&cmd_req, 1, NETFN_PICMG_REQ );
	/* the completion function will be called by the transport layer
	 * completion routine after the xfer has completed. It is up to the 
	 * test framework to keep track of request/response pairs using the 
	 * sequence numbers */
	ws->ipmi_completion_function = 0; // none at this moment 

	/* change ws state, work list processing will do the rest */
	ws_set_state( ws, WS_ACTIVE_MASTER_WRITE );
}
Ejemplo n.º 3
0
void app_cmd_reset_watchdog_timer( void )
/*----------------------------------------------------------------------------*/
{
	IPMI_WS		*ws;
	IPMI_CMD_REQ	cmd_req;
	
	ws = ws_alloc();
	
	if( !ws ) {
		printf( "app_cmd_get_device_id: ws allocation failed\n" );
		return;
	}

	cmd_req.command = IPMI_CMD_RESET_WATCHDOG_TIMER;

	fill_pkt_out( ws, &cmd_req, 0, NETFN_APP_REQ );
	ws->ipmi_completion_function = 0; // none at this moment 

	/* change ws state, work list processing will do the rest */
	ws_set_state( ws, WS_ACTIVE_MASTER_WRITE );
}
Ejemplo n.º 4
0
void
_main(void) {
	
	shdr = (struct startup_header *)boot_args.shdr_addr;

	board_init();

	setup_cmdline();

	cpu_startup();

	#define INIT_SYSPAGE_SIZE 0x600
	init_syspage_memory(ws_alloc(INIT_SYSPAGE_SIZE), INIT_SYSPAGE_SIZE);

	if(shdr->imagefs_paddr != 0) {
		avoid_ram(shdr->imagefs_paddr, shdr->stored_size);
	}

	main(_argc, _argv, envv);

	//
	// Tell the mini-drivers that the next time they're called, they're
	// going to be in the kernel. Also flip the handler & data pointers
	// to the proper values for that environment.
	//
	mdriver_hook();

	//
	// Copy the local version of the system page we've built to the real
	// system page location we allocated in init_system_private().
	//
	write_syspage_memory();

	//
	// Tell the AP's that that the syspage is now present.
	//
	smp_hook_rtn();

	startnext();
}
Ejemplo n.º 5
0
static struct co_info *
get_co_info(void) {
	struct co_info	*next;
	unsigned		i;

	#define	INFO_BLOCK	20

	if(co_free_list == NULL) {
		next = ws_alloc(sizeof(*next)*INFO_BLOCK);
		if(next == NULL) {
			crash("No memory for callout information structure.\n");
		}
		for(i = 0; i < INFO_BLOCK; ++i) {
			next->next = co_free_list;
			co_free_list = next;
			++next;
		}
	}
	next = co_free_list;
	co_free_list = next->next;
	return(next);
}
Ejemplo n.º 6
0
Archivo: url.c Proyecto: AndreRH/wine
static WCHAR *url_decode( WCHAR *str, ULONG len, WS_HEAP *heap, ULONG *ret_len )
{
    WCHAR *p = str, *q, *ret;
    BOOL decode = FALSE, convert = FALSE;
    ULONG i, len_utf8, len_left;
    unsigned char *utf8, *r;

    *ret_len = len;
    for (i = 0; i < len; i++, p++)
    {
        if ((len - i) < 3) break;
        if (p[0] == '%' && isxdigitW( p[1] ) && isxdigitW( p[2] ))
        {
            decode = TRUE;
            if (url_decode_byte( p[1], p[2] ) > 159)
            {
                convert = TRUE;
                break;
            }
            *ret_len -= 2;
        }
    }
    if (!decode) return str;
    if (!convert)
    {
        if (!(q = ret = ws_alloc( heap, *ret_len * sizeof(WCHAR) ))) return NULL;
        p = str;
        while (len)
        {
            if (len >= 3 && p[0] == '%' && isxdigitW( p[1] ) && isxdigitW( p[2] ))
            {
                *q++ = url_decode_byte( p[1], p[2] );
                p += 3;
                len -= 3;
            }
            else
            {
                *q++ = *p++;
                len -= 1;
            }
        }
        return ret;
    }

    if (!(r = utf8 = strdup_utf8( str, len, &len_utf8 ))) return NULL;
    len_left = len_utf8;
    while (len_left)
    {
        if (len_left >= 3 && r[0] == '%' && isxdigit( r[1] ) && isxdigit( r[2] ))
        {
            r[0] = url_decode_byte( r[1], r[2] );
            len_left -= 3;
            memmove( r + 1, r + 3, len_left );
            len_utf8 -= 2;
        }
        else len_left -= 1;
        r++;
    }

    if (!(*ret_len = MultiByteToWideChar( CP_UTF8, MB_ERR_INVALID_CHARS, (char *)utf8,
                                          len_utf8, NULL, 0 )))
    {
        WARN( "invalid UTF-8 sequence\n" );
        heap_free( utf8 );
        return NULL;
    }
    if ((ret = ws_alloc( heap, *ret_len * sizeof(WCHAR) )))
        MultiByteToWideChar( CP_UTF8, 0, (char *)utf8, len_utf8, ret, *ret_len );

    heap_free( utf8 );
    return ret;
}
Ejemplo n.º 7
0
Archivo: url.c Proyecto: AndreRH/wine
/**************************************************************************
 *          WsEncodeUrl		[webservices.@]
 */
HRESULT WINAPI WsEncodeUrl( const WS_URL *base, ULONG flags, WS_HEAP *heap, WS_STRING *ret,
                            WS_ERROR *error )
{
    static const WCHAR fmtW[] = {':','%','u',0};
    ULONG len = 0, len_scheme, len_enc, ret_size;
    const WS_HTTP_URL *url = (const WS_HTTP_URL *)base;
    const WCHAR *scheme;
    WCHAR *str, *p, *q;
    ULONG port = 0;
    HRESULT hr;

    TRACE( "%p %08x %p %p %p\n", base, flags, heap, ret, error );
    if (error) FIXME( "ignoring error parameter\n" );

    if (!url || !heap || !ret) return E_INVALIDARG;
    if (flags)
    {
        FIXME( "unimplemented flags %08x\n", flags );
        return E_NOTIMPL;
    }
    if (!(scheme = scheme_str( url->url.scheme, &len_scheme ))) return WS_E_INVALID_FORMAT;
    len = len_scheme + 3; /* '://' */
    len += 6; /* ':65535' */

    if ((hr = url_encode_size( url->host.chars, url->host.length, "", &len_enc )) != S_OK)
        return hr;
    len += len_enc;

    if ((hr = url_encode_size( url->path.chars, url->path.length, "/", &len_enc )) != S_OK)
        return hr;
    len += len_enc;

    if ((hr = url_encode_size( url->query.chars, url->query.length, "/?", &len_enc )) != S_OK)
        return hr;
    len += len_enc + 1; /* '?' */

    if ((hr = url_encode_size( url->fragment.chars, url->fragment.length, "/?", &len_enc )) != S_OK)
        return hr;
    len += len_enc + 1; /* '#' */

    ret_size = len * sizeof(WCHAR);
    if (!(str = ws_alloc( heap, ret_size ))) return WS_E_QUOTA_EXCEEDED;

    memcpy( str, scheme, len_scheme * sizeof(WCHAR) );
    p = str + len_scheme;
    p[0] = ':';
    p[1] = p[2] = '/';
    p += 3;

    if ((hr = url_encode( url->host.chars, url->host.length, p, "", &len_enc )) != S_OK)
        goto error;
    p += len_enc;

    if (url->portAsString.length)
    {
        q = url->portAsString.chars;
        len = url->portAsString.length;
        while (len && isdigitW( *q ))
        {
            if ((port = port * 10 + *q - '0') > 65535)
            {
                hr = WS_E_INVALID_FORMAT;
                goto error;
            }
            q++; len--;
        }
        if (url->port && port != url->port)
        {
            hr = E_INVALIDARG;
            goto error;
        }
    } else port = url->port;

    if (port == default_port( url->url.scheme )) port = 0;
    if (port)
    {
        WCHAR buf[7];
        len = sprintfW( buf, fmtW, port );
        memcpy( p, buf, len * sizeof(WCHAR) );
        p += len;
    }

    if ((hr = url_encode( url->path.chars, url->path.length, p, "/", &len_enc )) != S_OK)
        goto error;
    p += len_enc;

    if (url->query.length)
    {
        *p++ = '?';
        if ((hr = url_encode( url->query.chars, url->query.length, p, "/?", &len_enc )) != S_OK)
            goto error;
        p += len_enc;
    }

    if (url->fragment.length)
    {
        *p++ = '#';
        if ((hr = url_encode( url->fragment.chars, url->fragment.length, p, "/?", &len_enc )) != S_OK)
            goto error;
        p += len_enc;
    }

    ret->length = p - str;
    ret->chars  = str;
    return S_OK;

error:
    ws_free( heap, str, ret_size );
    return hr;
}
Ejemplo n.º 8
0
Archivo: url.c Proyecto: AndreRH/wine
/**************************************************************************
 *          WsDecodeUrl		[webservices.@]
 */
HRESULT WINAPI WsDecodeUrl( const WS_STRING *str, ULONG flags, WS_HEAP *heap, WS_URL **ret,
                            WS_ERROR *error )
{
    HRESULT hr = WS_E_QUOTA_EXCEEDED;
    WCHAR *p, *q, *decoded = NULL;
    WS_HTTP_URL *url = NULL;
    ULONG len, len_decoded, port = 0;

    TRACE( "%s %08x %p %p %p\n", str ? debugstr_wn(str->chars, str->length) : "null", flags,
           heap, ret, error );
    if (error) FIXME( "ignoring error parameter\n" );

    if (!str || !heap) return E_INVALIDARG;
    if (!str->length) return WS_E_INVALID_FORMAT;
    if (flags)
    {
        FIXME( "unimplemented flags %08x\n", flags );
        return E_NOTIMPL;
    }
    if (!(decoded = url_decode( str->chars, str->length, heap, &len_decoded )) ||
        !(url = ws_alloc( heap, sizeof(*url) ))) goto error;

    hr = WS_E_INVALID_FORMAT;

    p = q = decoded;
    len = len_decoded;
    while (len && *q != ':') { q++; len--; };
    if (*q != ':') goto error;
    if ((url->url.scheme = scheme_type( p, q - p )) == ~0u) goto error;

    if (!--len || *++q != '/') goto error;
    if (!--len || *++q != '/') goto error;

    p = ++q; len--;
    while (len && *q != '/' && *q != ':' && *q != '?' && *q != '#') { q++; len--; };
    if (q == p) goto error;
    url->host.length = q - p;
    url->host.chars  = p;

    if (len && *q == ':')
    {
        p = ++q; len--;
        while (len && isdigitW( *q ))
        {
            if ((port = port * 10 + *q - '0') > 65535) goto error;
            q++; len--;
        };
        url->port = port;
        url->portAsString.length = q - p;
        url->portAsString.chars  = p;
    }
    if (!port)
    {
        url->port = default_port( url->url.scheme );
        url->portAsString.length = 0;
        url->portAsString.chars  = NULL;
    }

    if (len && *q == '/')
    {
        p = q;
        while (len && *q != '?') { q++; len--; };
        url->path.length = q - p;
        url->path.chars  = p;
    }
    else url->path.length = 0;

    if (len && *q == '?')
    {
        p = ++q; len--;
        while (len && *q != '#') { q++; len--; };
        url->query.length = q - p;
        url->query.chars  = p;
    }
    else url->query.length = 0;

    if (len && *q == '#')
    {
        p = ++q; len--;
        while (len && *q != '#') { q++; len--; };
        url->fragment.length = q - p;
        url->fragment.chars  = p;
    }
    else url->fragment.length = 0;

    *ret = (WS_URL *)url;
    return S_OK;

error:
    if (decoded != str->chars) ws_free( heap, decoded, len_decoded );
    ws_free( heap, url, sizeof(*url) );
    return hr;
}