/* * rpc_server.c * ------------ * Remote procedure call server-side private API implementation. * * Copyright (c) 2016, NORDUnet A/S All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the NORDUnet nor the names of its contributors may * be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * This is the main RPC server moddule. It creates a new thread to deal * with each request, to prevent a long-running request (e.g. RSA keygen) * from blocking independent requests from other clients. This has a * number of consequences. We can't do a blocking receive in the main * thread, because that prevents the dispatch thread from transmitting the * response (because they both want to lock the UART - see * stm32f4xx_hal_uart.c). So we have to do a non-blocking receive with a * callback routine. But we can't create a thread from the callback * routine, because it's in the context of an ISR, so we raise a semaphore * for the main thread to create the dispatch thread. */ #include "cmsis_os.h" #include "stm-init.h" #include "stm-led.h" #include "stm-fmc.h" #include "stm-uart.h" /* stm32f4xx_hal_def.h and hal.h both define HAL_OK as an enum value */ #define HAL_OK HAL_OKAY #include "hal.h" #include "hal_internal.h" /* hal_rpc_sendto, hal_rpc_recvfrom */ #include "xdr_internal.h" /* hal_xdr_encode_int */ /* RPC buffers. For each active RPC, there will be two - input and output. */ #ifndef NUM_RPC_BUFFER /* An arbitrary number, but we don't expect to have more than 8 concurrent * RPC requests. */ #define NUM_RPC_BUFFER 16 #endif #ifndef MAX_PKT_SIZE /* Another arbitrary number, more or less driven by the 4096-bit RSA * keygen test. */ #define MAX_PKT_SIZE 4096 #endif /* The thread entry point takes a single void* argument, so we bundle the * packet buffer and length arguments together. */ typedef struct { size_t len; uint8_t buf[MAX_PKT_SIZE]; } rpc_buffer_t; osPoolDef(rpc_buffer_pool, NUM_RPC_BUFFER, rpc_buffer_t); osPoolId rpc_buffer_pool; static rpc_buffer_t *rpc_buffer_alloc(void) { return (rpc_buffer_t *)osPoolCAlloc(rpc_buffer_pool); } /* A mutex to arbitrate concurrent UART transmits, from RPC responses. */ osMutexId uart_mutex; osMutexDef(uart_mutex); /* Borrowed from xdr.c. We know the target architecture is little-endian, * but we pretend for the sake of appearances. */ #ifdef __ARMEL__ /* little endian */ static inline uint32_t htonl(uint32_t w) { return ((w & 0x000000ff) << 24) + ((w & 0x0000ff00) << 8) + ((w & 0x00ff0000) >> 8) + ((w & 0xff000000) >> 24); } #else #define htonl(x) (x) #endif /* Thread entry point for the RPC request handler. */ static void dispatch_thread(void const *args) { rpc_buffer_t *ibuf = (rpc_buffer_t *)args; rpc_buffer_t *obuf = rpc_buffer_alloc(); if (obuf == NULL) { uint32_t err = htonl(HAL_ERROR_ALLOCATION_FAILURE); osMutexWait(uart_mutex, osWaitForever); hal_rpc_sendto((uint8_t *)&err, 4, NULL); osMutexRelease(uart_mutex); osPoolFree(rpc_buffer_pool,
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals

AUTHOR = u'Rob Austein'
SITENAME = u'Your Bug Report Will Be Graded'

# Apparently this is much longer than theme designer expected.  Skip it for now.
SITESUBTITLE = u'"I\'m not proud of being a congenital pain in the ass.  But I will take money for it."'

PATH = 'content'
TIMEZONE = 'UTC'
DEFAULT_LANG = u'English'

# Hack article URLs to match what Blogofile did, to avoid breaking links.

ARTICLE_URL = '{date:%Y}/{date:%m}/{date:%d}/{slug}/'
ARTICLE_SAVE_AS = '{date:%Y}/{date:%m}/{date:%d}/{slug}/index.html'

# Feed generation is usually not desired when developing
SITEURL = ''
RELATIVE_URLS = True
FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None

# Blogroll
LINKS = (('Pelican', 'http://getpelican.com/'),
         ('Python.org', 'http://python.org/'),
         ('Jinja2', 'http://jinja.pocoo.org/'))
LINKS_WIDGET_NAME = "Links"

# Social widget.  Can't get rid of this with default theme, only change its name.
# Fiddle with themes later
SOCIAL = ()
SOCIAL_WIDGET_NAME = "Subscribe"

DEFAULT_PAGINATION = 10

THEME = "/home/blog/pelican-themes/sundown"