Skip to content

Commit

Permalink
slotspec defaults to all empty
Browse files Browse the repository at this point in the history
  • Loading branch information
arekinath committed Nov 14, 2023
1 parent 64ea325 commit 2a74adb
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 18 deletions.
45 changes: 31 additions & 14 deletions slot-spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright (c) 2019, Joyent Inc
* Author: Alex Wilson <alex.wilson@joyent.com>
* Copyright 2023 The University of Queensland
* Author: Alex Wilson <alex@uq.edu.au>
*/

#include <stdint.h>
Expand All @@ -30,6 +30,7 @@ slotspec_alloc(void)
{
struct slotspec *spec;
spec = calloc(1, sizeof (*spec));
spec->ss_mask = 0x743ffffc;
return (spec);
}

Expand Down Expand Up @@ -69,8 +70,20 @@ slotspec_test(const struct slotspec *spec, enum piv_slotid slotid)
return ((spec->ss_mask & (1ull << parsed)) != 0);
}

void
slotspec_set_default(struct slotspec *spec)
{
spec->ss_mask = 0x743ffffc;
}

void
slotspec_clear_all(struct slotspec *spec)
{
spec->ss_mask = 0;
}


#line 74 "slot-spec.c"
#line 87 "slot-spec.c"
static const char _slotspec_actions[] = {
0, 1, 3, 1, 6, 2, 0, 3,
2, 2, 5, 2, 4, 5, 2, 6,
Expand Down Expand Up @@ -149,12 +162,11 @@ static const int slotspec_error = 0;
static const int slotspec_en_main = 1;


#line 121 "slot-spec.rl"
#line 134 "slot-spec.rl"

errf_t *
slotspec_parse(struct slotspec *spec, const char *p)
slotspec_parse_pe(struct slotspec *spec, const char *p, const char *pe)
{
const char *pe = p + strlen(p);
const char *eof = pe;
boolean_t invert = B_FALSE;
enum piv_slotid slotid;
Expand All @@ -165,17 +177,15 @@ slotspec_parse(struct slotspec *spec, const char *p)
unsigned long int parsed;
int cs;

spec->ss_mask = 0x743ffffc;


#line 172 "slot-spec.c"
#line 182 "slot-spec.c"
{
cs = slotspec_start;
}

#line 139 "slot-spec.rl"
#line 149 "slot-spec.rl"

#line 179 "slot-spec.c"
#line 189 "slot-spec.c"
{
int _klen;
unsigned int _trans;
Expand Down Expand Up @@ -314,7 +324,7 @@ slotspec_parse(struct slotspec *spec, const char *p)
"(expected '!' and then a slot)", p - 1));
}
break;
#line 318 "slot-spec.c"
#line 328 "slot-spec.c"
}
}

Expand Down Expand Up @@ -387,15 +397,15 @@ slotspec_parse(struct slotspec *spec, const char *p)
"(expected '!' and then a slot)", p - 1));
}
break;
#line 391 "slot-spec.c"
#line 401 "slot-spec.c"
}
}
}

_out: {}
}

#line 140 "slot-spec.rl"
#line 150 "slot-spec.rl"

if (cs == slotspec_error) {
err = errf("InvalidSlotSpec", NULL, "Unexpected '%c'",
Expand All @@ -407,3 +417,10 @@ slotspec_parse(struct slotspec *spec, const char *p)

return (err);
}

errf_t *
slotspec_parse(struct slotspec *spec, const char *p)
{
const char *pe = p + strlen(p);
return (slotspec_parse_pe(spec, p, pe));
}
4 changes: 4 additions & 0 deletions slot-spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ struct slotspec;
struct slotspec *slotspec_alloc(void);
void slotspec_free(struct slotspec *);
errf_t *slotspec_parse(struct slotspec *, const char *);
errf_t *slotspec_parse_pe(struct slotspec *, const char *,
const char *);

void slotspec_set(struct slotspec *, enum piv_slotid slot);
void slotspec_clear(struct slotspec *, enum piv_slotid slot);
void slotspec_set_default(struct slotspec *);
void slotspec_clear_all(struct slotspec *);
int slotspec_test(const struct slotspec *, enum piv_slotid slot);

#endif /* !_SLOT_SPEC_H */
25 changes: 21 additions & 4 deletions slot-spec.rl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ slotspec_alloc(void)
{
struct slotspec *spec;
spec = calloc(1, sizeof (*spec));
spec->ss_mask = 0x743ffffc;
return (spec);
}

Expand Down Expand Up @@ -117,12 +118,23 @@ slotspec_test(const struct slotspec *spec, enum piv_slotid slotid)
return ((spec->ss_mask & (1ull << parsed)) != 0);
}

void
slotspec_set_default(struct slotspec *spec)
{
spec->ss_mask = 0x743ffffc;
}

void
slotspec_clear_all(struct slotspec *spec)
{
spec->ss_mask = 0;
}

%% write data;

errf_t *
slotspec_parse(struct slotspec *spec, const char *p)
slotspec_parse_pe(struct slotspec *spec, const char *p, const char *pe)
{
const char *pe = p + strlen(p);
const char *eof = pe;
boolean_t invert = B_FALSE;
enum piv_slotid slotid;
Expand All @@ -133,8 +145,6 @@ slotspec_parse(struct slotspec *spec, const char *p)
unsigned long int parsed;
int cs;

spec->ss_mask = 0x743ffffc;

%% write init;
%% write exec;

Expand All @@ -148,3 +158,10 @@ slotspec_parse(struct slotspec *spec, const char *p)

return (err);
}

errf_t *
slotspec_parse(struct slotspec *spec, const char *p)
{
const char *pe = p + strlen(p);
return (slotspec_parse_pe(spec, p, pe));
}

0 comments on commit 2a74adb

Please sign in to comment.