text:
Tagged: Funny
The Black Hole Bomb and Black Hole Civilizations
The Black Hole Bomb and Black Hole Civilizations To support Kurzgesagt and learn more about Brilliant, go to https://www.brilliant.org/nutshell and sign up for free. The first 688 people that go to that link will get 20% off the annual Premium subscription. Kurzgesagt Newsletter: http://eepurl.com/cRUQxz Support us on Patreon so we can make more videos (and…
24 HOUR BOX FORT PRISON ESCAPE ROOM!! 📦🚔 Secret UNDERGROUND Tunnel, SPY GADGETS & More!
24 HOUR BOX FORT PRISON ESCAPE ROOM!! 📦🚔 Secret UNDERGROUND Tunnel, SPY GADGETS & More! In Todays 24 hour Box Fort video papa Jake build the worlds biggest Box Fort prison and try to escape it through a secret underground tunnel! In this video we build a box fort prison and do an epic prison…
Whats In My HUGE Fridge?
Whats In My HUGE Fridge? Welcome to my #ROdiculous Life ❤ SUBSCRIBE ► https://www.youtube.com/subscription_center?add_user=rosannapansino WATCH MY PREVIOUS VIDEO ► https://www.youtube.com/watch?v=tITlhjq-6Fg ————————————————————————– SHOP: MY BAKING LINE: http://bit.ly/BakingLine NERDY NUMMIES COOKBOOK: http://www.RosannaPansino.com/the-nerdy-nummies-cookbook/ ————————————————————————– ADD ME ON: Facebook: http://www.facebook.com/rosannapansino Twitter: http://www.twitter.com/RosannaPansino Instagram: http://instagram.com/rosannapansino Snapchat: rosannapansino Website: http://www.RosannaPansino.com ————————————————————————– Thanks for watching! Subscribe for more videos. xoxo Ro
LAZY BOY Vs. TRAMPOLINE from 45m!
LAZY BOY Vs. TRAMPOLINE from 45m! Incoming lazy boy haha SUBSCRIBE ➤ http://bit.ly/SubHowRidiculous BUY NEW MERCH ➤ http://tidd.ly/8b33c00b SOCIALS Instagram ➤ (@HowRidiculous): http://bit.ly/FollowHRonInsta Facebook ➤ http://bit.ly/HRFacey Snapchat ➤ howridiculousau Twitter ➤ (@howridiculous): http://bit.ly/HRTweets JOIN MAILING LIST ➤ http://eepurl.com/bVPft1 We are passionate about seeing children released from poverty and we would love you to consider sponsoring…
Antonio Banderas Can Play Picasso, But Can He Draw Like Him?
Antonio Banderas Can Play Picasso, But Can He Draw Like Him? 'Genius: Picasso' star Antonio Banderas tells the history of the famous artist with whom he shares a hometown. Subscribe To "The Late Show" Channel HERE: http://bit.ly/ColbertYouTube For more content from "The Late Show with Stephen Colbert", click HERE: http://bit.ly/1AKISnR Watch full episodes of "The…
Devils Vs Angels Two w/ TheOdd1sOut
Devils Vs Angels Two w/ TheOdd1sOut We do some more of the draw Thanks to theodd1sout for being apart of this video: https://www.youtube.com/channel/UCo8bcnLyZH8tBIH9V1mLgqQ Come chat with me in Discord ► https://discordapp.com/invite/somethingelseyt twitter ►https://twitter.com/SomethingelseYT Instagram ► https://www.instagram.com/somethingel… snapchat ►adamortiz Songs used: Kevin Macleod – Airport lounge
Wheel of Freestyle with Black Panther's Letitia Wright
Wheel of Freestyle with Black Panther's Letitia Wright Black Panther's Letitia Wright and The Roots' Black Thought take turns working three random words they've never seen before into a freestyle rap (plus a surprise freestyle from Jimmy). Subscribe NOW to The Tonight Show Starring Jimmy Fallon: http://bit.ly/1nwT1aN Watch The Tonight Show Starring Jimmy Fallon Weeknights…
24 HOUR BOX FORT PRISON ESCAPE ROOM!! 📦🚔 Secret Tunnel, SPY GADGETS & More!
24 HOUR BOX FORT PRISON ESCAPE ROOM!! 📦🚔 Secret Tunnel, SPY GADGETS & More! In Todays 24 hour Box Fort video papa Jake build the worlds biggest Box Fort prison and try to escape it through a secret tunnel! In this video we build a box fort prison and do an epic prison escape room!…
You Won't Believe What Obama Says In This Video! 😉
You Won't Believe What Obama Says In This Video! 😉 "We're entering an era in which our enemies can make anyone say anything at any point in time." Check out more awesome videos at BuzzFeedVideo! https://bit.ly/YTbuzzfeedvideo https://bit.ly/YTbuzzfeedblue1 https://bit.ly/YTbuzzfeedviolet GET MORE BUZZFEED: https://www.buzzfeed.com https://www.buzzfeed.com/videos https://www.youtube.com/buzzfeedvideo https://www.youtube.com/asis https://www.youtube.com/buzzfeedblue https://www.youtube.com/buzzfeedviolet https://www.youtube.com/perolike https://www.youtube.com/ladylike BuzzFeedVideo BuzzFeed Motion Picture's flagship channel.…
Robert De Niro Explains Why He Rocks Giant Platform Shoes in The Irishman
Robert De Niro Explains Why He Rocks Giant Platform Shoes in The Irishman Robert De Niro chats about The Irishman, his Martin Scorsese film with Al Pacino, Harvey Keitel and Joe Pesci, and the much-anticipated movies and video games debuting during his Tribeca Film Festival. Subscribe NOW to The Tonight Show Starring Jimmy Fallon: http://bit.ly/1nwT1aN…
Oh my god yes
Liam Toye says:
I think Sean deserves a lot of the credit for putting...
Watery Reptile says:
@Hazyy They do vegan wings
Shea Hargis says:
He's not worthy of this show
Hazyy says:
fantano is vegan so i cant see it unfortunately, would love...


Combine a tour of the Kingdom's highlights with luxury accommodation and fine dining. From the bustle of Phnom Penh to the awe-inspiring Temples of Angkor and the serenity of the Tonle Sap Lake you are sure to enjoy this luxurious experience.
In the afternoon, enjoy a city tour in a cyclo with visits to the National Museum, the Royal Palace and the Silver Pagoda. End your day with a boat trip as the sun sets over the capital.
Royal Place built in 1866 by King Norodom; Silver Pagoda, Tuol Sleng Museum, a reminder of the Khmer Rouge regime. Visit the peaceful stretch of green fields of Cheung Ek. Continue to visit the Russian market and end the trip with a visit of the Wat Phnom Temple, Phnom Penh's namesake, from where you can enjoy views over the tree-lined avenues of Phnom Penh during sunset.
Take a short early morning flight to Siem Reap and transfer to the hotel. In the afternoon, you will ride in a Tuk Tuk to visit Angkor Thom. Continue on to the Bayon Temple, the Terrace of Elephants, the Royal Palace and the Terrace of the Leper King.
Rise early and travel by Tuk Tuk to visit the jungle enveloped temple of Ta Prohm. Next, you will visit the magnificent Angkor Wat. Enjoy a guided tour around this huge structure and learn about the glories of the Kingdom of Angkor. Return to the hotel for a late breakfast and a rest. In the afternoon, head to the temple of Banteay Srei or 'Citadel of the Women'. On your way back to Siem Reap, enjoy the sunset from the top of the pyramid-shaped temple of Pre Rup.
This morning drive by Tuk Tuk to the edge of Siem Reap. Enjoy a fun buffalo cart ride through the countryside until you reach Cambodia's largest freshwater lake; the Tonle Sap. Board a boat and spend the rest of the morning at one of the largest floating villages on the lake which is called Kompong Phluk. In the village you will witness the fascinating daily lives of the local people who live on the water. The rest of the day is at leisure.


As managers, what can we learn from the downfall of Robert Gabriel Mugabe?
Ironically, it was not God who removed Mugabe but his own army.
Normally I send my monthly blog on 21st of the month – this forces me to have the blog ready. A self-imposed discipline that now has become a habit. However, each December I send it out early so it does not get lost in the clutter and busyness before Christmas.
With the fall of the despotic dictator Robert Mugabe in Zimbabwe last month, it would be a pity to waste the opportunity to discuss issues of leadership.
Dictators, even when putting their humanitarian and moral crimes aside, are usually poor managers. Most dictators run their countries in such a way, that if they were companies, they would have failed long ago. Despite the lessons of history, it does not stop many managers today from doing their best to emulate the world's worst management techniques. Most of us have worked for such people during our working life.
Mugabe is a great example. In 37 years of corrupt, bloody, incompetent and chaotic rule, Mugabe managed to reduce the size of the economy to a third of its size in 1980, turning the country from a net food exporter to a country where three quarters of the population now rely on food aid to survive.
Successfully leading a team isn't easy, however it takes a special skill to lead as incompetently as Mugabe. Without trivialising the effects of brutal regimes on citizens where many "national shareholders" pay with their lives, there are some undesirable management characteristics that managers and leaders frequently exhibit that are displayed by dictators such as Mugabe.
What three lessons can we learn from Mugabe's leadership?
Inauthentic leadership is not sustainable. Whilst it might appear that 37 years in power implies sustainable leadership, Mugabe's leadership was only sustained by military force, violence and vote rigging. Even his own political party, ZANU-PF turned on him very quickly indicating that his leadership was inauthentic. Without military support his leadership ceased to exist. His departure brought the population out dancing in the streets.
I can remember working for a general manager who people did not trust, always managed upwards and ignored his subordinates and peers. When he eventually headed the company, there was a rush to the exits of senior managers. The business struggled and was taken over 2 years later.
Surround yourself by people who are not afraid to say 'YES'. Mugabe ensured that any potential leadership rivals and political rivals were silenced, often in suspicious vehicle accidents and mysterious house fires, thereby surrounding himself with sycophants who would play to his ego (Egos Destroy Businesses) and enrich themselves through his corrupt patronage. Promoting his wife to Vice President, and firing Vice President was probably the last straw. Ironically the 'fired' Vice President has since replaced Mugabe as president.
The downfall of many great organisations can be traced to the hubris and arrogance of its leaders. Mugabe fits this picture. Having a fixed mindset, he closed himself off from feedback, and saw himself as the smartest person in the room, was unwilling to listen to others whilst surrounding himself with sycophants who praised him as a 'revolutionary hero'.
Surrounding yourself with "yes" people may make life easier in the short-term, however it does not create long-term, sustainable outcomes, whether in business or politics.
I once witnessed a senior manager surround himself with 'yes men' who were sycophantic to his requirements, while he failed to develop them as professional managers. It was a smokescreen so that he could corruptly enrich himself through the business. Like most dictators he kept his team weak and did not plan for succession. His corrupt activities were eventually found out, was dismissed and left his division in a perilously unprofitable state.
Blame others to divert attention from your own failings whilst never admitting that you make mistakes. Mugabe was a past master at this strategy, whether it was blaming the British government for his own incompetent economic management, the white commercial farmers for not wanting to support his government or his political opposition for civil unrest, he always diverted the blame.
We see this behavior by many managers today. They blame the market, their employees, the government or even their customers for their own management failings. I think we have all worked for managers who have displayed this characteristic. Instead of being accountable for the performance of the organisation, they blame external factors and ignore the cause of the problems. For example, a good employee who leaves under a dictatorial manager is never given an exit interview and their performance or contribution is normally denigrated.
As a boss are you displaying dictatorial management behavior?
In recognising dictatorial management behavioral traits such as those displayed by Mugabe, it allows us to ensure firstly, that we do not act in this manner and secondly to take action if we see it in others. This is the role of a good leader.
Good team leaders display authentic leadership because it is sustainable and best for the team. They surround themselves with competent people, often brighter than themselves and are inclusive of all team members. Furthermore, they develop a succession plan and focus on the issues that drive the business and hold themselves accountable for both successes and failures.
If you would like to test your knowledge of dictators, try this quiz – I got 50/60.
Have you ever walked into a business and realised it was poorly managed before you even met the management team?
Years of experience has sharpened my 'antenna' to organisations with poor management. The symptoms are apparent even when you first come in contact with the business or organisation.
Think about the last time you visited an organisation – what were your first impressions? They are generally a guide to the rest of the organisation. I can remember a recent visit to a business. My first impressions proved to be correct.
The reception was untidy and dirty, no visitors book, no induction procedure, no chair to sit while waiting for the owner, no coffee, tea or water was offered at the meeting, the meeting room where customers would obviously meet had broken chairs with paper and cardboard boxes on the board table. When I politely requested a cup of coffee there were no clean coffee mugs or milk.
Was this initial experience an indication of how the business was managed? Yes of course it was!
The staff were surly and demotivated, and initiative was discouraged. The owner treated them poorly which were exacerbated by his erratic behaviour. The business went into administration within 4 months of my visit.
By comparison, another business I visited was the opposite. Although the office area was 'dated' it was neat and tidy, a drink was offered and there were pictures on the wall showing what the company did together with certificates of appreciation from charities and the company's values were prominently displayed. I subsequently found out that this company was growing profitably at 20% per annum and had been doing so for the past 3 years.
Another indicator is telephone manner – if the phone is not answered promptly, if the person does not state the company, introduce themselves and have a helpful and pleasant manner then it is probably a symptom of poor management. http://everydaylife.globalpost.com/proper-phone-etiquette-workplace-1129.html. Telephones are the face of the business and often the first interaction with customers.
As an extension of this theory, we often don't notice good managers or good customers until they have left. They are often 'invisible' and do their job without 'noise'. In one of my earlier blogs Beware of the Operations Hero https://5-dimensionz.com.au/2013/06/23/beware-the-operations-hero/ explains this concept as well.
Like a well serviced and driven motor vehicle that performs well and does not breakdown, good management is the same.
Good managers recognise this in their staff, customers and suppliers……….do you?


