about summary refs log tree commit diff stats
path: root/html/shell/cell.mu.html
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2021-06-26 09:20:32 -0700
committerKartik Agaram <vc@akkartik.com>2021-06-26 09:20:32 -0700
commitdc5a0acf3feea227d03a98cedf427d2aef462320 (patch)
treeee6eff6dfc02b88063b51b7d413f03a91566403f /html/shell/cell.mu.html
parentf7a7db83eff079d0494ded92fd73403d23a55538 (diff)
downloadmu-dc5a0acf3feea227d03a98cedf427d2aef462320.tar.gz
.
Switch html rendering to my current colorscheme with a little less blue,
for night browsing.
Diffstat (limited to 'html/shell/cell.mu.html')
-rw-r--r--html/shell/cell.mu.html14
1 files changed, 7 insertions, 7 deletions
diff --git a/html/shell/cell.mu.html b/html/shell/cell.mu.html
index 2317802a..c58efa7d 100644
--- a/html/shell/cell.mu.html
+++ b/html/shell/cell.mu.html
@@ -10,20 +10,20 @@
 <meta name="colorscheme" content="minimal-light">
 <style type="text/css">
 <!--
-pre { white-space: pre-wrap; font-family: monospace; color: #000000; background-color: #eeeeee; }
-body { font-size:12pt; font-family: monospace; color: #000000; background-color: #eeeeee; }
+pre { white-space: pre-wrap; font-family: monospace; color: #000000; background-color: #ffffd7; }
+body { font-size:12pt; font-family: monospace; color: #000000; background-color: #ffffd7; }
 a { color:inherit; }
 * { font-size:12pt; font-size: 1em; }
-.PreProc { color: #c000c0; }
-.Special { color: #ff6060; }
+.muRegEsi { color: #87d787; }
+.muComment { color: #005faf; }
 .LineNr { }
 .Constant { color: #008787; }
-.muRegEcx { color: #af875f; }
-.muRegEsi { color: #87d787; }
+.Special { color: #ff6060; }
 .muRegEax { color: #875f00; }
 .Delimiter { color: #c000c0; }
 .muFunction { color: #af5f00; text-decoration: underline; }
-.muComment { color: #005faf; }
+.muRegEcx { color: #af875f; }
+.PreProc { color: #c000c0; }
 -->
 </style>
 
94' href='#n194'>194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240pre { line-height: 125%; } td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#include "list.h"
#include "pipe.h"
#include "fs.h"
#include "alloc.h"
#include "fifobuffer.h"

static List* gPipeList = NULL;

static FileSystemNode* gPipesRoot = NULL;

static FileSystemDirent gDirent;

typedef struct Pipe {
    char name[32];
    FifoBuffer* buffer;
    FileSystemNode* fsNode;
    List* accessingThreads;
} Pipe;

static BOOL pipes_open(File *file, uint32 flags);
static FileSystemDirent *pipes_readdir(FileSystemNode *node, uint32 index);
static FileSystemNode *pipes_finddir(FileSystemNode *node, char *name);

void initializePipes() {
    gPipeList = List_Create();

    gPipesRoot = getFileSystemNode("/system/pipes");

    if (NULL == gPipesRoot) {
        WARNING("/system/pipes not found!!");
    }
    else {
        gPipesRoot->open = pipes_open;
        gPipesRoot->finddir = pipes_finddir;
        gPipesRoot->readdir = pipes_readdir;
    }
}

static BOOL pipes_open(File *file, uint32 flags) {
    return TRUE;
}

static FileSystemDirent *pipes_readdir(FileSystemNode *node, uint32 index) {
    int counter = 0;

    List_Foreach (n, gPipeList) {
        Pipe* p = (Pipe*)n->data;

        if (counter == index) {
            strcpy(gDirent.name, p->name);
            gDirent.fileType = FT_Pipe;

            return &gDirent;
        }
        ++counter;
    }

    return NULL;
}

static FileSystemNode *pipes_finddir(FileSystemNode *node, char *name) {
    List_Foreach (n, gPipeList) {
        Pipe* p = (Pipe*)n->data;

        if (strcmp(name, p->name) == 0) {
            return p->fsNode;
        }
    }

    return NULL;
}

static BOOL pipe_open(File *file, uint32 flags) {
    beginCriticalSection();

    Pipe* pipe = file->node->privateNodeData;

    List_Append(pipe->accessingThreads, file->thread);

    endCriticalSection();

    return TRUE;
}

static void pipe_close(File *file) {
    beginCriticalSection();

    Pipe* pipe = file->node->privateNodeData;

    List_RemoveFirstOccurrence(pipe->accessingThreads, file->thread);

    endCriticalSection();
}

static void blockAccessingThreads(Pipe* pipe) {
    disableInterrupts();

    List_Foreach (n, pipe->accessingThreads) {
        Thread* reader = n->data;

        reader->state = TS_WAITIO;

        reader->state_privateData = pipe;
    }

    enableInterrupts();

    halt();
}

static void wakeupAccessingThreads(Pipe* pipe) {
    beginCriticalSection();

    List_Foreach (n, pipe->accessingThreads) {
        Thread* reader = n->data;

        if (reader->state == TS_WAITIO) {
            if (reader->state_privateData == pipe) {
                reader->state = TS_RUN;
            }
        }
    }

    endCriticalSection();
}

static int32 pipe_read(File *file, uint32 size, uint8 *buffer) {
    if (0 == size || NULL == buffer) {
        return -1;
    }

    Pipe* pipe = file->node->privateNodeData;

    uint32 used = 0;
    while ((used = FifoBuffer_getSize(pipe->buffer)) < size) {
        blockAccessingThreads(pipe);
    }

    disableInterrupts();

    int32 readBytes = FifoBuffer_dequeue(pipe->buffer, buffer, size);

    wakeupAccessingThreads(pipe);

    return readBytes;
}

static int32 pipe_write(File *file, uint32 size, uint8 *buffer) {
    if (0 == size || NULL == buffer) {
        return -1;
    }

    Pipe* pipe = file->node->privateNodeData;

    uint32 free = 0;
    while ((free = FifoBuffer_getFree(pipe->buffer)) < size) {
        blockAccessingThreads(pipe);
    }

    disableInterrupts();

    int32 bytesWritten = FifoBuffer_enqueue(pipe->buffer, buffer, size);

    wakeupAccessingThreads(pipe);

    return bytesWritten;
}

BOOL createPipe(const char* name, uint32 bufferSize) {
    List_Foreach (n, gPipeList) {
        Pipe* p = (Pipe*)n->data;
        if (strcmp(name, p->name) == 0) {
            return FALSE;
        }
    }

    Pipe* pipe = (Pipe*)kmalloc(sizeof(Pipe));
    memset((uint8*)pipe, 0, sizeof(Pipe));

    strcpy(pipe->name, name);
    pipe->buffer = FifoBuffer_create(bufferSize);

    pipe->accessingThreads = List_Create();

    pipe->fsNode = (FileSystemNode*)kmalloc(sizeof(FileSystemNode));
    memset((uint8*)pipe->fsNode, 0, sizeof(FileSystemNode));
    pipe->fsNode->privateNodeData = pipe;
    pipe->fsNode->open = pipe_open;
    pipe->fsNode->close = pipe_close;
    pipe->fsNode->read = pipe_read;
    pipe->fsNode->write = pipe_write;

    List_Append(gPipeList, pipe);

    return TRUE;
}

BOOL destroyPipe(const char* name) {
    List_Foreach (n, gPipeList) {
        Pipe* p = (Pipe*)n->data;
        if (strcmp(name, p->name) == 0) {
            List_RemoveFirstOccurrence(gPipeList, p);
            FifoBuffer_destroy(p->buffer);
            List_Destroy(p->accessingThreads);
            kfree(p->fsNode);
            kfree(p);

            return TRUE;
        }
    }

    return FALSE;
}

BOOL existsPipe(const char* name) {
    List_Foreach (n, gPipeList) {
        Pipe* p = (Pipe*)n->data;
        if (strcmp(name, p->name) == 0) {
            return TRUE;
        }
    }

    return FALSE;
}