Device tree override reg value - linux-device-driver

I have a device tree that I want to override some node's reg value. The problem is that my understanding the name of the node has to match the reg value. How can this node's reg change without overriding the parent node.
Example:
\{
parent_name : parent {
n10 : node#10 {
reg = <10>;
};
n100 : node#100 {
reg = <100>;
};
};
To override node#100 to have a different reg value, can this be done:
&n100 {
reg = <200>;
}
If this is done, the reg of node#100 will be 200 which is not what the specs says.

the name of the node has to match the reg value
Correct, the Device Tree Specification does mention this requirement.
You should not try to "redefine" the reg property which would create a descrepancy.
Rather you could create a whole new node with the proper node name & unit address.
You can delete the old node using
/delete-node/ node#100;
or
/delete-node/ &n100;

Related

How can i create multiple fargate profiles with single namespace and different labels using terraform?

I am trying to create fargate profiles for EKS using terraform, the requirement is to create multiple fargate profiles bound to single namespace but different label.
I have defined the selector variable as below :
variable "selectors" {
description = "description"
type = list(object({
namespace = string
labels = any
}))
default = []
}
and the fargate module block as below :
resource "aws_eks_fargate_profile" "eks_fargate_profile" {
for_each = {for namespace in var.selectors: namespace.namespace => namespace}
cluster_name = var.cluster_name
fargate_profile_name = format("%s-%s","fargate",each.value.namespace)
pod_execution_role_arn = aws_iam_role.eks_fargate_role.arn
subnet_ids = var.vpc_subnets
selector {
namespace = each.value.namespace
labels = each.value.labels
}
and calling the module as below :
selectors = [
{
namespace = "ns"
labels = {
Application = "fargate-1"
}
},
{
namespace = "ns"
labels = {
Application = "fargate-2"
}
}
]
When i try to run terraform plan, i am getting below error :
Two different items produced the key "jenkinsbuild" in this 'for' expression. If duplicates are expected, use the ellipsis (...) after the value expression to enable grouping by key.
I tried giving (...) at the end of the for loop, this time i am getting another error as below :
each.value is tuple with 1 element
│
│ This value does not have any attributes.
I also defined selectors variable type as any, as well tried type casting the output to string(namespace) and object(labels), but no luck.
So could you please help me in achieving the same, It seems i am close but i am missing something here.
Thanks and Regards,
Sandeep.
In Terraform, when using for_each, the keys must be unique. If you do not have unique keys, then use count:
resource "aws_eks_fargate_profile" "eks_fargate_profile" {
count = length(var.selectors)
selector {
namespace = var.selectors[count.index].namespace
labels = var.selectors[count.index].labels
}
...
}

How does the next object work in Linked List? How is it able to make another class objects point to the next address?

class Node
{
public int data;
public Node next;
public Node(int idata) {
data = idata;
next = null;
}
}
Node newnode = new Node(val);
newnode.next = null;
Like if I'm creating a new object newnode of the class Node , how is it able to use .next to find the next address of the list?
In your example code next is just null. Actually, it was not necessary to explicitly do newnode.next = null;, as it already was initialised to null in the Node constructor.
It becomes more interesting when you assign another new node to the next property of the node you have created:
Node newnode = new Node(1);
newnode.next = new Node(2);
In Java objects are accessed with references. newnode is such a reference, and newnode.next is also such a reference. Both are references to Node instances (if not null).
We could extend the linked list further:
newnode.next.next = new Node(3);
newnode.next.next.next = new Node(4);
When you realise that next is a property that can hold a value like any variable, then there is really no magic to it.
You could for instance also first create Node instances that are disconnected, and only after their creation link them together:
Node a = new Node(1);
Node b = new Node(2);
Node c = new Node(3);
Node d = new Node(4);
a.next = b;
b.next = c;
c.next = d;

How to create a directory on the basis of path in cq5?

I have a String which is the path of the page for example /content/xperia/public/events/eventeditor. I am gererating the XML of this page and saving it to DAM, but I want to save it in the similar tree structure under /content.
I tried the following code
String page = "/content/xperia/public/events/eventeditor";
page = page.replace("/content", "/content/dam");
if (adminSession.nodeExists(page+ "/"+ "jcr:content")) {
Node node = adminSession.getNode(page+ "/"+ "jcr:content");
node.setProperty("jcr:data", sb.toString());
} else {
Node feedNode = JcrUtil.createPath(page,"nt:file", adminSession);
Node dataNode = JcrUtil.createPath(feedNode.getPath() + "/"+ "jcr:content", "nt:resource", adminSession);
dataNode.setProperty("jcr:data",sb.toString());
}
But it gives the following error
No matching child node definition found for
{http://www.jcp.org/jcr/1.0}content
Because there is no such path in the repository. Is there a way through which I can create a directory on the fly. Because to save this file, I need to create the entire tree xperia/public/events under /content/dam and then save eventeditor.xml in that directory .
Please suggest.
There are a few issues with your code. The JcrUtil.createPath(String absolutePath, String nodeType, Session session) creates all the non-existent intermediate path with the given NodeType.
This means that all the nodes xperia, public and events are created with type nt:file instead of sling:OrderedFolder.
You can use the createPath(String absolutePath, boolean createUniqueLeaf, String intermediateNodeType, String nodeType, Session session, boolean autoSave) method instead, to specify the type of intermediary nodes that are to be created.
String page = "/content/xperia/public/events/eventeditor";
page = page.replace("/content", "/content/dam");
page += ".xml";
if (adminSession.nodeExists(page+ "/"+ "jcr:content")) {
Node node = adminSession.getNode(page+ "/"+ "jcr:content");
node.setProperty("jcr:data", sb.toString());
} else {
Node feedNode = JcrUtil.createPath(page, true, "sling:OrderedFolder", "nt:file", adminSession, false);
Node dataNode = feedNode.addNode("jcr:content", "nt:resource");
dataNode.setProperty("jcr:data",sb.toString());
}
adminSession.save();

llvm Invalid operand for global metadata

I want to assign unique IDs for basic blocks in a module using global metadata. But I got an error: "Invalid operand for global metadata!". Any problems in the follow code snippet?
Here is part of the code I add operand of a named metadata node:
bool runOnModule(Module &M) {
...
NamedMDNode *NMD = M.getOrInsertNamedMetadata(mdKindName);
for (Module::iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI) {
for (Function::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ++BI) {
errs() << "Basic Block number: " << counter << "\n";
NMD->addOperand(assignID(BI, ++counter));
errs() << "Basic Block name: " << BI->getName() << "\n";
}
}
...
}
// Assign unique IDs to Basic Blocks as Metadata Nodes
MDNode* assignID (BasicBlock* BB, unsigned id) {
// Fetch the context in which the enclosing module was defined
LLVMContext &Context = BB->getParent()->getParent()->getContext();
// Create a metadata node that contains ID as a constant:
Value* ID[2];
ID[0] = BB;
ID[1] = ConstantInt::get(Type::getInt32Ty(Context), id);
return MDNode::getWhenValsUnresolved(Context, ArrayRef<Value*>(ID, 2), false);
}
The version of llvm is 3.6.0.
I am using visual studio 2013 for my project.
Thanks,
henry
Solution: ID[0] should store MDString::get(Context, BB->getName())
By passing false as the last argument for getWhenValsUnresolved, you have created a global metadata node. Global metadata may only contain:
Constants, including addresses of global values.
MDNodes.
MDStrings.
If you want to use something which is function-local - such as instruction, argument or (in your case) a basic-block, you need to use local metadata. Create one by using true as the last argument there.

specman: Assign multiple struct member in one expression

Hy,
I expanding an existing specman test where some code like this appears:
struct dataset {
!register : int (bits:16);
... other members
}
...
data : list of dataset;
foo : dataset;
gen foo;
foo.register = 0xfe;
... assign other foo members ...
data.push(foo.copy());
is there a way to assign to the members of the struct in one line? like:
foo = { 0xff, ... };
I currently can't think of a direct way of setting all members as you want, but there is a way to initialize variables (I'm not sure if it works on struct members as well). Anyway something like the following may fit for you:
myfunc() is {
var foo : dataset = new dataset with {
.register = 0xff;
.bar = 0xfa;
}
data.push(foo.copy());
}
You can find more information about new with help new struct from the specman prompt.
Hope it helps!
the simple beuty of assigning fields by name is one language feature i've always found usefull , safe to code and readable.
this is how i'd go about it:
struct s {
a : int;
b : string;
c : bit;
};
extend sys {
ex() is {
var s := new s with {.a = 0x0; .b = "zero"; .c = 0;};
};
run() is also {
var s;
gen s keeping {.a == 0x0; .b == "zero"; .c == 0;};
};
};
i even do data.push(new dataset with {.reg = 0xff; bar = 0x0;}); but you may raise the readablity flag if you want.
warning: using unpack() is perfectly correct (see ross's answer), however error prone IMO. i recommend to verify (with code that actually runs) every place you opt to use unpack().
You can directly use the pack and unpack facility of Specman with "physical fields" ( those instance members prefixed with the modifier %).
Example:
define FLOODLES_WIDTH 47;
type floodles_t : uint(bits:FLOODLES_WIDTH);
define FLABNICKERS_WIDTH 28;
type flabnickers_t : uint(bits:FLABNICKERS_WIDTH);
struct foo_s {
%!floodle : floodles_t;
%!flabnicker : flabnickers_t;
};
extend sys {
run() is also {
var f : foo_s = new;
unpack(packing.low,64'hdeadbeefdeadbeef,f);
print f;
unpack(packing.low,64'hacedacedacedaced,f);
print f;
};
setup() is also {
set_config(print,radix,hex);
};
};
When this run, it prints:
Loading /nfs/pdx/home/rbroger1/tmp.e ...
read...parse...update...patch...h code...code...clean...
Doing setup ...
Generating the test using seed 1...
Starting the test ...
Running the test ...
f = foo_s-#0: foo_s of unit: sys
---------------------------------------------- #tmp
0 !%floodle: 0x3eefdeadbeef
1 !%flabnicker: 0x001bd5b
f = foo_s-#0: foo_s of unit: sys
---------------------------------------------- #tmp
0 !%floodle: 0x2cedacedaced
1 !%flabnicker: 0x00159db
Look up packing, unpacking, physical fields, packing.low, packing.high in your Specman docs.
You can still use physical fields even if the struct doesn't map to the DUT. If your struct is already using physical fields for some other purpose then you'll need to pursue some sort of set* method for that struct.