MicroJet Imaging is a major importer, distributor and exporter of Compatible Inkjet Cartridges, Toners and allied products in the Australia.
Established in 2000, we have expanded rapidly since that time, capturing a significant portion of the Inkjet and Laser Toner market in our first year of operation. MicroJet Imaging distributes nationwide through sub-distributors and exporting to overseas markets such as New Zealand, Fiji and other Asian and Pacific destinations.
The Microjet brand offers a comprehensive range of consumables. Cartridges are sourced from suppliers in the US, Taiwan and China to ensure the best possible product in each category. We invest a great deal of time in the selection and testing of our products. Microjet products are always selected on the basis of quality.
Microjet Imaging highly values conscientious service and delivery of quality merchandise. Reliability and consistent performance has resulted in high levels of customer satisfaction, which have consequently ensured continued growth.


Viewing request for 14 Broadway, Lancaster, LA1 2BU.
Fantastic two bed furnished property available for students or student couple looking for a quieter life in Skerton, Lancaster.
Property is within walking distance to the city centre with easy access to motorway and surrounding areas. Local shops, garage and Subway shop nearby. Neutral, modern decor through with two great size, double bedrooms and brand new, modern furniture. Ideal for students, a couple or working professionals.
Tenant pays own bills - needs to be viewed to appreciate the full potential the property has to offer. Get in touch with the office for more information or to book in for a viewing!


HomeRoutines can keep routines that are only used in certain months of the year. For instance, you might have a Spring cleaning list, or an Autumn weekend list involving the raking of ALL THE LEAVES.
Tap the calendar row to select which days of the week the routine will occur, as usual.
Tap on the row with the Month Doughnut to go to the month settings screen. Mmm, doughnuts.
Tap the checkboxes to select which months the routine should show in.


text:
Bâle, Switzerland
Novartis AG develops, manufactures, and markets healthcare products. It operates through the following segments: Pharmaceuticals, Alcon, Sandoz, Vaccines & Diagnostics, and Consumer Health. The Pharmaceuticals segment provides patent-protected prescription medicines. The Alcon segment offers...
Novartis AG develops, manufactures, and markets healthcare products. It operates through the following segments: Pharmaceuticals, Alcon, Sandoz, Vaccines & Diagnostics, and Consumer Health. The Pharmaceuticals segment provides patent-protected prescription medicines. The Alcon segment offers surgical, ophthalmic pharmaceuticals, and vision care products. The Sandoz segment provides generic pharmaceuticals. The Vaccines & Diagnostics segment provides human vaccines and blood testing diagnostics. The Consumer Health segment operates two divisions: Over-the-Counter (OTC) and Animal Health. The OTC division develops and sells a wide range of affordable and reliable consumer medications for self-care and numerous common ailments. The Animal Health division's products prolong and improve animals lives. The company was founded on February 29, 1996 and is headquartered in Basel, Switzerland.
Copywriter / Creative Director / Writer
Producer / Director
Executive Producer / Content Producer / Producer
Content Producer / Executive Producer / Line Producer
Want to work at Novartis?
We'll send Novartis your right swipe.
Is Novartis remote friendly?
How creative is Novartis?
You can do hard.
Novartis Vivinda

redpajama_set_name: RedPajamaCommonCrawl


« *** WINNERS *** Lori, Donna and Ashley are Living the Life of Riley! CONGRATULATIONS!
Jewelry trends may come and go, but there are certain beautiful staples which will always be in fashion. One such staple is pearl jewelry. No matter what stylish ensemble you may be wearing, pearls are sure to add that extra touch of class and pizazz! Recently, I discovered Pure Pearls, an online store specializing in fabulous pearl jewelry.
I had the opportunity to review a gorgeous black freshwater pearl pendant necklace. Keep reading to learn more and how you could win a freshwater pearl pendant necklace in your choice of color too!
I reviewed the Black Freshwater Classic Pearl Pendant, 7.0-10.0 mm, from Pure Pearls, which retails for $575.00, but is currently on sale for $115.00.
Pure Pearls is an online jewelry store dedicated to bringing its customers the absolute best in pearl jewelry at a fraction of the retail prices. Their team of experts source pearls straight from the pearl farms themselves and select only the top 3% of every harvest for their own pearl jewelry. Because Pure Pearls cuts out the middle man entirely, they can offer their customers wholesale prices on top quality pearls.
No wonder it looks so beautiful! The black freshwater pearl is treated with an iridescent peacock overtone to give it its unique appearance and comes on a 16-inch 14K gold box chain. I loved that I actually got to choose the color of gold (either white or yellow) for the box chain too. With the high prices of gold and the flawlessness of the black pearl, I am so shocked that this black freshwater pendant is only being sold for $115.00! Now that's a steal!
Pure Pearls has so many stunning pearl bracelets, necklaces, earrings and rings at remarkable prices. If you are searching for a special gift for yourself or another lucky lady, then I highly suggest checking out the high quality and superbly designed selections from Pure Pearls!
Disclosure: I received the Black Freshwater Classic Pearl Pendant, 7.0-10.00 mm, from Pure Pearls in order to facilitate my review. No other compensation was received. This product review is based on my own personal experiences with this item and is completely honest and objective.


text:
The world's refugee system can be fixed: here's the ten-point plan to save lives and create hope
Refugees walk from railway station in Hegyeshalom in Hungary toward the Austrian border in 2015 (Photo: Vladimir Simicek/AFP/Getty Images)
i Team 2 years Tuesday March 28th 2017
Interview: Baroness Warsi blames Michael Gove for alienating Muslims
'I still regret being unable to save JFK'
Could I strike it lucky in Scotland's gold rush? I went panning to find out
Exit: the U2 song blamed for a murder
Famous double agent Kim Philby's 'real betrayal was leaving family'
Our system for helping refugees is broken, and even those who survive their journeys to Europe are condemned to lives of misery. But the world can help if we take these bold steps, argue experts Alexander Betts and Paul Collier
And still they die in their hundreds. Another boat-load of refugees and migrants, 250 or more of them hoping to make it from Africa to Europe, are thought to have drowned in the Mediterranean last week after two partially submerged dinghies were found.
A combination of state fragility – in countries such as Syria, Somalia and Afghanistan – and increased opportunities for mobility has intensified refugee movements and made for one of the big policy challenges of the 21st century – not to mention a deadly risk for the people involved.
More humans are displaced from their homelands around the world than at any time since the Second World War – and with the spectre of climate change, the numbers will grow.
Yet while the needs increase, the political commitment to assisting refugees is in freefall amid rising populist nationalism. The European refugee crisis offered a test case to see whether our policies have been up to the task. And they demonstrably failed.
Declaring "Wir schaffen das" – or, we'll manage it – German Chancellor Angela Merkel opened her country's doors. But just six months later, recognising her approach was unsustainable, she performed a U-turn by conspiring with the European Union and Turkey to close the Balkans and the Aegean Sea routes to Syrians.
The legacy of Europe's muddled response has been far-reaching. Nine thousand people have drowned crossing the Mediterranean while nationalism has been emboldened.
It does not need to be this way. With better political leadership, we could reform our refugee policies in ways that meet the challenge sustainably at the scale required. Here are 10 steps that we urgently need to take.
A migrant hangs from a boat as they wait to be rescued as they drift in the sea north of Libya (Photo: AFP PHOTO / ARIS MESSINISARIS MESSINIS/AFP/Getty Images)
1) Focus on developing countries:
The real challenge is not in Europe. Only 10 per cent of refugees are in developed countries, and the focus on Europe has led us to neglect a parallel crisis: the dire situation of the 90 per cent of the world's refugees in developing regions.
More than 60 per cent of refugees are in just 10 safe-haven countries: Turkey, Lebanon, Jordan, Kenya, Uganda, Ethiopia, Iran, Pakistan, Tanzania and Chad. This is where we find the most vulnerable people. And yet for every £1 of public money spent by donor states on an asylum seeker who reaches Europe, we spend less than 1p on a refugee in a neighbouring host country.
This neglect has led to declining conditions that are bad for refugees, create insecurity and contribute to onward movement. We need a massive increase in our development assistance contributions to those countries to make refuge sustainable.
A Somali refugee with her child in their compound at Hagadera sector of the Dadaab refugee camp in Kenya (Photo: TONY KARUMBA/AFP/Getty Images)
2) Clarify the purpose of refuge:
In Europe and the US, refuge has become unnecessarily bound up with politically toxic debates relating to "migration" and "globalisation".
Properly understood, though, refuge is about something quite different: offering safe haven to people fleeing danger, and restoring their lives to normality as quickly as possible.
Refuge should mean providing three things: rescue and meeting immediate needs; autonomy by empowering people to help themselves through jobs and education; and an eventual route out of limbo by ensuring people can go home, or receive resettlement elsewhere if it becomes clear that going home is not likely to be an option in the foreseeable future.
For most people, these purposes can be fulfilled close to home and should not require long and dangerous journeys. And the majority do not want to be migrants; when the UN Refugee Agency surveyed Syrian refugees about resettlement in Canada, more than 70 per cent said they preferred to stay closer to home.
Lord Alf Dubs with supporters outside 10 Downing Street before handing in a petition calling for refugee children to continue being welcomed into the UK (Photo: JUSTIN TALLIS/AFP/Getty Images)
3) Move beyond refugee camps:
The humanitarian system's default response remains camps. These offer life-saving basics such as food, clothing and shelter. But they are often dehumanising, usually denying the right to work and freedom of movement. People get stuck in them for decades.
A response designed just for the emergency phase can endure. Kenya's Dadaab camps, for example, opened in 1992 and host 350,000 Somalis – a significant proportion of whom have been there ever since the camps were created.
Unsurprisingly, a majority of refugees bypass camps entirely. And they are left with two equally problematic alternatives: to go to cities, where they give up assistance and often face destitution; or to embark on perilous journeys with people smugglers.
The eastern sector of IFO-2 in the sprawling Dadaab refugee camp, north of the Kenyan capital Nairobi (Photo: TONY KARUMBA/AFP/Getty Images)
4) Allow refugees to work:
Refugees have skills, talents and aspirations. And yet, around the world, they face severe restrictions on the right to work. This undermines autonomy and dignity, and erodes people's ability to help themselves and contribute to their host societies.
The evidence shows that when refugees are given access to labour markets, it leads to "win-win" outcomes for both them and their hosts.
Uganda, now host to around 1 million refugees, lets them work and register businesses. A recent study by Oxford University showed that 21 per cent of refugees in Uganda's capital, Kampala, run a business that employs at least one other person – and, of those they employ, 40 per cent are host country citizens.
Many developing countries are unwilling to let refugees work because they fear displacing citizens from jobs. So development assistance and business investment are needed to create incentives for host countries to open their labour markets. The UK Government is supporting pilot projects to do just that in special development areas in Jordan and Ethiopia.
Refugees from South Sudan conduct a choir practice in a makeshift church in the Adjumani Settlement in Uganda (Photo: Dan Kitwood/Getty Images)
5) Ensure routes out of limbo:
People should not spend their lives as refugees. Ideally, they will be able to go home. But sometimes this is not possible within a reasonable timeframe. Three years of uncertainty may be reasonable; a decade is not.
Once people have been in a safe-haven country beyond a certain "cut-off" time, they should be permanently integrated somewhere – whether in that country or another one.
Resettlement – moving people from camps to a neighbouring country – is currently available to less than 2 per cent of refugees, and it is not used strategically.
Countries need to work together to ensure that resettlement or alternative legal migration options are available – above all to those refugees whose lives have been put on hold indefinitely.
Migrants wait to be rescued in the Mediterranean Sea north of Libya (Photo: AFP PHOTO / ARIS MESSINISARIS MESSINIS/AFP/Getty Images)
6) Incubate post-conflict recovery:
How we treat refugees while they are in exile will shape what they do when they go home. If we can give them access to jobs and education in safe-haven countries, they will be better placed to return home and contribute to reconstruction once the conflict ends.
For example, companies such as Caterpillar, Benetton and Sony were forced to withdraw from Syria – but why shouldn't they continue to employ Syrians on the other side of the Jordanian border and then relocate back when the war ends?
Similarly, if we enable refugees to work while they are in exile, they may build businesses they can take back to their country of origin later on.
Syrian refugee Faraj Ghazi al-Jamous drags his family's luggage out of a hotel in Jordan after
they were prevented from travel to the US by Donald Trump's executive order earlier this year (Photo: KHALIL MAZRAAWI/AFP/Getty Images)
7) Send people back humanely:
Our refugee policies can only be effective against the backdrop of an effective immigration system.
There is no universal right to migrate. But refugees have a right to migrate insofar as it is necessary in order to reach safety. Ideally, this will happen close to home, but occasionally it may not. In these rare instances, we have to offer asylum as a last resort.
To sustain public confidence, our immigration system has to welcome those who are refugees but, for whatever reason, have not found safe haven nearer to home. But it must also devise ways to provide humane returns for those who either are not refugees or have already found adequate protection elsewhere.
Our current return-and-reintegrate policies are not always sufficiently humane or effective, and too often we seek migration partnerships with governments that are not capable of ensuring the human rights of refugees or migrants.
Refugees from Afghanistan attend a French lesson in Saint-Brevin-les-Pins, western France (Photo: LOIC VENANCE/AFP/Getty Images)
8) Don't rely on the UN refugee Convention 1951:
We have an international treaty that defines refugees and sets out their rights. But it was created for a different era – post-Second World War Europe – and it is now of declining relevance.
More than half the world's refugees are in countries that are not full signatories. Elsewhere, including in Europe, there is systemic non-compliance with the treaty.
Furthermore, even when it is applied, its interpretation throws up inconsistent outcomes: if you are an Eritrean, you have a 24 per cent chance of being recognised as a refugee in France – and a 100 per cent chance in Sweden.
This inconsistency stems from the refugee definition no longer being appropriate. It shoehorns today's drivers of displacement into the old definition of a refugee as fleeing "persecution" – when, in reality, most people today flee state fragility and armed conflict.
Migrants walk along the A25 motorway in the direction of Calais (Photo: PHILIPPE HUGUEN/AFP/Getty Images)
9) Reform the UN Refugee Agency:
The world needs a United Nations refugee agency to facilitate collective action by governments. But the current models of the UN High Commissioner for Refugees (UNHCR) need to be updated.
In many contexts, the organisation is absent. In Turkey, for example, the largest refugee-hosting country in the world, fewer than 10 per cent of Syrian refugees get any assistance from the UNHCR or its operational partners.
The agency is very good at running refugee camps and providing legal advice to states. But these are no longer the key skills needed to ensure refugee protection. The skills needed today are economic and political analysis – and yet the UNHCR has limited professional competence in these areas.
Few UN organisations can change from within – there are too many vested interests – and so the push for reform needs to come from donor governments.
Bodies of refugees and migrants have been washing up on a beach in Izmir, along Turkey's Aegean coast (Photo: LATIF SANSUR/AFP/Getty Images)
10) Address root causes
The main cause of displacement today is state fragility. More than 50 per cent of refugees come from just three such countries. However, the international community has a poor track record in rebuilding fragile states.
Many such governments have been through successive periods of internal armed conflict, leading to the repeated waves of internal and cross-border displacement.
Emerging drivers of displacement, such as climate change, will disproportionately exacerbate refugee movements insofar as they affect already fragile states.
If the world is serious about ending displacement, it will need to find better ways to bring peace and stability to situations such as the Syrian conflict.
Alexander Betts is professor of forced migration and international affairs, and Paul Collier is professor of economics and public policy – both at the University of Oxford.
The pair will be giving a 'How To: Academy' talk at the Emmanuel Centre in central London on Thursday to mark the release of their book 'Refuge: Transforming a Broken Refugee System' (Allen Lane, £20)


text:
Q: Don't understand error I am attempting to add authentication to my node.js/express.js/react.js application.
My directory structure is as follows:
application
    server.js
    www
    js
       app.js
       sessions.js

I add these two lines to server.js
var express = require('express'),
    app = express(),
    path = require('path'),
    http = require('http').Server(app),
    io = req

let sessions = require('./www/js/sessions');
app.use(sessions);

I run node server.js I see a new message I have not seen before:
$ node server.js
express-session deprecated req.secret; provide secret option www/js/sessions.js:16:22

and then in the browser when I connect to I get this error. If I remove the two lines above from server.js the program runs fine:
In the browser, I see exception:
TypeError: passport.initialize is not a function
   at module.exports.passport (/home/idf/Documents/js/react-trader/www/js/sessions.js:18:56)
   at Layer.handle [as handle_request] (/home/idf/Documents/js/react-trader/node_modules/express/lib/router/layer.js:95:5)
   at trim_prefix (/home/idf/Documents/js/react-trader/node_modules/express/lib/router/index.js:312:13)
   at /home/idf/Documents/js/react-trader/node_modules/express/lib/router/index.js:280:7
   at Function.process_params (/home/idf/Documents/js/react-trader/node_modules/express/lib/router/index.js:330:12)
   at next (/home/idf/Documents/js/react-trader/node_modules/express/lib/router/index.js:271:10)
   at expressInit (/home/idf/Documents/js/react-trader/node_modules/express/lib/middleware/init.js:33:5)
   at Layer.handle [as handle_request] (/home/idf/Documents/js/react-trader/node_modules/express/lib/router/layer.js:95:5)
   at trim_prefix (/home/idf/Documents/js/react-trader/node_modules/express/lib/router/index.js:312:13)
   at /home/idf/Documents/js/react-trader/node_modules/express/lib/router/index.js:280:7

I can't tell from the error if it is complaining that it can't find sessions.js, or if it is failing to find an npm requirement. I did install express-session and I see it in the package.json so not sure...
{
  "name": "TraderWS",
  "version": "1.0.0",
  "description": "Trader Workstation",
  "main": "server.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Me",
  "license": "MIT",
  "dependencies": {
    "babel-loader": "^6.2.10",
    "babel-preset-es2015": "^6.22.0",
    "babel-preset-react": "^6.22.0",
    "body-parser": "^1.16.1",
    "connect-redis": "^3.2.0",
    "express": "^4.12.3",
    "express-session": "^1.15.1",
    "griddle-react": "^0.7.1",
    "react": "^15.4.2",
    "rx": "^4.0.7",
    "socket.io": "^1.3.5",
    "webpack": "^2.2.1"
  }
}

A: This may or may not help anyone else.
Initially the problem was that I was not passing a passport to sessions. This fixed that problem:
let usersService = require('./service/users');
let bodyParser = require('./middleware/bodyParser');
let passport = require('./config/passport');
let sessions = require('./middleware/sessions')(passport); // was missing parameter passport

Then I had another problem in that I had code below with the commented out version, and that caused an error because there was no secret. Once I actually entered a string secret, the problem went away
'use strict';

const session = require('express-session');

let config = {
    //secret: process.env.SESSION_SECRET,
    secret: 'keyboard cat',
    saveUninitialized: false,
    resave: false
};

if (process.env.REDIS_URL) {
    const RedisStore = require('connect-redis')(session);
    config.store = new RedisStore({ url: process.env.REDIS_URL });
}

let expressSession = session(config);

module.exports = passport => [expressSession, passport.initialize(), passport.session()];

redpajama_set_name: RedPajamaStackExchange


The template should be similar to the car where the design is to be used. Designing it will have to be done using an image editing software. Remember to set up the correct layers. Know which layer will contain dummy elements, elements that are necessary to make the design look realistic but are not needed during the printing.
Keeping how the wrapped car will look in perspective is highly recommended, especially when the car is in motion or when sitting in traffic. Decide when to use bolder colors and when to put them as the main focus of the work. The design should be eye-catching. Limit the text to use in the said wrap since it will be difficult for people to catch up to the reading anyway.
Another part of the design that one will have to keep in mind is the corners. The design is going to be tiled into panels, regardless of who the print provider or the installer is. In order to cater to the issues of the corners during application, it is for the best if the person can talk it out with the print provider or the installer.
There are also times when the person will have to decide on the resolution. The resolution will make a difference on how good the final output will be, after all. Make sure to provide the best output so that the person will not have a difficult time with the entire process. To use the right resolution, ask for the assistance of installers or print providers.
Consider what parts are not needed to be wrapped. There are those parts, after all. It is necessary to strictly abide by this since most of the regulations on such thing are set by the state. In order to determine what the rules are for this, do not hesitate to contact the state or ask the print providers or installers.
The person should also think what the design should be. If possible, one should keep the entire design simple. Otherwise, it will just become visually confusing for the viewers. On the other hand, it will also become more difficult to install. The person should try to avoid complex designs which provide too much information.
There is no need to use spot colors. It is recommended for people to avoid these and just convert them to RGB or CMYK. Making use of the spot colors means that one will be working with transparency. Otherwise, it will just cause strange and even unexpected results during the printing phase.
The design file for these vehicle wraps Los Angeles should be properly linked and saved in its eps format. Turn the fonts into outlines as well. Do not forget to keep a clear copy of this saved file before giving it to the print provider to immediately print the file out.
Read more about The Best Tips For Designing Great Vehicle Wraps visiting our website.


text:
/
    if (tmp > UINT8_MAX) {
        return false;
    }

    *value = (uint8_t) tmp;
    return true;
}

bool tpm2_util_string_to_uint16(const char *str, uint16_t *value) {

    uint32_t tmp;
    bool result = tpm2_util_string_to_uint32(str, &tmp);
    if (!result) {
        return false;
    }

    /* overflow on 16 bits? */
    if (tmp > UINT16_MAX) {
        return false;
    }

    *value = (uint16_t) tmp;
    return true;
}

bool tpm2_util_string_to_uint32(const char *str, uint32_t *value) {

    char *endptr;

    if (str == NULL || *str == '\0') {
        return false;
    }

    /* clear errno before the call, should be 0 afterwards */
    errno = 0;
    uint32_t tmp = strtoul(str, &endptr, 0);
    if (errno) {
        return false;
    }

    /*
     * The entire string should be able to be converted or fail
     * We already checked that str starts with a null byte, so no
     * need to check that again per the man page.
     */
    if (*endptr != '\0') {
        return false;
    }

    *value = tmp;
    return true;
}

int tpm2_util_hex_to_byte_structure(const char *inStr, UINT16 *byteLength,
        BYTE *byteBuffer) {
    int strLength; //if the inStr likes "1a2b...", no prefix "0x"
    int i = 0;
    if (inStr == NULL || byteLength == NULL || byteBuffer == NULL)
        return -1;
    strLength = strlen(inStr);
    if (strLength % 2)
        return -2;
    for (i = 0; i < strLength; i++) {
        if (!isxdigit(inStr[i]))
            return -3;
    }

    if (*byteLength < strLength / 2)
        return -4;

    *byteLength = strLength / 2;

    for (i = 0; i < *byteLength; i++) {
        char tmpStr[4] = { 0 };
        tmpStr[0] = inStr[i * 2];
        tmpStr[1] = inStr[i * 2 + 1];
        byteBuffer[i] = strtol(tmpStr, NULL, 16);
    }
    return 0;
}

void tpm2_util_hexdump(const BYTE *data, size_t len) {

    if (!output_enabled) {
        return;
    }

    size_t i;
    for (i=0; i < len; i++) {
        printf("%02x", data[i]);
    }
}

bool tpm2_util_hexdump_file(FILE *fd, size_t len) {
    BYTE* buff = (BYTE*)malloc(len);
    if (!buff) {
        LOG_ERR("malloc() failed");
        return false;
    }

    bool res = files_read_bytes(fd, buff, len);
    if (!res) {
        LOG_ERR("Failed to read file");
        free(buff);
        return false;
    }

    tpm2_util_hexdump(buff, len);

    free(buff);
    return true;
}

bool tpm2_util_print_tpm2b_file(FILE *fd)
{
    UINT16 len;
    bool res = files_read_16(fd, &len);
    if(!res) {
        LOG_ERR("File read failed");
        return false;
    }
    return tpm2_util_hexdump_file(fd, len);
}

bool tpm2_util_is_big_endian(void) {

    uint32_t test_word;
    uint8_t *test_byte;

    test_word = 0xFF000000;
    test_byte = (uint8_t *) (&test_word);

    return test_byte[0] == 0xFF;
}

#define STRING_BYTES_ENDIAN_CONVERT(size) \
    UINT##size tpm2_util_endian_swap_##size(UINT##size data) { \
    \
        UINT##size converted; \
        UINT8 *bytes = (UINT8 *)&data; \
        UINT8 *tmp = (UINT8 *)&converted; \
    \
        size_t i; \
        for(i=0; i < sizeof(UINT##size); i ++) { \
            tmp[i] = bytes[sizeof(UINT##size) - i - 1]; \
        } \
        \
        return converted; \
    }

STRING_BYTES_ENDIAN_CONVERT(16)
STRING_BYTES_ENDIAN_CONVERT(32)
STRING_BYTES_ENDIAN_CONVERT(64)

#define STRING_BYTES_ENDIAN_HTON(size) \
    UINT##size tpm2_util_hton_##size(UINT##size data) { \
    \
        bool is_big_endian = tpm2_util_is_big_endian(); \
        if (is_big_endian) { \
           return data; \
        } \
    \
        return tpm2_util_endian_swap_##size(data); \
    }

STRING_BYTES_ENDIAN_HTON(16)
STRING_BYTES_ENDIAN_HTON(32)
STRING_BYTES_ENDIAN_HTON(64)

/*
 * Converting from host-to-network (hton) or network-to-host (ntoh) is
 * the same operation: if endianess differs between host and data, swap
 * endianess. Thus we can just call the hton routines, but have some nice
 * names for folks.
 */
UINT16 tpm2_util_ntoh_16(UINT16 data) {
    return tpm2_util_hton_16(data);
}

UINT32 tpm2_util_ntoh_32(UINT32 data) {
    return tpm2_util_hton_32(data);
}
UINT64 tpm2_util_ntoh_64(UINT64 data) {
    return tpm2_util_hton_64(data);
}

UINT32 tpm2_util_pop_count(UINT32 data) {

    static const UINT8 bits_per_nibble[] =
        {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4};

    UINT8 count = 0;
    UINT8 *d = (UINT8 *)&data;

    size_t i;
    for (i=0; i < sizeof(data); i++) {
        count += bits_per_nibble[d[i] & 0x0f];
        count += bits_per_nibble[d[i] >> 4];
    }

    return count;
}

#define TPM2_UTIL_KEYDATA_INIT { .len = 0 };

typedef struct tpm2_util_keydata tpm2_util_keydata;
struct tpm2_util_keydata {
    UINT16 len;
    struct {
        const char *name;
        TPM2B *value;
    } entries[2];
};

static void tpm2_util_public_to_keydata(TPM2B_PUBLIC *public, tpm2_util_keydata *keydata) {

    switch (public->publicArea.type) {
    case TPM2_ALG_RSA:
        keydata->len = 1;
        keydata->entries[0].name = tpm2_alg_util_algtostr(public->publicArea.type, tpm2_alg_util_flags_any);
        keydata->entries[0].value = (TPM2B *)&public->publicArea.unique.rsa;
        return;
    case TPM2_ALG_KEYEDHASH:
        keydata->len = 1;
        keydata->entries[0].name = tpm2_alg_util_algtostr(public->publicArea.type, tpm2_alg_util_flags_any);
        keydata->entries[0].value = (TPM2B *)&public->publicArea.unique.keyedHash;
        return;
    case TPM2_ALG_SYMCIPHER:
        keydata->len = 1;
        keydata->entries[0].name = tpm2_alg_util_algtostr(public->publicArea.type, tpm2_alg_util_flags_any);
        keydata->entries[0].value = (TPM2B *)&public->publicArea.unique.sym;
        return;
    case TPM2_ALG_ECC:
        keydata->len = 2;
        keydata->entries[0].name = "x";
        keydata->entries[0].value = (TPM2B *)&public->publicArea.unique.ecc.x;
        keydata->entries[1].name = "y";
        keydata->entries[1].value = (TPM2B *)&public->publicArea.unique.ecc.y;
        return;
    default:
        LOG_WARN("The algorithm type(0x%4.4x) is not supported",
                public->publicArea.type);
    }

    return;
}

void print_yaml_indent(size_t indent_count) {
    while (indent_count--) {
        tpm2_tool_output("  ");
    }
}

void tpm2_util_tpma_object_to_yaml(TPMA_OBJECT obj, char *indent) {

    if (!indent) {
        indent = "";
    }

    char *attrs = tpm2_attr_util_obj_attrtostr(obj);
    tpm2_tool_output("%sattributes:\n", indent);
    tpm2_tool_output("%s  value: %s\n", indent, attrs);
    tpm2_tool_output("%s  raw: 0x%x\n", indent, obj);
    free(attrs);
}

static void print_alg_raw(const char *name, TPM2_ALG_ID alg, const char *indent) {

    tpm2_tool_output("%s%s:\n", indent, name);
    tpm2_tool_output("%s  value: %s\n", indent, tpm2_alg_util_algtostr(alg, tpm2_alg_util_flags_any));
    tpm2_tool_output("%s  raw: 0x%x\n", indent, alg);
}

static void print_scheme_common(TPMI_ALG_RSA_SCHEME scheme, const char *indent) {
    print_alg_raw("scheme", scheme, indent);
}

static void print_sym(TPMT_SYM_DEF_OBJECT *sym, const char *indent) {

    print_alg_raw("sym-alg", sym->algorithm, indent);
    print_alg_raw("sym-mode", sym->mode.sym, indent);
    tpm2_tool_output("%ssym-keybits: %u\n", indent, sym->keyBits.sym);
}

static void print_rsa_scheme(TPMT_RSA_SCHEME *scheme, const char *indent) {

    print_scheme_common(scheme->scheme, indent);

    /*
     * everything is a union on a hash algorithm except for RSAES which
     * has nothing. So on RSAES skip the hash algorithm printing
     */
    if (scheme->scheme != TPM2_ALG_RSAES) {
        print_alg_raw("scheme-halg", scheme->details.oaep.hashAlg, indent);
    }
}

static void print_ecc_scheme(TPMT_ECC_SCHEME *scheme, const char *indent) {

    print_scheme_common(scheme->scheme, indent);

    /*
     * everything but ecdaa uses only hash alg
     * in a union, so we only need to do things differently
     * for ecdaa.
     */
    print_alg_raw("scheme-halg", scheme->details.oaep.hashAlg, indent);

    if (scheme->scheme == TPM2_ALG_ECDAA) {
        tpm2_tool_output("%sscheme-count: %u\n", indent, scheme->details.ecdaa.count);
    }
}

static void print_kdf_scheme(TPMT_KDF_SCHEME *kdf, const char *indent) {

    print_alg_raw("kdfa-alg", kdf->scheme, indent);

    /*
     * The hash algorithm for the KDFA is in a union, just grab one of them.
     */
    print_alg_raw("kdfa-halg", kdf->details.mgf1.hashAlg, indent);
}

void tpm2_util_public_to_yaml(TPM2B_PUBLIC *public, char *indent) {

    if (!indent) {
        indent = "";
    }

    tpm2_tool_output("%sname-alg:\n", indent);
    tpm2_tool_output("%s  value: %s\n", indent, tpm2_alg_util_algtostr(public->publicArea.nameAlg, tpm2_alg_util_flags_any));
    tpm2_tool_output("%s  raw: 0x%x\n", indent, public->publicArea.nameAlg);

    tpm2_util_tpma_object_to_yaml(public->publicArea.objectAttributes, indent);

    tpm2_tool_output("%stype:\n", indent);
    tpm2_tool_output("%s  value: %s\n", indent, tpm2_alg_util_algtostr(public->publicArea.type, tpm2_alg_util_flags_any));
    tpm2_tool_output("%s  raw: 0x%x\n", indent, public->publicArea.type);

    switch(public->publicArea.type) {
    case TPM2_ALG_SYMCIPHER: {
        TPMS_SYMCIPHER_PARMS *s = &public->publicArea.parameters.symDetail;
        print_sym(&s->sym, indent);
    } break;
    case TPM2_ALG_KEYEDHASH: {
        TPMS_KEYEDHASH_PARMS *k = &public->publicArea.parameters.keyedHashDetail;
        tpm2_tool_output("%salgorithm: \n", indent);
        tpm2_tool_output("%s  value: %s\n", indent, tpm2_alg_util_algtostr(k->scheme.scheme, tpm2_alg_util_flags_any));
        tpm2_tool_output("%s  raw: 0x%x\n", indent, k->scheme.scheme);

        if (k->scheme.scheme == TPM2_ALG_HMAC) {
            tpm2_tool_output("%shash-alg:\n", indent);
            tpm2_tool_output("%s  value: %s\n", indent, tpm2_alg_util_algtostr(k->scheme.details.hmac.hashAlg, tpm2_alg_util_flags_any));
            tpm2_tool_output("%s  raw: 0x%x\n", indent, k->scheme.details.hmac.hashAlg);
        } else if (k->scheme.scheme == TPM2_ALG_XOR) {
            tpm2_tool_output("%shash-alg:\n", indent);
            tpm2_tool_output("%s  value: %s\n", indent, tpm2_alg_util_algtostr(k->scheme.details.exclusiveOr.hashAlg, tpm2_alg_util_flags_any));
            tpm2_tool_output("%s  raw: 0x%x\n", indent, k->scheme.details.exclusiveOr.hashAlg);

            tpm2_tool_output("%skdfa-alg:\n", indent);
            tpm2_tool_output("%s  value: %s\n", indent, tpm2_alg_util_algtostr(k->scheme.details.exclusiveOr.kdf, tpm2_alg_util_flags_any));
            tpm2_tool_output("%s  raw: 0x%x\n", indent, k->scheme.details.exclusiveOr.kdf);
        }

    } break;
    case TPM2_ALG_RSA: {
        TPMS_RSA_PARMS *r = &public->publicArea.parameters.rsaDetail;
        tpm2_tool_output("%sexponent: 0x%x\n", indent, r->exponent);
        tpm2_tool_output("%sbits: %u\n", indent, r->keyBits);

        print_rsa_scheme(&r->scheme, indent);

        print_sym(&r->symmetric, indent);
    } break;
    case TPM2_ALG_ECC: {
        TPMS_ECC_PARMS *e = &public->publicArea.parameters.eccDetail;

        tpm2_tool_output("%scurve-id:\n", indent);
        tpm2_tool_output("%s  value: %s\n", indent, tpm2_alg_util_ecc_to_str(e->curveID));
        tpm2_tool_output("%s  raw: 0x%x\n", indent, e->curveID);

        print_kdf_scheme(&e->kdf, indent);

        print_ecc_scheme(&e->scheme, indent);

        print_sym(&e->symmetric, indent);
    } break;
    }

    tpm2_util_keydata keydata = TPM2_UTIL_KEYDATA_INIT;
    tpm2_util_public_to_keydata(public, &keydata);

    UINT16 i;
    /* if no keydata len will be 0 and it wont print */
    for (i=0; i < keydata.len; i++) {
        tpm2_tool_output("%s%s: ", indent, keydata.entries[i].name);
        tpm2_util_print_tpm2b(keydata.entries[i].value);
        tpm2_tool_output("%s\n", indent);
    }

    if (public->publicArea.authPolicy.size) {
        tpm2_tool_output("%sauthorization policy: ", indent);
        tpm2_util_hexdump(public->publicArea.authPolicy.buffer,
                public->publicArea.authPolicy.size);
        tpm2_tool_output("%s\n", indent);
    }
}

tpm2_object_load_rc tpm2_util_object_load(ESYS_CONTEXT *ctx,
                        const char *objectstr, tpm2_loaded_object *outobject) {

    // 0. If objecstr is NULL return error
    if (!objectstr) {
        LOG_ERR("tpm2_util_object_load called with empty objectstr parameter");
        return olrc_error;
    }

    tpm2_object_load_rc olrc;

    // 1. If the objectstr starts with a file: prefix, treat as a context file
    bool starts_with_file = !strncmp(objectstr, FILE_PREFIX, FILE_PREFIX_LEN);
    if (starts_with_file) {
        outobject->path = objectstr += FILE_PREFIX_LEN;
        olrc = olrc_file;
    } else {
        // 2. Try to load objectstr as a TPM2_HANDLE
        bool loaded = tpm2_util_string_to_uint32(objectstr,
                        &outobject->handle);
        if (loaded) {
            // we have a handle
            outobject->path = NULL;
            outobject->tr_handle = 0;
            olrc = olrc_handle;
        } else {
            // we must assume this is a file path
            outobject->path = objectstr;
            olrc = olrc_file;
        }
    }

    // 3. if we have a context file, attempt to load it into the TPM
    if (olrc == olrc_file) {
        bool loaded = files_load_tpm_context_from_path(ctx,
                       &outobject->tr_handle, outobject->path);
        if (!loaded) {
            LOG_ERR("Could not load context file at path: \"%s\"", objectstr);
            olrc = olrc_error;
        }
    }

    return olrc;
}

bool tpm2_util_calc_unique(TPMI_ALG_HASH name_alg, TPM2B_PRIVATE_VENDOR_SPECIFIC *key,
        TPM2B_DIGEST *seed, TPM2B_DIGEST *unique_data) {

    TPM2B_MAX_BUFFER buf = { .size = key->size + seed->size };
    if (buf.size > sizeof(buf.buffer)) {
        LOG_ERR("Seed and key size are too big");
        return false;
    }

    memcpy(buf.buffer, seed->buffer, seed->size);
    memcpy(&buf.buffer[seed->size], key->buffer,
        key->size);

    digester d = tpm2_openssl_halg_to_digester(name_alg);
    if (!d) {
        return false;
    }

    unique_data->size = tpm2_alg_util_get_hash_size(name_alg);
    d(buf.buffer, buf.size, unique_data->buffer);

    return true;
}

bool tpm2_util_sys_handle_to_esys_handle(ESYS_CONTEXT *context,
        TPM2_HANDLE sys_handle, ESYS_TR *esys_handle) {

    TSS2_RC ret = Esys_TR_FromTPMPublic(context, sys_handle,
                    ESYS_TR_NONE, ESYS_TR_NONE, ESYS_TR_NONE, esys_handle);
    if (ret != TSS2_RC_SUCCESS) {
        LOG_PERR(Esys_TR_FromTPMPublic, ret);
        return false;
    }

    return true;
}

bool tpm2_util_esys_handle_to_sys_handle(ESYS_CONTEXT *context,
        ESYS_TR esys_handle, TPM2_HANDLE *sys_handle) {

    bool result = true;
    TPM2B_NAME *loaded_name;

    TSS2_RC rval = Esys_TR_GetName(context, esys_handle, &loaded_name);
    if (rval != TPM2_RC_SUCCESS) {
        LOG_PERR(Esys_TR_GetName, rval);
        result = false;
        goto outname;
    }

    size_t offset = 0;
    TPM2_HANDLE hndl;
    // TODO: this doesn't produce handles that _look_ right
    rval = Tss2_MU_TPM2_HANDLE_Unmarshal(loaded_name->name, loaded_name->size,
                &offset, &hndl);
    if (rval != TPM2_RC_SUCCESS) {
        LOG_PERR(Tss2_MU_TPM2_HANDLE_Unmarshal, rval);
        result = false;
        goto outname;
    }

    *sys_handle = hndl;

outname:
    free(loaded_name);

    return result;
}

redpajama_set_name: RedPajamaGithub


Power Chord is the story of one man's epic pilgrimage to gain rock enlightenment from the gods and guitar heroes of the Golden Age of heavy metal. Author Scott McKenzie set off to make contact with the legendary metal superstars he worshipped in his rural Kentucky youth—men like George Lynch of Dokken, Glen Tipton of Judas Priest, and Ace Frehley of KISS—hoping to gain wisdom and a better understanding of the electric guitar mystique. The result is a veritable treasure trove of enthralling behind-the-scenes stories and "where are they now" revelations that will delight anyone who has ever felt a Mötley Crüe, Guns 'N' Roses, or Black Sabbath song reach out from the speakers and grab them by the ears.


text:
Q: Google+ PlusClient getCurrentLocation() method I see that the Person object that can be retrieved from the loadPerson method of PlusClient has a getCurrentLocation() method. For some reason I do not see the getCurrentLocation() method in the documentation online. Also, when I try to use it, it returns null always. What's the deal with this function?

A: getCurrentLocation is documented under the Person object:
http://developer.android.com/reference/com/google/android/gms/plus/model/people/Person.html#getCurrentLocation()
It returns the users current location if they have set it to a value on their Google+ profile.  It will return null if they have not set it to a value.

A: So I hate to be the bearer of bad news on this one, but it seems like Google+ has stopped support for the getCurrentLocation part of their People api. There's a whole thread here about complaints concerning it.
EDIT: Figured out a workaround to the problem. I guess they just put everything in the getplaceslived method.
String location = "";
for(PlacesLived place : Plus.PeopleApi.getCurrentPerson(mGoogleApiClient).getPlacesLived()){
        //If the place is primary, record it and break
        if(place.isPrimary()){
            location = place.getValue();
            break;
        }
        //If it isn't and there isn't any location yet, record the most recent location and wait to see if another is primary
        if(location.equals("")){
            location = place.getValue();
        }
    }


text:
Q: How to compose query properly using dbGetQuery command? I have a small database in PostgresSQL. And I connected to it via R-studio and try to retrieve data from database.
I wrote a command, but it doesn't work. And I don't know what's the problem. Please, help me.
So, the code works well.
data1 <- dbGetQuery(con, "select  a.date from bank_schema.ratios_135 a")

But these two codes fail
data1 <- dbGetQuery(con, "select a.'n1.2' from bank_schema.ratios_135 a")
data1 <- dbGetQuery(con, "select a.REGN from bank_schema.ratios_135 a")

Where con is the postgres connection object.
And of course query with any combination of these vars gives an error.
I would be thankful to all of you if you help me.

A: You need to properly quote the odd names:
data1 <- dbGetQuery(con, 'select a."n1.2" from bank_schema.ratios_135 a')
data2 <- dbGetQuery(con, 'select a."REGN" from bank_schema.ratios_135 a')

Single quotes in PostgreSQL are used to create a text string, double quotes are used to name an identifier without changing its case.


text:
#ifndef _CPU_PISMMCPUDXESMM_H_
#define _CPU_PISMMCPUDXESMM_H_

#include <PiSmm.h>

#include <Protocol/MpService.h>
#include <Protocol/SmmConfiguration.h>
#include <Protocol/SmmCpu.h>
#include <Protocol/SmmAccess2.h>
#include <Protocol/SmmReadyToLock.h>
#include <Protocol/SmmCpuService.h>
#include <Protocol/SmmMemoryAttribute.h>

#include <Guid/AcpiS3Context.h>
#include <Guid/MemoryAttributesTable.h>
#include <Guid/PiSmmMemoryAttributesTable.h>

#include <Library/BaseLib.h>
#include <Library/IoLib.h>
#include <Library/TimerLib.h>
#include <Library/SynchronizationLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/PcdLib.h>
#include <Library/MtrrLib.h>
#include <Library/SmmCpuPlatformHookLib.h>
#include <Library/SmmServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/DebugAgentLib.h>
#include <Library/UefiLib.h>
#include <Library/HobLib.h>
#include <Library/LocalApicLib.h>
#include <Library/UefiCpuLib.h>
#include <Library/CpuExceptionHandlerLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <Library/SmmCpuFeaturesLib.h>
#include <Library/PeCoffGetEntryPointLib.h>
#include <Library/RegisterCpuFeaturesLib.h>

#include <AcpiCpuData.h>
#include <CpuHotPlugData.h>

#include <Register/Cpuid.h>
#include <Register/Msr.h>

#include "CpuService.h"
#include "SmmProfile.h"

//
// CET definition
//
#define CPUID_CET_SS   BIT7
#define CPUID_CET_IBT  BIT20

#define CR4_CET_ENABLE  BIT23

#define MSR_IA32_S_CET                     0x6A2
#define MSR_IA32_PL0_SSP                   0x6A4
#define MSR_IA32_INTERRUPT_SSP_TABLE_ADDR  0x6A8

typedef union {
  struct {
    // enable shadow stacks
    UINT32  SH_STK_ENP:1;
    // enable the WRSS{D,Q}W instructions.
    UINT32  WR_SHSTK_EN:1;
    // enable tracking of indirect call/jmp targets to be ENDBRANCH instruction.
    UINT32  ENDBR_EN:1;
    // enable legacy compatibility treatment for indirect call/jmp tracking.
    UINT32  LEG_IW_EN:1;
    // enable use of no-track prefix on indirect call/jmp.
    UINT32  NO_TRACK_EN:1;
    // disable suppression of CET indirect branch tracking on legacy compatibility.
    UINT32  SUPPRESS_DIS:1;
    UINT32  RSVD:4;
    // indirect branch tracking is suppressed.
    // This bit can be written to 1 only if TRACKER is written as IDLE.
    UINT32  SUPPRESS:1;
    // Value of the endbranch state machine
    // Values: IDLE (0), WAIT_FOR_ENDBRANCH(1).
    UINT32  TRACKER:1;
    // linear address of a bitmap in memory indicating valid
    // pages as target of CALL/JMP_indirect that do not land on ENDBRANCH when CET is enabled
    // and not suppressed. Valid when ENDBR_EN is 1. Must be machine canonical when written on
    // parts that support 64 bit mode. On parts that do not support 64 bit mode, the bits 63:32 are
    // reserved and must be 0. This value is extended by 12 bits at the low end to form the base address
    // (this automatically aligns the address on a 4-Kbyte boundary).
    UINT32  EB_LEG_BITMAP_BASE_low:12;
    UINT32  EB_LEG_BITMAP_BASE_high:32;
  } Bits;
  UINT64   Uint64;
} MSR_IA32_CET;

//
// MSRs required for configuration of SMM Code Access Check
//
#define EFI_MSR_SMM_MCA_CAP                    0x17D
#define  SMM_CODE_ACCESS_CHK_BIT               BIT58

#define  SMM_FEATURE_CONTROL_LOCK_BIT          BIT0
#define  SMM_CODE_CHK_EN_BIT                   BIT2

///
/// Page Table Entry
///
#define IA32_PG_P                   BIT0
#define IA32_PG_RW                  BIT1
#define IA32_PG_U                   BIT2
#define IA32_PG_WT                  BIT3
#define IA32_PG_CD                  BIT4
#define IA32_PG_A                   BIT5
#define IA32_PG_D                   BIT6
#define IA32_PG_PS                  BIT7
#define IA32_PG_PAT_2M              BIT12
#define IA32_PG_PAT_4K              IA32_PG_PS
#define IA32_PG_PMNT                BIT62
#define IA32_PG_NX                  BIT63

#define PAGE_ATTRIBUTE_BITS         (IA32_PG_D | IA32_PG_A | IA32_PG_U | IA32_PG_RW | IA32_PG_P)
//
// Bits 1, 2, 5, 6 are reserved in the IA32 PAE PDPTE
// X64 PAE PDPTE does not have such restriction
//
#define IA32_PAE_PDPTE_ATTRIBUTE_BITS    (IA32_PG_P)

#define PAGE_PROGATE_BITS           (IA32_PG_NX | PAGE_ATTRIBUTE_BITS)

#define PAGING_4K_MASK  0xFFF
#define PAGING_2M_MASK  0x1FFFFF
#define PAGING_1G_MASK  0x3FFFFFFF

#define PAGING_PAE_INDEX_MASK  0x1FF

#define PAGING_4K_ADDRESS_MASK_64 0x000FFFFFFFFFF000ull
#define PAGING_2M_ADDRESS_MASK_64 0x000FFFFFFFE00000ull
#define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull

#define SMRR_MAX_ADDRESS       BASE_4GB

typedef enum {
  PageNone,
  Page4K,
  Page2M,
  Page1G,
} PAGE_ATTRIBUTE;

typedef struct {
  PAGE_ATTRIBUTE   Attribute;
  UINT64           Length;
  UINT64           AddressMask;
} PAGE_ATTRIBUTE_TABLE;

//
// Size of Task-State Segment defined in IA32 Manual
//
#define TSS_SIZE              104
#define EXCEPTION_TSS_SIZE    (TSS_SIZE + 4) // Add 4 bytes SSP
#define TSS_X64_IST1_OFFSET   36
#define TSS_IA32_CR3_OFFSET   28
#define TSS_IA32_ESP_OFFSET   56
#define TSS_IA32_SSP_OFFSET   104

#define CR0_WP                BIT16

//
// Code select value
//
#define PROTECT_MODE_CODE_SEGMENT          0x08
#define LONG_MODE_CODE_SEGMENT             0x38

//
// The size 0x20 must be bigger than
// the size of template code of SmmInit. Currently,
// the size of SmmInit requires the 0x16 Bytes buffer
// at least.
//
#define BACK_BUF_SIZE  0x20

#define EXCEPTION_VECTOR_NUMBER     0x20

#define INVALID_APIC_ID 0xFFFFFFFFFFFFFFFFULL

typedef UINT32                              SMM_CPU_ARRIVAL_EXCEPTIONS;
#define ARRIVAL_EXCEPTION_BLOCKED           0x1
#define ARRIVAL_EXCEPTION_DELAYED           0x2
#define ARRIVAL_EXCEPTION_SMI_DISABLED      0x4

//
// Private structure for the SMM CPU module that is stored in DXE Runtime memory
// Contains the SMM Configuration Protocols that is produced.
// Contains a mix of DXE and SMM contents.  All the fields must be used properly.
//
#define SMM_CPU_PRIVATE_DATA_SIGNATURE  SIGNATURE_32 ('s', 'c', 'p', 'u')

typedef struct {
  UINTN                           Signature;

  EFI_HANDLE                      SmmCpuHandle;

  EFI_PROCESSOR_INFORMATION       *ProcessorInfo;
  SMM_CPU_OPERATION               *Operation;
  UINTN                           *CpuSaveStateSize;
  VOID                            **CpuSaveState;

  EFI_SMM_RESERVED_SMRAM_REGION   SmmReservedSmramRegion[1];
  EFI_SMM_ENTRY_CONTEXT           SmmCoreEntryContext;
  EFI_SMM_ENTRY_POINT             SmmCoreEntry;

  EFI_SMM_CONFIGURATION_PROTOCOL  SmmConfiguration;
} SMM_CPU_PRIVATE_DATA;

extern SMM_CPU_PRIVATE_DATA  *gSmmCpuPrivate;
extern CPU_HOT_PLUG_DATA      mCpuHotPlugData;
extern UINTN                  mMaxNumberOfCpus;
extern UINTN                  mNumberOfCpus;
extern EFI_SMM_CPU_PROTOCOL   mSmmCpu;

///
/// The mode of the CPU at the time an SMI occurs
///
extern UINT8  mSmmSaveStateRegisterLma;

//
// SMM CPU Protocol function prototypes.
//

/**
  Read information from the CPU save state.

  @param  This      EFI_SMM_CPU_PROTOCOL instance
  @param  Width     The number of bytes to read from the CPU save state.
  @param  Register  Specifies the CPU register to read form the save state.
  @param  CpuIndex  Specifies the zero-based index of the CPU save state
  @param  Buffer    Upon return, this holds the CPU register value read from the save state.

  @retval EFI_SUCCESS   The register was read from Save State
  @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor
  @retval EFI_INVALID_PARAMTER   This or Buffer is NULL.

**/
EFI_STATUS
EFIAPI
SmmReadSaveState (
  IN CONST EFI_SMM_CPU_PROTOCOL         *This,
  IN UINTN                              Width,
  IN EFI_SMM_SAVE_STATE_REGISTER        Register,
  IN UINTN                              CpuIndex,
  OUT VOID                              *Buffer
  );

/**
  Write data to the CPU save state.

  @param  This      EFI_SMM_CPU_PROTOCOL instance
  @param  Width     The number of bytes to read from the CPU save state.
  @param  Register  Specifies the CPU register to write to the save state.
  @param  CpuIndex  Specifies the zero-based index of the CPU save state
  @param  Buffer    Upon entry, this holds the new CPU register value.

  @retval EFI_SUCCESS   The register was written from Save State
  @retval EFI_NOT_FOUND The register is not defined for the Save State of Processor
  @retval EFI_INVALID_PARAMTER   ProcessorIndex or Width is not correct

**/
EFI_STATUS
EFIAPI
SmmWriteSaveState (
  IN CONST EFI_SMM_CPU_PROTOCOL         *This,
  IN UINTN                              Width,
  IN EFI_SMM_SAVE_STATE_REGISTER        Register,
  IN UINTN                              CpuIndex,
  IN CONST VOID                         *Buffer
  );

/**
Read a CPU Save State register on the target processor.

This function abstracts the differences that whether the CPU Save State register is in the
IA32 CPU Save State Map or X64 CPU Save State Map.

This function supports reading a CPU Save State register in SMBase relocation handler.

@param[in]  CpuIndex       Specifies the zero-based index of the CPU save state.
@param[in]  RegisterIndex  Index into mSmmCpuWidthOffset[] look up table.
@param[in]  Width          The number of bytes to read from the CPU save state.
@param[out] Buffer         Upon return, this holds the CPU register value read from the save state.

@retval EFI_SUCCESS           The register was read from Save State.
@retval EFI_NOT_FOUND         The register is not defined for the Save State of Processor.
@retval EFI_INVALID_PARAMTER  This or Buffer is NULL.

**/
EFI_STATUS
EFIAPI
ReadSaveStateRegister (
  IN UINTN                        CpuIndex,
  IN EFI_SMM_SAVE_STATE_REGISTER  Register,
  IN UINTN                        Width,
  OUT VOID                        *Buffer
  );

/**
Write value to a CPU Save State register on the target processor.

This function abstracts the differences that whether the CPU Save State register is in the
IA32 CPU Save State Map or X64 CPU Save State Map.

This function supports writing a CPU Save State register in SMBase relocation handler.

@param[in] CpuIndex       Specifies the zero-based index of the CPU save state.
@param[in] RegisterIndex  Index into mSmmCpuWidthOffset[] look up table.
@param[in] Width          The number of bytes to read from the CPU save state.
@param[in] Buffer         Upon entry, this holds the new CPU register value.

@retval EFI_SUCCESS           The register was written to Save State.
@retval EFI_NOT_FOUND         The register is not defined for the Save State of Processor.
@retval EFI_INVALID_PARAMTER  ProcessorIndex or Width is not correct.

**/
EFI_STATUS
EFIAPI
WriteSaveStateRegister (
  IN UINTN                        CpuIndex,
  IN EFI_SMM_SAVE_STATE_REGISTER  Register,
  IN UINTN                        Width,
  IN CONST VOID                   *Buffer
  );

extern CONST UINT8                  gcSmmInitTemplate[];
extern CONST UINT16                 gcSmmInitSize;
X86_ASSEMBLY_PATCH_LABEL            gPatchSmmCr0;
extern UINT32                       mSmmCr0;
X86_ASSEMBLY_PATCH_LABEL            gPatchSmmCr3;
extern UINT32                       mSmmCr4;
X86_ASSEMBLY_PATCH_LABEL            gPatchSmmCr4;
X86_ASSEMBLY_PATCH_LABEL            gPatchSmmInitStack;
X86_ASSEMBLY_PATCH_LABEL            mPatchCetSupported;
extern BOOLEAN                      mCetSupported;

/**
  Semaphore operation for all processor relocate SMMBase.
**/
VOID
EFIAPI
SmmRelocationSemaphoreComplete (
  VOID
  );

///
/// The type of SMM CPU Information
///
typedef struct {
  SPIN_LOCK                         *Busy;
  volatile EFI_AP_PROCEDURE         Procedure;
  volatile VOID                     *Parameter;
  volatile UINT32                   *Run;
  volatile BOOLEAN                  *Present;
} SMM_CPU_DATA_BLOCK;

typedef enum {
  SmmCpuSyncModeTradition,
  SmmCpuSyncModeRelaxedAp,
  SmmCpuSyncModeMax
} SMM_CPU_SYNC_MODE;

typedef struct {
  //
  // Pointer to an array. The array should be located immediately after this structure
  // so that UC cache-ability can be set together.
  //
  SMM_CPU_DATA_BLOCK            *CpuData;
  volatile UINT32               *Counter;
  volatile UINT32               BspIndex;
  volatile BOOLEAN              *InsideSmm;
  volatile BOOLEAN              *AllCpusInSync;
  volatile SMM_CPU_SYNC_MODE    EffectiveSyncMode;
  volatile BOOLEAN              SwitchBsp;
  volatile BOOLEAN              *CandidateBsp;
} SMM_DISPATCHER_MP_SYNC_DATA;

#define SMM_PSD_OFFSET              0xfb00

///
/// All global semaphores' pointer
///
typedef struct {
  volatile UINT32      *Counter;
  volatile BOOLEAN     *InsideSmm;
  volatile BOOLEAN     *AllCpusInSync;
  SPIN_LOCK            *PFLock;
  SPIN_LOCK            *CodeAccessCheckLock;
} SMM_CPU_SEMAPHORE_GLOBAL;

///
/// All semaphores for each processor
///
typedef struct {
  SPIN_LOCK                         *Busy;
  volatile UINT32                   *Run;
  volatile BOOLEAN                  *Present;
} SMM_CPU_SEMAPHORE_CPU;

///
/// All semaphores' information
///
typedef struct {
  SMM_CPU_SEMAPHORE_GLOBAL          SemaphoreGlobal;
  SMM_CPU_SEMAPHORE_CPU             SemaphoreCpu;
} SMM_CPU_SEMAPHORES;

extern IA32_DESCRIPTOR                     gcSmiGdtr;
extern EFI_PHYSICAL_ADDRESS                mGdtBuffer;
extern UINTN                               mGdtBufferSize;
extern IA32_DESCRIPTOR                     gcSmiIdtr;
extern VOID                                *gcSmiIdtrPtr;
extern UINT64                              gPhyMask;
extern SMM_DISPATCHER_MP_SYNC_DATA         *mSmmMpSyncData;
extern UINTN                               mSmmStackArrayBase;
extern UINTN                               mSmmStackArrayEnd;
extern UINTN                               mSmmStackSize;
extern EFI_SMM_CPU_SERVICE_PROTOCOL        mSmmCpuService;
extern IA32_DESCRIPTOR                     gcSmiInitGdtr;
extern SMM_CPU_SEMAPHORES                  mSmmCpuSemaphores;
extern UINTN                               mSemaphoreSize;
extern SPIN_LOCK                           *mPFLock;
extern SPIN_LOCK                           *mConfigSmmCodeAccessCheckLock;
extern EFI_SMRAM_DESCRIPTOR                *mSmmCpuSmramRanges;
extern UINTN                               mSmmCpuSmramRangeCount;
extern UINT8                               mPhysicalAddressBits;

//
// Copy of the PcdPteMemoryEncryptionAddressOrMask
//
extern UINT64  mAddressEncMask;

/**
  Create 4G PageTable in SMRAM.

  @param[in]      Is32BitPageTable Whether the page table is 32-bit PAE
  @return         PageTable Address

**/
UINT32
Gen4GPageTable (
  IN      BOOLEAN                   Is32BitPageTable
  );

/**
  Initialize global data for MP synchronization.

  @param Stacks             Base address of SMI stack buffer for all processors.
  @param StackSize          Stack size for each processor in SMM.
  @param ShadowStackSize    Shadow Stack size for each processor in SMM.

**/
UINT32
InitializeMpServiceData (
  IN VOID        *Stacks,
  IN UINTN       StackSize,
  IN UINTN       ShadowStackSize
  );

/**
  Initialize Timer for SMM AP Sync.

**/
VOID
InitializeSmmTimer (
  VOID
  );

/**
  Start Timer for SMM AP Sync.

**/
UINT64
EFIAPI
StartSyncTimer (
  VOID
  );

/**
  Check if the SMM AP Sync timer is timeout.

  @param Timer  The start timer from the begin.

**/
BOOLEAN
EFIAPI
IsSyncTimerTimeout (
  IN      UINT64                    Timer
  );

/**
  Initialize IDT for SMM Stack Guard.

**/
VOID
EFIAPI
InitializeIDTSmmStackGuard (
  VOID
  );

/**
  Initialize Gdt for all processors.

  @param[in]   Cr3          CR3 value.
  @param[out]  GdtStepSize  The step size for GDT table.

  @return GdtBase for processor 0.
          GdtBase for processor X is: GdtBase + (GdtStepSize * X)
**/
VOID *
InitGdt (
  IN  UINTN  Cr3,
  OUT UINTN  *GdtStepSize
  );

/**

  Register the SMM Foundation entry point.

  @param          This              Pointer to EFI_SMM_CONFIGURATION_PROTOCOL instance
  @param          SmmEntryPoint     SMM Foundation EntryPoint

  @retval         EFI_SUCCESS       Successfully to register SMM foundation entry point

**/
EFI_STATUS
EFIAPI
RegisterSmmEntry (
  IN CONST EFI_SMM_CONFIGURATION_PROTOCOL  *This,
  IN EFI_SMM_ENTRY_POINT                   SmmEntryPoint
  );

/**
  Create PageTable for SMM use.

  @return     PageTable Address

**/
UINT32
SmmInitPageTable (
  VOID
  );

/**
  Schedule a procedure to run on the specified CPU.

  @param   Procedure        The address of the procedure to run
  @param   CpuIndex         Target CPU number
  @param   ProcArguments    The parameter to pass to the procedure

  @retval   EFI_INVALID_PARAMETER    CpuNumber not valid
  @retval   EFI_INVALID_PARAMETER    CpuNumber specifying BSP
  @retval   EFI_INVALID_PARAMETER    The AP specified by CpuNumber did not enter SMM
  @retval   EFI_INVALID_PARAMETER    The AP specified by CpuNumber is busy
  @retval   EFI_SUCCESS - The procedure has been successfully scheduled

**/
EFI_STATUS
EFIAPI
SmmStartupThisAp (
  IN      EFI_AP_PROCEDURE          Procedure,
  IN      UINTN                     CpuIndex,
  IN OUT  VOID                      *ProcArguments OPTIONAL
  );

/**
  Schedule a procedure to run on the specified CPU in a blocking fashion.

  @param  Procedure                The address of the procedure to run
  @param  CpuIndex                 Target CPU Index
  @param  ProcArguments            The parameter to pass to the procedure

  @retval EFI_INVALID_PARAMETER    CpuNumber not valid
  @retval EFI_INVALID_PARAMETER    CpuNumber specifying BSP
  @retval EFI_INVALID_PARAMETER    The AP specified by CpuNumber did not enter SMM
  @retval EFI_INVALID_PARAMETER    The AP specified by CpuNumber is busy
  @retval EFI_SUCCESS              The procedure has been successfully scheduled

**/
EFI_STATUS
EFIAPI
SmmBlockingStartupThisAp (
  IN      EFI_AP_PROCEDURE          Procedure,
  IN      UINTN                     CpuIndex,
  IN OUT  VOID                      *ProcArguments OPTIONAL
  );

/**
  This function sets the attributes for the memory region specified by BaseAddress and
  Length from their current attributes to the attributes specified by Attributes.

  @param[in]  BaseAddress      The physical address that is the start address of a memory region.
  @param[in]  Length           The size in bytes of the memory region.
  @param[in]  Attributes       The bit mask of attributes to set for the memory region.

  @retval EFI_SUCCESS           The attributes were set for the memory region.
  @retval EFI_ACCESS_DENIED     The attributes for the memory resource range specified by
                                BaseAddress and Length cannot be modified.
  @retval EFI_INVALID_PARAMETER Length is zero.
                                Attributes specified an illegal combination of attributes that
                                cannot be set together.
  @retval EFI_OUT_OF_RESOURCES  There are not enough system resources to modify the attributes of
                                the memory resource range.
  @retval EFI_UNSUPPORTED       The processor does not support one or more bytes of the memory
                                resource range specified by BaseAddress and Length.
                                The bit mask of attributes is not support for the memory resource
                                range specified by BaseAddress and Length.

**/
EFI_STATUS
EFIAPI
SmmSetMemoryAttributes (
  IN  EFI_PHYSICAL_ADDRESS                       BaseAddress,
  IN  UINT64                                     Length,
  IN  UINT64                                     Attributes
  );

/**
  This function clears the attributes for the memory region specified by BaseAddress and
  Length from their current attributes to the attributes specified by Attributes.

  @param[in]  BaseAddress      The physical address that is the start address of a memory region.
  @param[in]  Length           The size in bytes of the memory region.
  @param[in]  Attributes       The bit mask of attributes to clear for the memory region.

  @retval EFI_SUCCESS           The attributes were cleared for the memory region.
  @retval EFI_ACCESS_DENIED     The attributes for the memory resource range specified by
                                BaseAddress and Length cannot be modified.
  @retval EFI_INVALID_PARAMETER Length is zero.
                                Attributes specified an illegal combination of attributes that
                                cannot be set together.
  @retval EFI_OUT_OF_RESOURCES  There are not enough system resources to modify the attributes of
                                the memory resource range.
  @retval EFI_UNSUPPORTED       The processor does not support one or more bytes of the memory
                                resource range specified by BaseAddress and Length.
                                The bit mask of attributes is not support for the memory resource
                                range specified by BaseAddress and Length.

**/
EFI_STATUS
EFIAPI
SmmClearMemoryAttributes (
  IN  EFI_PHYSICAL_ADDRESS                       BaseAddress,
  IN  UINT64                                     Length,
  IN  UINT64                                     Attributes
  );

/**
  Initialize MP synchronization data.

**/
VOID
EFIAPI
InitializeMpSyncData (
  VOID
  );

/**

  Find out SMRAM information including SMRR base and SMRR size.

  @param          SmrrBase          SMRR base
  @param          SmrrSize          SMRR size

**/
VOID
FindSmramInfo (
  OUT UINT32   *SmrrBase,
  OUT UINT32   *SmrrSize
  );

/**
  Relocate SmmBases for each processor.

  Execute on first boot and all S3 resumes

**/
VOID
EFIAPI
SmmRelocateBases (
  VOID
  );

/**
  Page Fault handler for SMM use.

  @param  InterruptType    Defines the type of interrupt or exception that
                           occurred on the processor.This parameter is processor architecture specific.
  @param  SystemContext    A pointer to the processor context when
                           the interrupt occurred on the processor.
**/
VOID
EFIAPI
SmiPFHandler (
  IN EFI_EXCEPTION_TYPE   InterruptType,
  IN EFI_SYSTEM_CONTEXT   SystemContext
  );

/**
  Perform the remaining tasks.

**/
VOID
PerformRemainingTasks (
  VOID
  );

/**
  Perform the pre tasks.

**/
VOID
PerformPreTasks (
  VOID
  );

/**
  Initialize MSR spin lock by MSR index.

  @param  MsrIndex       MSR index value.

**/
VOID
InitMsrSpinLockByIndex (
  IN UINT32      MsrIndex
  );

/**
  Hook return address of SMM Save State so that semaphore code
  can be executed immediately after AP exits SMM to indicate to
  the BSP that an AP has exited SMM after SMBASE relocation.

  @param[in] CpuIndex     The processor index.
  @param[in] RebasedFlag  A pointer to a flag that is set to TRUE
                          immediately after AP exits SMM.

**/
VOID
SemaphoreHook (
  IN UINTN             CpuIndex,
  IN volatile BOOLEAN  *RebasedFlag
  );

/**
Configure SMM Code Access Check feature for all processors.
SMM Feature Control MSR will be locked after configuration.
**/
VOID
ConfigSmmCodeAccessCheck (
  VOID
  );

/**
  Hook the code executed immediately after an RSM instruction on the currently
  executing CPU.  The mode of code executed immediately after RSM must be
  detected, and the appropriate hook must be selected.  Always clear the auto
  HALT restart flag if it is set.

  @param[in] CpuIndex                 The processor index for the currently
                                      executing CPU.
  @param[in] CpuState                 Pointer to SMRAM Save State Map for the
                                      currently executing CPU.
  @param[in] NewInstructionPointer32  Instruction pointer to use if resuming to
                                      32-bit mode from 64-bit SMM.
  @param[in] NewInstructionPointer    Instruction pointer to use if resuming to
                                      same mode as SMM.

  @retval The value of the original instruction pointer before it was hooked.

**/
UINT64
EFIAPI
HookReturnFromSmm (
  IN UINTN              CpuIndex,
  SMRAM_SAVE_STATE_MAP  *CpuState,
  UINT64                NewInstructionPointer32,
  UINT64                NewInstructionPointer
  );

/**
  Get the size of the SMI Handler in bytes.

  @retval The size, in bytes, of the SMI Handler.

**/
UINTN
EFIAPI
GetSmiHandlerSize (
  VOID
  );

/**
  Install the SMI handler for the CPU specified by CpuIndex.  This function
  is called by the CPU that was elected as monarch during System Management
  Mode initialization.

  @param[in] CpuIndex   The index of the CPU to install the custom SMI handler.
                        The value must be between 0 and the NumberOfCpus field
                        in the System Management System Table (SMST).
  @param[in] SmBase     The SMBASE address for the CPU specified by CpuIndex.
  @param[in] SmiStack   The stack to use when an SMI is processed by the
                        the CPU specified by CpuIndex.
  @param[in] StackSize  The size, in bytes, if the stack used when an SMI is
                        processed by the CPU specified by CpuIndex.
  @param[in] GdtBase    The base address of the GDT to use when an SMI is
                        processed by the CPU specified by CpuIndex.
  @param[in] GdtSize    The size, in bytes, of the GDT used when an SMI is
                        processed by the CPU specified by CpuIndex.
  @param[in] IdtBase    The base address of the IDT to use when an SMI is
                        processed by the CPU specified by CpuIndex.
  @param[in] IdtSize    The size, in bytes, of the IDT used when an SMI is
                        processed by the CPU specified by CpuIndex.
  @param[in] Cr3        The base address of the page tables to use when an SMI
                        is processed by the CPU specified by CpuIndex.
**/
VOID
EFIAPI
InstallSmiHandler (
  IN UINTN   CpuIndex,
  IN UINT32  SmBase,
  IN VOID    *SmiStack,
  IN UINTN   StackSize,
  IN UINTN   GdtBase,
  IN UINTN   GdtSize,
  IN UINTN   IdtBase,
  IN UINTN   IdtSize,
  IN UINT32  Cr3
  );

/**
  Search module name by input IP address and output it.

  @param CallerIpAddress   Caller instruction pointer.

**/
VOID
DumpModuleInfoByIp (
  IN  UINTN              CallerIpAddress
  );

/**
  This function sets memory attribute according to MemoryAttributesTable.
**/
VOID
SetMemMapAttributes (
  VOID
  );

/**
  This function sets UEFI memory attribute according to UEFI memory map.
**/
VOID
SetUefiMemMapAttributes (
  VOID
  );

/**
  Return if the Address is forbidden as SMM communication buffer.

  @param[in] Address the address to be checked

  @return TRUE  The address is forbidden as SMM communication buffer.
  @return FALSE The address is allowed as SMM communication buffer.
**/
BOOLEAN
IsSmmCommBufferForbiddenAddress (
  IN UINT64  Address
  );

/**
  This function caches the UEFI memory map information.
**/
VOID
GetUefiMemoryMap (
  VOID
  );

/**
  This function sets memory attribute for page table.
**/
VOID
SetPageTableAttributes (
  VOID
  );

/**
  Return page table base.

  @return page table base.
**/
UINTN
GetPageTableBase (
  VOID
  );

/**
  This function sets the attributes for the memory region specified by BaseAddress and
  Length from their current attributes to the attributes specified by Attributes.

  @param[in]   BaseAddress      The physical address that is the start address of a memory region.
  @param[in]   Length           The size in bytes of the memory region.
  @param[in]   Attributes       The bit mask of attributes to set for the memory region.
  @param[out]  IsSplitted       TRUE means page table splitted. FALSE means page table not splitted.

  @retval EFI_SUCCESS           The attributes were set for the memory region.
  @retval EFI_ACCESS_DENIED     The attributes for the memory resource range specified by
                                BaseAddress and Length cannot be modified.
  @retval EFI_INVALID_PARAMETER Length is zero.
                                Attributes specified an illegal combination of attributes that
                                cannot be set together.
  @retval EFI_OUT_OF_RESOURCES  There are not enough system resources to modify the attributes of
                                the memory resource range.
  @retval EFI_UNSUPPORTED       The processor does not support one or more bytes of the memory
                                resource range specified by BaseAddress and Length.
                                The bit mask of attributes is not support for the memory resource
                                range specified by BaseAddress and Length.

**/
EFI_STATUS
EFIAPI
SmmSetMemoryAttributesEx (
  IN  EFI_PHYSICAL_ADDRESS                       BaseAddress,
  IN  UINT64                                     Length,
  IN  UINT64                                     Attributes,
  OUT BOOLEAN                                    *IsSplitted  OPTIONAL
  );

/**
  This function clears the attributes for the memory region specified by BaseAddress and
  Length from their current attributes to the attributes specified by Attributes.

  @param[in]   BaseAddress      The physical address that is the start address of a memory region.
  @param[in]   Length           The size in bytes of the memory region.
  @param[in]   Attributes       The bit mask of attributes to clear for the memory region.
  @param[out]  IsSplitted       TRUE means page table splitted. FALSE means page table not splitted.

  @retval EFI_SUCCESS           The attributes were cleared for the memory region.
  @retval EFI_ACCESS_DENIED     The attributes for the memory resource range specified by
                                BaseAddress and Length cannot be modified.
  @retval EFI_INVALID_PARAMETER Length is zero.
                                Attributes specified an illegal combination of attributes that
                                cannot be set together.
  @retval EFI_OUT_OF_RESOURCES  There are not enough system resources to modify the attributes of
                                the memory resource range.
  @retval EFI_UNSUPPORTED       The processor does not support one or more bytes of the memory
                                resource range specified by BaseAddress and Length.
                                The bit mask of attributes is not support for the memory resource
                                range specified by BaseAddress and Length.

**/
EFI_STATUS
EFIAPI
SmmClearMemoryAttributesEx (
  IN  EFI_PHYSICAL_ADDRESS                       BaseAddress,
  IN  UINT64                                     Length,
  IN  UINT64                                     Attributes,
  OUT BOOLEAN                                    *IsSplitted  OPTIONAL
  );

/**
  This API provides a way to allocate memory for page table.

  This API can be called more once to allocate memory for page tables.

  Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL
  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is
  returned.

  @param  Pages                 The number of 4 KB pages to allocate.

  @return A pointer to the allocated buffer or NULL if allocation fails.

**/
VOID *
AllocatePageTableMemory (
  IN UINTN           Pages
  );

/**
  Allocate pages for code.

  @param[in]  Pages Number of pages to be allocated.

  @return Allocated memory.
**/
VOID *
AllocateCodePages (
  IN UINTN           Pages
  );

/**
  Allocate aligned pages for code.

  @param[in]  Pages                 Number of pages to be allocated.
  @param[in]  Alignment             The requested alignment of the allocation.
                                    Must be a power of two.
                                    If Alignment is zero, then byte alignment is used.

  @return Allocated memory.
**/
VOID *
AllocateAlignedCodePages (
  IN UINTN            Pages,
  IN UINTN            Alignment
  );

//
// S3 related global variable and function prototype.
//

extern BOOLEAN                mSmmS3Flag;

/**
  Initialize SMM S3 resume state structure used during S3 Resume.

  @param[in] Cr3    The base address of the page tables to use in SMM.

**/
VOID
InitSmmS3ResumeState (
  IN UINT32  Cr3
  );

/**
  Get ACPI CPU data.

**/
VOID
GetAcpiCpuData (
  VOID
  );

/**
  Restore SMM Configuration in S3 boot path.

**/
VOID
RestoreSmmConfigurationInS3 (
  VOID
  );

/**
  Get ACPI S3 enable flag.

**/
VOID
GetAcpiS3EnableFlag (
  VOID
  );

/**
  Transfer AP to safe hlt-loop after it finished restore CPU features on S3 patch.

  @param[in] ApHltLoopCode          The address of the safe hlt-loop function.
  @param[in] TopOfStack             A pointer to the new stack to use for the ApHltLoopCode.
  @param[in] NumberToFinishAddress  Address of Semaphore of APs finish count.

**/
VOID
TransferApToSafeState (
  IN UINTN  ApHltLoopCode,
  IN UINTN  TopOfStack,
  IN UINTN  NumberToFinishAddress
  );

/**
  Set ShadowStack memory.

  @param[in]  Cr3              The page table base address.
  @param[in]  BaseAddress      The physical address that is the start address of a memory region.
  @param[in]  Length           The size in bytes of the memory region.

  @retval EFI_SUCCESS           The shadow stack memory is set.
**/
EFI_STATUS
SetShadowStack (
  IN  UINTN                                      Cr3,
  IN  EFI_PHYSICAL_ADDRESS                       BaseAddress,
  IN  UINT64                                     Length
  );

/**
  Set not present memory.

  @param[in]  Cr3              The page table base address.
  @param[in]  BaseAddress      The physical address that is the start address of a memory region.
  @param[in]  Length           The size in bytes of the memory region.

  @retval EFI_SUCCESS           The not present memory is set.
**/
EFI_STATUS
SetNotPresentPage (
  IN  UINTN                                      Cr3,
  IN  EFI_PHYSICAL_ADDRESS                       BaseAddress,
  IN  UINT64                                     Length
  );

/**
  Initialize the shadow stack related data structure.

  @param CpuIndex     The index of CPU.
  @param ShadowStack  The bottom of the shadow stack for this CPU.
**/
VOID
InitShadowStack (
  IN UINTN  CpuIndex,
  IN VOID   *ShadowStack
  );

/**
  This function set given attributes of the memory region specified by
  BaseAddress and Length.

  @param  This              The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
  @param  BaseAddress       The physical address that is the start address of
                            a memory region.
  @param  Length            The size in bytes of the memory region.
  @param  Attributes        The bit mask of attributes to set for the memory
                            region.

  @retval EFI_SUCCESS           The attributes were set for the memory region.
  @retval EFI_INVALID_PARAMETER Length is zero.
                                Attributes specified an illegal combination of
                                attributes that cannot be set together.
  @retval EFI_UNSUPPORTED       The processor does not support one or more
                                bytes of the memory resource range specified
                                by BaseAddress and Length.
                                The bit mask of attributes is not supported for
                                the memory resource range specified by
                                BaseAddress and Length.

**/
EFI_STATUS
EFIAPI
EdkiiSmmSetMemoryAttributes (
  IN  EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL   *This,
  IN  EFI_PHYSICAL_ADDRESS                  BaseAddress,
  IN  UINT64                                Length,
  IN  UINT64                                Attributes
  );

/**
  This function clears given attributes of the memory region specified by
  BaseAddress and Length.

  @param  This              The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
  @param  BaseAddress       The physical address that is the start address of
                            a memory region.
  @param  Length            The size in bytes of the memory region.
  @param  Attributes        The bit mask of attributes to clear for the memory
                            region.

  @retval EFI_SUCCESS           The attributes were cleared for the memory region.
  @retval EFI_INVALID_PARAMETER Length is zero.
                                Attributes specified an illegal combination of
                                attributes that cannot be cleared together.
  @retval EFI_UNSUPPORTED       The processor does not support one or more
                                bytes of the memory resource range specified
                                by BaseAddress and Length.
                                The bit mask of attributes is not supported for
                                the memory resource range specified by
                                BaseAddress and Length.

**/
EFI_STATUS
EFIAPI
EdkiiSmmClearMemoryAttributes (
  IN  EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL   *This,
  IN  EFI_PHYSICAL_ADDRESS                  BaseAddress,
  IN  UINT64                                Length,
  IN  UINT64                                Attributes
  );

/**
  This function retrieves the attributes of the memory region specified by
  BaseAddress and Length. If different attributes are got from different part
  of the memory region, EFI_NO_MAPPING will be returned.

  @param  This              The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
  @param  BaseAddress       The physical address that is the start address of
                            a memory region.
  @param  Length            The size in bytes of the memory region.
  @param  Attributes        Pointer to attributes returned.

  @retval EFI_SUCCESS           The attributes got for the memory region.
  @retval EFI_INVALID_PARAMETER Length is zero.
                                Attributes is NULL.
  @retval EFI_NO_MAPPING        Attributes are not consistent cross the memory
                                region.
  @retval EFI_UNSUPPORTED       The processor does not support one or more
                                bytes of the memory resource range specified
                                by BaseAddress and Length.

**/
EFI_STATUS
EFIAPI
EdkiiSmmGetMemoryAttributes (
  IN  EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL   *This,
  IN  EFI_PHYSICAL_ADDRESS                  BaseAddress,
  IN  UINT64                                Length,
  IN  UINT64                                *Attributes
  );

/**
  This function fixes up the address of the global variable or function
  referred in SmmInit assembly files to be the absoute address.
**/
VOID
EFIAPI
PiSmmCpuSmmInitFixupAddress (
 );

/**
  This function fixes up the address of the global variable or function
  referred in SmiEntry assembly files to be the absoute address.
**/
VOID
EFIAPI
PiSmmCpuSmiEntryFixupAddress (
 );

#endif